pugjs/is-expression

Name: is-expression

Owner: Pug

Description: Validates a string as a JavaScript expression

Created: 2015-11-12 01:31:44.0

Updated: 2017-04-24 22:23:18.0

Pushed: 2018-05-07 15:27:11.0

Homepage:

Size: 20

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

is-expression

Validates a string as a JavaScript expression

Build Status Dependency Status npm version

Installation
npm install is-expression
Usage
isExpression(src[, options])

Validates a string as a JavaScript expression.

src contains the source.

options can contain any Acorn options (since we use Acorn under-the-hood), or any of the following:

See the examples below for usage.

Examples
isExpression = require('is-expression')

pression('myVar')
 true
pression('var')
 false
pression('["an", "array", "\'s"].indexOf("index")')
 true

pression('var', {throw: true})
yntaxError: Unexpected token (1:0)
   at Parser.pp.raise (acorn/dist/acorn.js:940:13)
   at ...

pression('public')
 true
pression('public', {strict: true})
 false

pression('abc // my comment')
 false
pression('abc // my comment', {lineComment: true})
 true
License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.