diff --git a/lib/fp/template/doc/wiki.jst b/lib/fp/template/doc/wiki.jst index 9cebf049b..aae5e5aff 100644 --- a/lib/fp/template/doc/wiki.jst +++ b/lib/fp/template/doc/wiki.jst @@ -23,52 +23,6 @@ var object = require('lodash/fp/object'); var extend = require('lodash/fp/extend'); ``` -## Convert - -Although `lodash/fp` & its method modules come pre-converted, there are times -when you may want to customize the conversion. That’s when the `convert` method -comes in handy. -```js -// Every option is `true` by default. -var mapValues = fp.mapValues.convert({ - // Specify capping iteratee arguments. - 'cap': true, - // Specify currying. - 'curry': true, - // Specify fixed arity. - 'fixed': true, - // Specify immutable operations. - 'immutable': true, - // Specify rearranging arguments. - 'rearg': true -}); - -// Disable capping of iteratee arguments to access the `key` param. -var mapValuesWithKey = fp.mapValues.convert({ 'cap': false }); - -mapValuesWithKey(function(value, key) { - return key == 'a' ? -1 : value; -})({ 'a': 1, 'b': 1 }); -// => { 'a': -1, 'b': 1 } -``` - -It’s also possible to use the convert module directly for manual conversions. -```js -var convert = require('lodash/fp/convert'); - -// Convert by name. -var assign = convert('assign', require('lodash.assign')); - -// Convert by object. -var fp = convert({ - 'assign': require('lodash.assign'), - 'chunk': require('lodash.chunk') -}); - -// Convert by `lodash` instance. -var fp = convert(lodash.runInContext()); -``` - ## Chaining The `lodash/fp` module **does not** convert chain sequence methods. See @@ -138,3 +92,49 @@ There are <%= _.size(mapping.aliasToReal) %> method aliases:
<%= _.map(mapping.aliasToReal, function(realName, alias) { return ' * `_.' + alias + '` is an alias of `_.' + realName + '`'; }).join('\n') %> + +## Convert + +Although `lodash/fp` & its method modules come pre-converted, there are times +when you may want to customize the conversion. That’s when the `convert` method +comes in handy. +```js +// Every option is `true` by default. +var mapValues = fp.mapValues.convert({ + // Specify capping iteratee arguments. + 'cap': true, + // Specify currying. + 'curry': true, + // Specify fixed arity. + 'fixed': true, + // Specify immutable operations. + 'immutable': true, + // Specify rearranging arguments. + 'rearg': true +}); + +// Disable capping of iteratee arguments to access the `key` param. +var mapValuesWithKey = fp.mapValues.convert({ 'cap': false }); + +mapValuesWithKey(function(value, key) { + return key == 'a' ? -1 : value; +})({ 'a': 1, 'b': 1 }); +// => { 'a': -1, 'b': 1 } +``` + +It’s also possible to use the convert module directly for manual conversions. +```js +var convert = require('lodash/fp/convert'); + +// Convert by name. +var assign = convert('assign', require('lodash.assign')); + +// Convert by object. +var fp = convert({ + 'assign': require('lodash.assign'), + 'chunk': require('lodash.chunk') +}); + +// Convert by `lodash` instance. +var fp = convert(lodash.runInContext()); +```