mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Add fp.convert to "Convert" section.
This commit is contained in:
@@ -100,7 +100,7 @@ when you may want to customize the conversion. That’s when the `convert` metho
|
|||||||
comes in handy.
|
comes in handy.
|
||||||
```js
|
```js
|
||||||
// Every option is `true` by default.
|
// Every option is `true` by default.
|
||||||
var mapValues = fp.mapValues.convert({
|
var _fp = fp.convert({
|
||||||
// Specify capping iteratee arguments.
|
// Specify capping iteratee arguments.
|
||||||
'cap': true,
|
'cap': true,
|
||||||
// Specify currying.
|
// Specify currying.
|
||||||
@@ -113,16 +113,17 @@ var mapValues = fp.mapValues.convert({
|
|||||||
'rearg': true
|
'rearg': true
|
||||||
});
|
});
|
||||||
|
|
||||||
// Disable capping of iteratee arguments to access the `key` param.
|
// The `convert` method is available on each method too.
|
||||||
var mapValuesWithKey = fp.mapValues.convert({ 'cap': false });
|
var mapValuesWithKey = fp.mapValues.convert({ 'cap': false });
|
||||||
|
|
||||||
|
// Here’s an example of disabling iteratee argument caps to access the `key` param.
|
||||||
mapValuesWithKey(function(value, key) {
|
mapValuesWithKey(function(value, key) {
|
||||||
return key == 'a' ? -1 : value;
|
return key == 'a' ? -1 : value;
|
||||||
})({ 'a': 1, 'b': 1 });
|
})({ 'a': 1, 'b': 1 });
|
||||||
// => { 'a': -1, 'b': 1 }
|
// => { 'a': -1, 'b': 1 }
|
||||||
```
|
```
|
||||||
|
|
||||||
It’s also possible to use the convert module directly for manual conversions.
|
// Manual conversions are also possible with the `convert` module.
|
||||||
```js
|
```js
|
||||||
var convert = require('lodash/fp/convert');
|
var convert = require('lodash/fp/convert');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user