mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Clarify doc example for _.compose.
Former-commit-id: bcd9337d0cc2f7b6a1ca77723f8d20d768cb0b91
This commit is contained in:
21
lodash.js
21
lodash.js
@@ -5001,11 +5001,22 @@
|
||||
* @returns {Function} Returns the new composed function.
|
||||
* @example
|
||||
*
|
||||
* var greet = function(name) { return 'hi ' + name; };
|
||||
* var exclaim = function(statement) { return statement + '!'; };
|
||||
* var welcome = _.compose(exclaim, greet);
|
||||
* welcome('moe');
|
||||
* // => 'hi moe!'
|
||||
* var realNameMap = {
|
||||
* 'curly': 'jerome'
|
||||
* };
|
||||
*
|
||||
* var format = function(name) {
|
||||
* name = realNameMap[name.toLowerCase()] || name;
|
||||
* return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
|
||||
* };
|
||||
*
|
||||
* var greet = function(formatted) {
|
||||
* return 'Hiya ' + formatted + '!';
|
||||
* };
|
||||
*
|
||||
* var welcome = _.compose(greet, format);
|
||||
* welcome('curly');
|
||||
* // => 'Hiya Jerome!'
|
||||
*/
|
||||
function compose() {
|
||||
var funcs = arguments;
|
||||
|
||||
Reference in New Issue
Block a user