Gathering detailed insights and metrics for escallmatch
Gathering detailed insights and metrics for escallmatch
Gathering detailed insights and metrics for escallmatch
Gathering detailed insights and metrics for escallmatch
ECMAScript CallExpression matcher made from function/method signature
npm install escallmatch
Typescript
Module System
Node Version
NPM Version
JavaScript (99.29%)
HTML (0.71%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
13 Stars
222 Commits
1 Forks
2 Watchers
1 Branches
2 Contributors
Updated on Jul 27, 2018
Latest Version
1.5.0
Package Id
escallmatch@1.5.0
Size
54.73 kB
NPM Version
3.10.3
Node Version
6.3.0
Published on
Aug 20, 2016
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
ECMAScript CallExpression matcher made from function/method signature
Creating CallExpression matcher for method signature 'assert.equal(actual, expected, [message])'
.
Then match against path/to/some_test.js
.
1var escallmatch = require('escallmatch'); 2var esprima = require('esprima'); 3var estraverse = require('estraverse'); 4var fs = require('fs'); 5 6var matcher = escallmatch('assert.equal(actual, expected, [message])'); 7 8estraverse.traverse(esprima.parse(fs.readFileSync('path/to/some_test.js')), { 9 enter: function (currentNode, parentNode) { 10 if (matcher.test(currentNode)) { 11 // currentNode is a CallExpression that matches to the signature 12 } 13 var argMatched = matcher.matchArgument(currentNode, parentNode); 14 if (argMatched) { 15 if (argMatched.kind === 'mandatory') { 16 // mandatory arg (in this case, `actual` or `expected`) 17 } else if (argMatched.kind === 'optional') { 18 // optional arg (in this case, `message`) 19 } 20 } 21 } 22});
where content of path/to/some_test.js
is:
1var assert = require('assert'); 2var anotherAssert = assert; 3var equal = assert.equal.bind(assert); 4var foo = '2'; 5var bar = 2; 6 7assert.equal(foo, bar); // matches 8assert.equal(bar, foo); // matches 9assert.equal(foo, bar, 'foo shoule be equal to bar'); // matches (with optional arg) 10 11assert.equal(); // does not match (less args) 12assert.equal(foo); // does not match (less args) 13assert.equal(foo, bar, 'hoge', 'fuga'); // does not match (too much args) 14 15assert.notEqual(foo, bar); // does not match (callee method name differs) 16anotherAssert.equal(foo, bar); // does not match (callee object name differs) 17equal(foo, bar); // does not match (callee does not match)
escallmatch
is a spin-off product of power-assert project.
Pull-requests, issue reports and patches are always welcomed.
Create matcher object for a given function/method signature string.
1var matcher = escallmatch('assert.equal(actual, expected, [message])');
Any arguments enclosed in bracket (for example, [message]
) means optional parameters. Without bracket means mandatory parameters.
Returns matcher
object having four methods, test
, matchArgument
, calleeAst
, and argumentSignatures
.
an object
for configuration options. If not passed, default options will be used.
type | default value |
---|---|
object | (return value of estraverse.VisitorKeys ) |
VisitorKeys for AST traversal. See estraverse.VisitorKeys and babel.types.VISITOR_KEYS.
type | default value |
---|---|
object | N/A |
Type and property whitelist on creating AST clone. astWhiteList
is an object containing NodeType as keys and properties as values.
1{ 2 ArrayExpression: ['type', 'elements'], 3 ArrayPattern: ['type', 'elements'], 4 ArrowFunctionExpression: ['type', 'id', 'params', 'body', 'generator', 'expression'], 5 AssignmentExpression: ['type', 'operator', 'left', 'right'], 6 ...
Tests whether node
matches the signature or not.
true
if matched.false
if not matched.node
should be an AST node object defined in Mozilla JavaScript AST spec.
Returns match result object representing whether node
(and its parentNode
) matches some argument of the signature or not.
null
if not matched.{name: 'actual', kind: 'mandatory'}
, whose name
is an argument name in the signature and kind
is 'mandatory'
or 'optional'
.node
and parentNode
should be AST node objects defined in Mozilla JavaScript AST spec.
Returns clone of callee AST object based on signature passed to escallmatch
function. Returned tree is one of AST node objects defined in Mozilla JavaScript AST spec (in most cases, Identifier
or MemberExpression
).
Returns array of argument signature objects based on signature passed to escallmatch
function. Returns array of objects like [{name: 'actual', kind: 'mandatory'}]
, whose name
is an argument name in the signature and kind
is 'mandatory'
or 'optional'
.
Install
$ npm install --save escallmatch
Install
$ bower install --save escallmatch
Then load (escallmatch
function is exported)
<script type="text/javascript" src="./path/to/bower_components/escallmatch/build/escallmatch.js"></script>
See CHANGELOG
Licensed under the MIT license.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 1/28 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More