mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 03:47:50 +00:00
Make exceptions to fp argument ordering stand out. [ci skip]
This commit is contained in:
@@ -69,11 +69,11 @@ The iteratee of `mapKeys` is invoked with one argument: (key)
|
|||||||
|
|
||||||
Methods have fixed arities to support auto-currying.
|
Methods have fixed arities to support auto-currying.
|
||||||
```js
|
```js
|
||||||
// The `lodash/padStart` method accepts an optional `chars` param.
|
// `lodash/padStart` accepts an optional `chars` param.
|
||||||
_.padStart('a', 3, '-')
|
_.padStart('a', 3, '-')
|
||||||
// → '--a'
|
// → '--a'
|
||||||
|
|
||||||
// The `lodash/fp/padStart` method does not.
|
// `lodash/fp/padStart` does not.
|
||||||
fp.padStart(3)('a');
|
fp.padStart(3)('a');
|
||||||
// → ' a'
|
// → ' a'
|
||||||
fp.padCharsStart('-')(3)('a');
|
fp.padCharsStart('-')(3)('a');
|
||||||
@@ -96,40 +96,44 @@ Methods with a fixed arity of four:<br>
|
|||||||
|
|
||||||
Method arguments are rearranged to make composition easier.
|
Method arguments are rearranged to make composition easier.
|
||||||
```js
|
```js
|
||||||
// The `lodash/filter` method is data-first iteratee-last:
|
// `lodash/filter` is data-first iteratee-last:
|
||||||
// (collection, iteratee)
|
// (collection, iteratee)
|
||||||
var compact = _.partial(_.filter, _, Boolean);
|
var compact = _.partial(_.filter, _, Boolean);
|
||||||
compact(['a', null, 'c']);
|
compact(['a', null, 'c']);
|
||||||
// → ['a', 'c']
|
// → ['a', 'c']
|
||||||
|
|
||||||
// The `lodash/fp/filter` method is iteratee-first data-last:
|
// `lodash/fp/filter` is iteratee-first data-last:
|
||||||
// (iteratee, collection)
|
// (iteratee, collection)
|
||||||
var compact = fp.filter(Boolean);
|
var compact = fp.filter(Boolean);
|
||||||
compact(['a', null, 'c']);
|
compact(['a', null, 'c']);
|
||||||
// → ['a', 'c']
|
// → ['a', 'c']
|
||||||
```
|
```
|
||||||
|
|
||||||
Methods with a fixed arity of two have an argument order of:<br>
|
##### Most methods follow these rules
|
||||||
|
|
||||||
|
A fixed arity of two has an argument order of:<br>
|
||||||
<%= toArgOrder(mapping.aryRearg[2]) %>
|
<%= toArgOrder(mapping.aryRearg[2]) %>
|
||||||
|
|
||||||
Methods with a fixed arity of three have an argument order of:<br>
|
A fixed arity of three has an argument order of:<br>
|
||||||
<%= toArgOrder(mapping.aryRearg[3]) %>
|
<%= toArgOrder(mapping.aryRearg[3]) %>
|
||||||
|
|
||||||
Methods with a fixed arity of four have an argument order of:<br>
|
A fixed arity of four has an argument order of:<br>
|
||||||
<%= toArgOrder(mapping.aryRearg[4]) %>
|
<%= toArgOrder(mapping.aryRearg[4]) %>
|
||||||
|
|
||||||
|
##### Exceptions to the rules
|
||||||
|
|
||||||
|
Methods that accept an array of arguments as their second parameter:<br>
|
||||||
|
<%= toFuncList(_.keys(mapping.methodSpread)) %>
|
||||||
|
|
||||||
|
Methods with unchanged argument orders:<br>
|
||||||
|
<%= toFuncList(_.keys(mapping.skipRearg)) %>
|
||||||
|
|
||||||
Methods with custom argument orders:<br>
|
Methods with custom argument orders:<br>
|
||||||
<%= _.map(_.keys(mapping.methodRearg), function(methodName) {
|
<%= _.map(_.keys(mapping.methodRearg), function(methodName) {
|
||||||
var orders = mapping.methodRearg[methodName];
|
var orders = mapping.methodRearg[methodName];
|
||||||
return ' * `_.' + methodName + '` has an order of ' + toArgOrder(orders);
|
return ' * `_.' + methodName + '` has an order of ' + toArgOrder(orders);
|
||||||
}).join('\n') %>
|
}).join('\n') %>
|
||||||
|
|
||||||
Methods with unchanged argument orders:<br>
|
|
||||||
<%= toFuncList(_.keys(mapping.skipRearg)) %>
|
|
||||||
|
|
||||||
The methods `invokeArgs`, `invokeArgsMap`, `partial`, `partialRight`, & `without`
|
|
||||||
accept an array of arguments as their second parameter.
|
|
||||||
|
|
||||||
#### New Methods
|
#### New Methods
|
||||||
|
|
||||||
Not all variadic methods have corresponding new method variants. Feel free to
|
Not all variadic methods have corresponding new method variants. Feel free to
|
||||||
|
|||||||
Reference in New Issue
Block a user