Skip to content

removed object-assign #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/rollingversions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ See the examples below for usage.
## Examples

```js
var isExpression = require('is-expression')
import isExpression from 'is-expression'

isExpression('myVar')
//=> true
Expand Down
28 changes: 13 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
'use strict';

var acorn = require('acorn');
var objectAssign = require('object-assign');

module.exports = isExpression;

var DEFAULT_OPTIONS = {
throw: false,
strict: false,
lineComment: false
};
const acorn = require('acorn');

function isExpression(src, options) {
options = objectAssign({}, DEFAULT_OPTIONS, options);
options = {
throw: false,
strict: false,
lineComment: false,
...options
};

try {
var parser = new acorn.Parser(options, src, 0);
const parser = new acorn.Parser(options, src, 0);

if (options.strict) {
parser.strict = true;
Expand All @@ -34,12 +30,14 @@ function isExpression(src, options) {
parser.unexpected();
}
} catch (ex) {
if (!options.throw) {
return false;
if (options.throw) {
throw ex;
}

throw ex;
return false;
}

return true;
}

module.exports = isExpression;
Loading