fn-annotate
Advanced tools
Comparing version 1.1.3 to 1.2.0
22
index.js
@@ -29,2 +29,14 @@ 'use strict'; | ||
function groupSubArguments(_, type, keys) { | ||
return type + keys.split(',') | ||
.map(function (arg) { | ||
return arg && arg.trim(); | ||
}) | ||
.filter(Boolean) | ||
.join('@'); | ||
} | ||
argumentString = argumentString.replace(/(\{)([^}]*)\}/g, groupSubArguments); | ||
argumentString = argumentString.replace(/(\[)([^}]*)\]/g, groupSubArguments); | ||
return argumentString.split(',') | ||
@@ -34,3 +46,13 @@ .map(function (arg) { | ||
}) | ||
.map(function (arg) { | ||
if (arg[0] === '{') { | ||
return arg.substring(1).split('@'); | ||
} | ||
if (arg[0] === '[') { | ||
return { items: arg.substring(1).split('@') }; | ||
} | ||
return arg; | ||
}) | ||
.filter(Boolean); | ||
} |
{ | ||
"name": "fn-annotate", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Get the argument names of a JavaScript function", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -37,2 +37,11 @@ 'use strict'; | ||
function supportsDestructuring() { | ||
try { | ||
var fn = global[EVIL]('(({x}) => x)'); | ||
return typeof fn === 'function'; | ||
} catch (ex) { | ||
return false; | ||
} | ||
} | ||
require('./function'); | ||
@@ -51,1 +60,5 @@ | ||
} | ||
if (supportsDestructuring()) { | ||
require('./destructuring'); | ||
} |
11614
12
248