Home

function: curryRight


curryRight(func: function, arity: number): function

This method is like `curry` except that arguments are applied to `func` in the manner of `partialRight` instead of `partial`. The `curryRight.placeholder` value, which defaults to `_` in monolithic builds, may be used as a placeholder for provided arguments. **Note:** This method doesn't set the "length" property of curried functions.

Example(s):

const abc = function(a, b, c) {
  return [a, b, c]
}

const curried = curryRight(abc)

curried(3)(2)(1)
// => [1, 2, 3]

curried(2, 3)(1)
// => [1, 2, 3]

curried(1, 2, 3)
// => [1, 2, 3]

// Curried with placeholders.
curried(3)(1, _)(2)
// => [1, 2, 3]

Params:

Name Type Attribute Description
func The function to curry.
arity The arity of `func`.

Returns:

function

  {
    "comment": "/**\r\n * This method is like `curry` except that arguments are applied to `func`\r\n * in the manner of `partialRight` instead of `partial`.\r\n *\r\n * The `curryRight.placeholder` value, which defaults to `_` in monolithic\r\n * builds, may be used as a placeholder for provided arguments.\r\n *\r\n * **Note:** This method doesn't set the \"length\" property of curried functions.\r\n *\r\n * @since 3.0.0\r\n * @category Function\r\n * @param {Function} func The function to curry.\r\n * @param {number} [arity=func.length] The arity of `func`.\r\n * @returns {Function} Returns the new curried function.\r\n * @example\r\n *\r\n * const abc = function(a, b, c) {\r\n *   return [a, b, c]\r\n * }\r\n *\r\n * const curried = curryRight(abc)\r\n *\r\n * curried(3)(2)(1)\r\n * // => [1, 2, 3]\r\n *\r\n * curried(2, 3)(1)\r\n * // => [1, 2, 3]\r\n *\r\n * curried(1, 2, 3)\r\n * // => [1, 2, 3]\r\n *\r\n * // Curried with placeholders.\r\n * curried(3)(1, _)(2)\r\n * // => [1, 2, 3]\r\n */",
    "meta": {
        "range": [
            1073,
            1294
        ],
        "filename": "curryRight.js",
        "lineno": 41,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100001044",
            "name": "curryRight",
            "type": "FunctionDeclaration",
            "paramnames": [
                "func",
                "arity"
            ]
        },
        "vars": {
            "result": "curryRight~result",
            "result.placeholder": "curryRight~result.placeholder"
        }
    },
    "description": "This method is like `curry` except that arguments are applied to `func`\rin the manner of `partialRight` instead of `partial`.\r\rThe `curryRight.placeholder` value, which defaults to `_` in monolithic\rbuilds, may be used as a placeholder for provided arguments.\r\r**Note:** This method doesn't set the \"length\" property of curried functions.",
    "since": "3.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Function",
            "value": "Function"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "function"
                ]
            },
            "description": "The function to curry.",
            "name": "func"
        },
        {
            "type": {
                "names": [
                    "number"
                ]
            },
            "optional": true,
            "defaultvalue": "func.length",
            "description": "The arity of `func`.",
            "name": "arity"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "function"
                ]
            },
            "description": "Returns the new curried function."
        }
    ],
    "examples": [
        "const abc = function(a, b, c) {\r  return [a, b, c]\r}\r\rconst curried = curryRight(abc)\r\rcurried(3)(2)(1)\r// => [1, 2, 3]\r\rcurried(2, 3)(1)\r// => [1, 2, 3]\r\rcurried(1, 2, 3)\r// => [1, 2, 3]\r\r// Curried with placeholders.\rcurried(3)(1, _)(2)\r// => [1, 2, 3]"
    ],
    "name": "curryRight",
    "longname": "curryRight",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000109",
    "___s": true,
    "filepath": "curryRight.js"
}