Home

function: ary


ary(func: function, n: number): function

Creates a function that invokes `func`, with up to `n` arguments, ignoring any additional arguments.

Example(s):

map(['6', '8', '10'], ary(parseInt, 1))
// => [6, 8, 10]

Params:

Name Type Attribute Description
func The function to cap arguments for.
n The arity cap.

Returns:

function

  {
    "comment": "/**\r\n * Creates a function that invokes `func`, with up to `n` arguments,\r\n * ignoring any additional arguments.\r\n *\r\n * @since 3.0.0\r\n * @category Function\r\n * @param {Function} func The function to cap arguments for.\r\n * @param {number} [n=func.length] The arity cap.\r\n * @returns {Function} Returns the new capped function.\r\n * @example\r\n *\r\n * map(['6', '8', '10'], ary(parseInt, 1))\r\n * // => [6, 8, 10]\r\n */",
    "meta": {
        "range": [
            554,
            714
        ],
        "filename": "ary.js",
        "lineno": 20,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100000064",
            "name": "ary",
            "type": "FunctionDeclaration",
            "paramnames": [
                "func",
                "n"
            ]
        },
        "vars": {
            "n": "ary~n"
        }
    },
    "description": "Creates a function that invokes `func`, with up to `n` arguments,\rignoring any additional arguments.",
    "since": "3.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Function",
            "value": "Function"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "function"
                ]
            },
            "description": "The function to cap arguments for.",
            "name": "func"
        },
        {
            "type": {
                "names": [
                    "number"
                ]
            },
            "optional": true,
            "defaultvalue": "func.length",
            "description": "The arity cap.",
            "name": "n"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "function"
                ]
            },
            "description": "Returns the new capped function."
        }
    ],
    "examples": [
        "map(['6', '8', '10'], ary(parseInt, 1))\r// => [6, 8, 10]"
    ],
    "name": "ary",
    "longname": "ary",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000007",
    "___s": true,
    "filepath": "ary.js"
}