estree-is-member-expression
v1.0.0
Published
check if an AST node is a MemberExpression, in general or a specific one
Downloads
233,346
Maintainers
Readme
estree-is-member-expression
check if an AST node is a MemberExpression, in general or a specific one
Install
npm install estree-is-member-expression
Usage
var isMemberExpression = require('estree-is-member-expression')
var node = parse('function a () {}')
isMemberExpression(node) // false
var node = parse('module.exports')
isMemberExpression(node) // true
isMemberExpression(node, 'module.exports') // true
isMemberExpression(node, 'module.filename') // false
isMemberExpression(node, 'module.filename.toString') // false
var node = parse('module.filename.toString')
isMemberExpression(node, 'module.filename.toString') // true
Also see the tests for more examples.
API
isMemberExpression(node, pattern)
Check if node
is a MemberExpression.
If pattern
is given, check if node
is a MemberExpression matching the pattern
.
pattern
can be a .-delimited string or an array. The pattern can contain more than two elements, all of them must match.