Wondering what’s next for npm?Check out our public roadmap! »

estree-is-require

1.0.0 • Public • Published

estree-is-require

check if an AST node is a valid require() call

npm travis standard

Install

npm install estree-is-require

Usage

var isRequire = require('estree-is-require')
 
var node = parse('function a () {}')
isRequire(node) // false
var node = parse('require("abc")')
isRequire(node) // true
isRequire(node, 'abc') // true
isRequire(node, 'xyz') // false
var node = parse('require(10)')
isRequire(node, 10) // true

Also see the tests for more examples.

API

isRequire(node, source)

Check if node is a call to require. If source is given, the first argument to require matches it.

License

Apache-2.0

Install

npm i estree-is-require

DownloadsWeekly Downloads

6,703

Version

1.0.0

License

Apache-2.0

Last publish

Collaborators

  • avatar