Comparing version 2.0.2 to 2.0.3
@@ -5,3 +5,3 @@ 'use strict'; | ||
var babylon = require('babylon'); | ||
var parser = require('@babel/parser'); | ||
@@ -16,3 +16,13 @@ /* | ||
*/ | ||
var cache = new WeakMap(); | ||
module.exports = function getArguments(f) { | ||
if (cache.has(f)) { | ||
return cache.get(f); | ||
} | ||
var args = _getArgs(f); | ||
cache.set(f, args); | ||
return args; | ||
}; | ||
function _getArgs(f) { | ||
var amended = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
@@ -46,3 +56,3 @@ | ||
try { | ||
var ast = babylon.parse(code); | ||
var ast = parser.parse(code, { plugins: ['objectRestSpread'] }); | ||
var node = findNode(ast); | ||
@@ -61,3 +71,3 @@ | ||
if (!amended) { | ||
return getArguments(f, true); | ||
return _getArgs(f, true); | ||
} | ||
@@ -64,0 +74,0 @@ |
# Change History | ||
## v2.0.3 (2018-10-24) | ||
* Argument name resolution is now cached internally for better performance. | ||
* Arguments can now be parsed from code containing object rest spread sytnax. | ||
Contributions thanks to [@dshook](https://github.com/dshook) | ||
## v2.0.2 (2017-09-08) | ||
@@ -4,0 +11,0 @@ |
@@ -1,2 +0,2 @@ | ||
const babylon = require('babylon'); | ||
const parser = require('@babel/parser'); | ||
@@ -11,3 +11,13 @@ /* | ||
*/ | ||
module.exports = function getArguments(f, amended = false) | ||
var cache = new WeakMap(); | ||
module.exports = function getArguments(f){ | ||
if(cache.has(f)){ | ||
return cache.get(f); | ||
} | ||
let args = _getArgs(f); | ||
cache.set(f, args); | ||
return args; | ||
} | ||
function _getArgs(f, amended = false) | ||
{ | ||
@@ -40,3 +50,3 @@ if (!f) { | ||
try { | ||
const ast = babylon.parse(code); | ||
const ast = parser.parse(code, {plugins: ['objectRestSpread']}); | ||
const node = findNode(ast); | ||
@@ -54,3 +64,3 @@ | ||
if (!amended) { | ||
return getArguments(f, true); | ||
return _getArgs(f, true); | ||
} | ||
@@ -57,0 +67,0 @@ |
'use strict'; | ||
const babylon = require('babylon'); | ||
const parser = require('@babel/parser'); | ||
@@ -13,3 +13,13 @@ /* | ||
*/ | ||
module.exports = function getArguments(f, amended = false) { | ||
var cache = new WeakMap(); | ||
module.exports = function getArguments(f) { | ||
if (cache.has(f)) { | ||
return cache.get(f); | ||
} | ||
let args = _getArgs(f); | ||
cache.set(f, args); | ||
return args; | ||
}; | ||
function _getArgs(f, amended = false) { | ||
if (!f) { | ||
@@ -41,3 +51,3 @@ throw new Error('Missing function or class parameter'); | ||
try { | ||
const ast = babylon.parse(code); | ||
const ast = parser.parse(code, { plugins: ['objectRestSpread'] }); | ||
const node = findNode(ast); | ||
@@ -54,3 +64,3 @@ | ||
if (!amended) { | ||
return getArguments(f, true); | ||
return _getArgs(f, true); | ||
} | ||
@@ -57,0 +67,0 @@ |
{ | ||
"name": "billy", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "A minimal application harness that stays out of your way and out of your code.", | ||
@@ -38,4 +38,4 @@ "author": "Brandon Valosek <bvalosek@gmail.com>", | ||
"dependencies": { | ||
"babylon": "6.17.0", | ||
"debug": "2.6.6" | ||
"@babel/parser": "^7.1.3", | ||
"debug": "^4.1.0" | ||
}, | ||
@@ -42,0 +42,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48666
1226
17
+ Added@babel/parser@^7.1.3
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.3(transitive)
+ Added@babel/types@7.26.3(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedms@2.1.3(transitive)
- Removedbabylon@6.17.0
- Removedbabylon@6.17.0(transitive)
- Removeddebug@2.6.6(transitive)
- Removedms@0.7.3(transitive)
Updateddebug@^4.1.0