yudarity
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -6,3 +6,9 @@ module.exports = function (func) { | ||
} | ||
return result[1].replace(/\{[^\}]*\}/g, 'param') .split(/\s*,\s*/).length; // eslint-disable-line | ||
var argumentStr = result[1].trim(); | ||
if (argumentStr.substring(argumentStr.length - 1, argumentStr.length) === ',') { | ||
argumentStr = argumentStr.substring(0, argumentStr.length - 1); | ||
} | ||
return argumentStr.replace(/\{[^\}]*\}/g, 'param') .split(/\s*,\s*/).length; // eslint-disable-line | ||
} |
{ | ||
"name": "yudarity", | ||
"description": "Returns function arity (number of possible arguments) supports all ES6 features including argument destructor and default.", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Roee Yudilevtich (RoeeYud@gmail.com)", | ||
@@ -14,3 +14,4 @@ "devDependencies": { | ||
"verbose": true, | ||
"testEnvironment": "node" | ||
"testEnvironment": "node", | ||
"transform": {} | ||
}, | ||
@@ -17,0 +18,0 @@ "repository": "https://github.com/roeeyud/arity", |
@@ -37,2 +37,33 @@ const arity = require('../arity'); | ||
}); | ||
it('"," at the end', function () { | ||
function testFn( | ||
id, | ||
options, | ||
a, | ||
c, | ||
) { | ||
return dispatch({ | ||
resource: 'a', | ||
method: 'b', | ||
path: 'c', | ||
payload: id, | ||
options, | ||
}); | ||
} | ||
expect(arity(testFn)).toBe(4); | ||
}); | ||
it('arrow', function () { | ||
expect(arity((id, options, a, c) => { | ||
return dispatch({ | ||
resource: 'a', | ||
method: 'b', | ||
path: 'c', | ||
payload: id, | ||
options, | ||
}); | ||
})).toBe(4); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
122733
70
13