Add mapping section to fp wiki template. [ci skip]

This commit is contained in:
John-David Dalton
2016-02-15 17:38:30 -08:00
parent 0da3674d5e
commit 97fd94744e

View File

@@ -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());
``` ```
Its customizable to create the `fp` wrapper thats right for you. Its even customizable so you can create the `fp` function thats 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 doesnt cap iteratee arguments. // Specify `cap` of `false` to create a function that doesnt 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 whats
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 Lodashs 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 Lodashs 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>