mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Add mapping section to fp wiki template. [ci skip]
This commit is contained in:
@@ -25,7 +25,7 @@ var extend = require('lodash/fp/extend');
|
|||||||
|
|
||||||
## Convert
|
## Convert
|
||||||
|
|
||||||
This module is used to convert Lodash methods into their `fp` counterparts.
|
This module is used to convert Lodash methods to their `fp` counterparts.
|
||||||
```js
|
```js
|
||||||
var convert = require('lodash/fp/convert');
|
var convert = require('lodash/fp/convert');
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ var fp = convert({
|
|||||||
var fp = convert(lodash.runInContext());
|
var fp = convert(lodash.runInContext());
|
||||||
```
|
```
|
||||||
|
|
||||||
It’s customizable to create the `fp` wrapper that’s right for you.
|
It’s even customizable so you can create the `fp` function that’s right for you.
|
||||||
```js
|
```js
|
||||||
// Every option is `true` by default.
|
// Every option is `true` by default.
|
||||||
var filter = convert('filter', _.filter, {
|
var filter = convert('filter', _.filter, {
|
||||||
@@ -58,7 +58,7 @@ var filter = convert('filter', _.filter, {
|
|||||||
'rearg': true
|
'rearg': true
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set `cap` to `false` to create a wrapper that doesn’t cap iteratee arguments.
|
// Specify `cap` of `false` to create a function that doesn’t cap iteratee arguments.
|
||||||
var filter = convert('filter', _.filter, { 'cap': false });
|
var filter = convert('filter', _.filter, { 'cap': false });
|
||||||
|
|
||||||
filter(function(value, index) {
|
filter(function(value, index) {
|
||||||
@@ -67,9 +67,21 @@ filter(function(value, index) {
|
|||||||
// => ['a', 'c']
|
// => ['a', 'c']
|
||||||
```
|
```
|
||||||
|
|
||||||
## Notes
|
## Mapping
|
||||||
|
|
||||||
#### Arity
|
Immutable auto-curried iteratee-first data-last methods sound great, but what’s
|
||||||
|
that really mean for each method? Below is a breakdown of the mapping used to
|
||||||
|
convert each method.
|
||||||
|
|
||||||
|
#### Capped Iteratee Arguments
|
||||||
|
|
||||||
|
Methods which provide iteratees one argument:<br>
|
||||||
|
<%= toFuncList(_.keys(_.pick(mapping.iterateeAry, _.partial(_.eq, _, 1)))) %>
|
||||||
|
|
||||||
|
Methods which provide iteratees two arguments:<br>
|
||||||
|
<%= toFuncList(_.keys(_.pick(mapping.iterateeAry, _.partial(_.eq, _, 2)))) %>
|
||||||
|
|
||||||
|
#### Fixed Arity
|
||||||
|
|
||||||
Methods with arity fixed to one argument:<br>
|
Methods with arity fixed to one argument:<br>
|
||||||
<%= toFuncList(mapping.aryMethod[1]) %>
|
<%= toFuncList(mapping.aryMethod[1]) %>
|
||||||
@@ -83,20 +95,7 @@ Methods with arity fixed to three arguments:<br>
|
|||||||
Methods with arity fixed to four arguments:<br>
|
Methods with arity fixed to four arguments:<br>
|
||||||
<%= toFuncList(mapping.aryMethod[4]) %>
|
<%= toFuncList(mapping.aryMethod[4]) %>
|
||||||
|
|
||||||
#### Iteratees
|
#### Rearranged Arguments
|
||||||
|
|
||||||
Methods which provide iteratees one argument:<br>
|
|
||||||
<%= toFuncList(_.keys(_.pick(mapping.iterateeAry, _.partial(_.eq, _, 1)))) %>
|
|
||||||
|
|
||||||
Methods which provide iteratees two argument:<br>
|
|
||||||
<%= toFuncList(_.keys(_.pick(mapping.iterateeAry, _.partial(_.eq, _, 2)))) %>
|
|
||||||
|
|
||||||
#### New Methods
|
|
||||||
|
|
||||||
Methods created to accommodate Lodash’s variadic methods:<br>
|
|
||||||
<%= toFuncList(_.keys(mapping.remap)) %>
|
|
||||||
|
|
||||||
#### Argument Orders
|
|
||||||
|
|
||||||
Methods fixed to two arguments have an argument order of<br>
|
Methods fixed to two arguments have an argument order of<br>
|
||||||
<%= toArgOrder(mapping.aryRearg[2]) %>
|
<%= toArgOrder(mapping.aryRearg[2]) %>
|
||||||
@@ -115,6 +114,11 @@ Methods with custom argument orders:<br>
|
|||||||
Methods with unchanged argument orders:<br>
|
Methods with unchanged argument orders:<br>
|
||||||
<%= toFuncList(_.keys(mapping.skipRearg)) %>
|
<%= toFuncList(_.keys(mapping.skipRearg)) %>
|
||||||
|
|
||||||
|
#### New Methods
|
||||||
|
|
||||||
|
Methods created to accommodate Lodash’s variadic methods:<br>
|
||||||
|
<%= toFuncList(_.keys(mapping.remap)) %>
|
||||||
|
|
||||||
#### Aliases
|
#### Aliases
|
||||||
|
|
||||||
There are <%= _.size(mapping.aliasToReal) %> method aliases:<br>
|
There are <%= _.size(mapping.aliasToReal) %> method aliases:<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user