Neuron Powered Motorization

    guess-function-max-arity

    1.0.0 • Public • Published

    guess-function-max-arity

    Node.js CI

    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

    Install

    npm i guess-function-max-arity

    DownloadsWeekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    17.5 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar