Clarify doc example for _.compose.

Former-commit-id: bcd9337d0cc2f7b6a1ca77723f8d20d768cb0b91
This commit is contained in:
John-David Dalton
2013-07-28 23:47:57 -07:00
parent cc0c2f1b3c
commit 6547d03b91

View File

@@ -5001,11 +5001,22 @@
* @returns {Function} Returns the new composed function. * @returns {Function} Returns the new composed function.
* @example * @example
* *
* var greet = function(name) { return 'hi ' + name; }; * var realNameMap = {
* var exclaim = function(statement) { return statement + '!'; }; * 'curly': 'jerome'
* var welcome = _.compose(exclaim, greet); * };
* welcome('moe'); *
* // => 'hi moe!' * 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() { function compose() {
var funcs = arguments; var funcs = arguments;