Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

curry

v4.17.11arrow_drop_down
v4.17.11
STATUS
Passing
DOWNLOADS
15
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
7 months ago
SIZE
5 KB
subject
Creates a function that accepts arguments of `func` and either invokes
1 contributor
Use curry in your project ?
Copied
npm i @bit/lodash.lodash.curry
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
revert changes
reload
toggle layout
maximize
curried(1)(2)(3);
modifieddraft
chevron_left
chevron_right
curry (
func:Function,
arity:number?,
null-null
) : Function

Creates a function that accepts arguments of func and either invokes func returning its result, if at least arity number of arguments have been provided, or returns a function that accepts the remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient.

The _.curry.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
var abc = function(a, b, c) {
  return [a, b, c];
};

var curried = _.curry(abc);

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

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

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

// Curried with placeholders.
curried(1)(_, 3)(2);
// => [1, 2, 3]
Arguments
func: Function

The function to curry.

arity: number?

The arity of func.

null-null

{Object} [guard] Enables use as an iteratee for methods like _.map.

Returns
Function

Returns the new curried function.