diff --git a/lib/fp/template/doc/wiki.jst b/lib/fp/template/doc/wiki.jst index 42ae65c3b..2b0b3f35a 100644 --- a/lib/fp/template/doc/wiki.jst +++ b/lib/fp/template/doc/wiki.jst @@ -31,6 +31,17 @@ to convert each method. #### Capped Iteratee Arguments +Iteratee arguments are capped to avoid gotchas with variadic iteratees. +```js +// The `lodash/map` iteratee recieves three arguments: (value, index|key, collection). +_.map(['6', '8', '10'], parseInt); +// → [6, NaN, 2] + +// The `lodash/fp/map` iteratee is capped at one argument: (value). +fp.map(parseInt)(['6', '8', '10']); +// → [6, 8, 10] +``` + Methods that cap iteratees to one argument:
<%= toFuncList(_.keys(_.pickBy(mapping.iterateeAry, _.partial(_.eq, _, 1)))) %> @@ -41,6 +52,19 @@ The iteratee of `mapKeys` is invoked with one argument: (key) #### Fixed Arity +Methods have fixed arities to support auto-currying. +```js +// The `lodash/padStart` method accepts an optional `chars` param. +_.padStart('a', 3, '-') +// → '--a' + +// The `lodash/fp/padStart` method does not. +fp.padStart(3)('a'); +// → ' a' +fp.padCharsStart('-')(3)('a'); +// → '--a' +``` + Methods with a fixed arity of one:
<%= toFuncList(mapping.aryMethod[1]) %> @@ -55,6 +79,19 @@ Methods with a fixed arity of four:
#### Rearranged Arguments +Method arguments are rearranged to make composition easier. +```js +// The `lodash/filter` method accepts (collection, iteratee). +var compact = _.partial(_.filter, _, Boolean); +compact(['a', null, 'c']); +// → ['a', 'c'] + +// The `lodash/fp/filter` method accepts (iteratee, collection) +var compact = fp.filter(Boolean); +compact(['a', null, 'c']); +// → ['a', 'c'] +``` + Methods with a fixed arity of two have an argument order of:
<%= toArgOrder(mapping.aryRearg[2]) %> @@ -77,6 +114,10 @@ apply as their second parameter. #### New Methods +Not all variadic methods have corresponding new method variants. Feel free to +[request](https://github.com/lodash/lodash/blob/master/.github/CONTRIBUTING.md#feature-requests) +any additions. + Methods created to accommodate Lodash’s variadic methods:
<%= toFuncList(_.keys(mapping.remap)) %>