
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
is-expression-babylon
Advanced tools
Check if a string is a valid JavaScript expression using Babylon
Validates a string as a JavaScript expression using Babylon
An alternative version of this module using Acorn instead of Babylon is available at is-expression. While this module aims to support all ECMAScript features, even spec proposals in Stage 0, is-expression is more conservative on the features it implements. Pick your poison.
npm install is-expression-babylon
const isExpression = require('is-expression-babylon');
isExpression(src[, options])Validates a string as a JavaScript expression.
src contains the source.
options can contain any Babylon options, or any of the following:
throw: Throw an error if the string is not an expression. The error can
be an Acorn error, with location information in err.loc and err.pos.
Defaults to false.strict: Use strict mode when trying to parse the string. Defaults to
false. Even if this option is false, if you have provided
options.sourceType === 'module' which imples strict mode under ES2015,
strict mode will be used.lineComment: When true, allows line comments in the expression.
Defaults to false for safety.See the examples below for usage.
isExpression.getExpression(src[, options])Get the Babylon Expression AST node of a string.
src contains the source.
options can contain any Babylon options, or any of the following:
strict: Use strict mode when trying to parse the string. Defaults to
false. Even if this option is false, if you have provided
options.sourceType === 'module' which imples strict mode under ES2015,
strict mode will be used.lineComment: When true, allows line comments in the expression.
Defaults to false for safety.If the string is not an expression, an error is thrown.
const isExpression = require('is-expression-babylon');
isExpression('myVar');
//=> true
isExpression('var');
//=> false
isExpression('["an", "array", "\'s"].indexOf("index")');
//=> true
isExpression('var', {throw: true});
// SyntaxError: Unexpected token (1:0)
// at Parser.pp.raise (acorn/dist/acorn.js:940:13)
// at ...
isExpression('public');
//=> true
isExpression('public', {strict: true});
//=> false
isExpression('abc // my comment');
//=> false
isExpression('abc // my comment', {lineComment: true});
//=> true
const expression = isExpression.getExpression('abc');
//=> Node { type: 'Identifier', ... }
MIT
1.1.0 / 2016-10-11
isExpression.getExpressionFAQs
Check if a string is a valid JavaScript expression using Babylon
The npm package is-expression-babylon receives a total of 6 weekly downloads. As such, is-expression-babylon popularity was classified as not popular.
We found that is-expression-babylon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.