guess-function-max-arity
v1.0.0
Published
Guess the maximum number of arguments the given function will consume.
Downloads
3
Maintainers
Readme
guess-function-max-arity
SEnD HelP
About
Guess the maximum number of arguments the given function will consume.
Determines, with a small amount of analysis, whether the function is variadic. Suspected variadic functions will produce Infinity
.
Intended use case: sane defaults for optimization flags in developer-oriented tooling.
Please don't use this in your production code.
Install
$ npm i guess-function-max-arity
Usage
import { guessMaxArity } from 'guess-function-max-arity';
guessArity(() => {}); // 0
guessArity((...args) => args); // Infinity
guessArity(function () {
return arguments;
}); // Infinity
guessArity({
async *async() {
return 'arguments';
},
}); // 0
guessArity(
() =>
function () {
return arguments;
}
); // 0
guessArity(function (arguments) {
return arguments;
}); // 1