Skip to content

Commit

Permalink
Paying tribute to the despot...
Browse files Browse the repository at this point in the history
  • Loading branch information
codeworrior committed Jun 15, 2021
1 parent 131b8c4 commit 7ea1a69
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/lbt/utils/parseJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
const espree = require("espree");
const {Syntax} = espree;

function parseJS(code, userOptions = {}) {
const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);

function parseJS(code, userOptions = {}) {
// allowed options and their defaults
const options = {
comment: false,
Expand All @@ -14,8 +15,8 @@ function parseJS(code, userOptions = {}) {
};

// validate and assign options
for (const [name,value] of Object.entries(userOptions)) {
if (!options.hasOwnProperty(name)) {
for (const [name, value] of Object.entries(userOptions)) {
if (!hasOwn(options, name)) {
throw new TypeError(`Allowed parser options are ${Object.keys(options)}, but not '${name}'`);
}
options[name] = value;
Expand Down

0 comments on commit 7ea1a69

Please sign in to comment.