Socket
Book a DemoInstallSign in
Socket

esprimaq

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esprimaq

Query esprima ASTs by using a chainable query syntax.

0.1.0
latest
Source
npmnpm
Version published
Weekly downloads
2.1K
-46.38%
Maintainers
1
Weekly downloads
 
Created
Source

esprimaq (BETA)

Query esprima ASTs by using a chainable query syntax.

Install

  npm install esprimaq

Usage

var find = require('esprimaq');

Find function calls of the mongo function:

var syntax = esprima.parse("mongo('hello');", {tolerant: true});
var result = find(syntax).callFn('mongo').exec();
assert.equal('hello', result[0].arguments[0].value);

Find variable declarations of x:

var syntax = esprima.parse("var x = 5;", {tolerant: true});
var result = find(syntax).varDecl('x').exec();
assert.equal('5', result[0].init.value);

Find calls to hello.bye:

var syntax = esprima.parse("hello.bye(w00t);", {tolerant: true});
var result = find(syntax).callMethod('hello', 'bye').exec();
assert.equal('w00t', result[0].arguments[0].name);

Find calls using this:

var syntax = esprima.parse('this.foo(bar);', {tolerant: true});
var result = find(syntax).callThisMethod('foo').exec();
assert.equal('bar', result[0].arguments[0].name);

TODO

  • Implement tons of selectors:
    • Identifier
    • CallExpression
    • ExpressionStatement
    • AssignmentExpression
    • Literal
    • Property
    • Identifier
    • among others
  • Implement way of doing AND in queries

FAQ

Why another esprima query/selector library?

I wanted a simpler and CSS-selector-free alternative to query esprima ASTs.

Do you know any cool CSS-based alternatives?

Yes, check these projects:

  • esquery
  • esprima-selector

Changelog

0.1.0

Added
  • Adding support for callThisMethod, fnExpressions and identifiers filters.

0.0.1

  • Initial Release

License

(The MIT License)

Copyright (c) 2014-2016 Alberto Pose < albertopose at gmail.com >

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FAQs

Package last updated on 22 Mar 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.