This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createAccount(email, password, done) { | |
var id = uuid(); | |
async.waterfall([ | |
_.partial(Services.Accounts.provision, email, password), | |
_.partial(Services.Notification.confirm, email) | |
], | |
_.partial(done, _, id, _)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createAccount(email, password, done) { | |
var id = uuid(); | |
async.waterfall([ | |
function(callback) { | |
Services.Accounts.provision(email, password, callback); | |
}, | |
function(accountId, callback) { | |
Services.Account.enable(email, accountId, callback); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function partial(fx) { | |
var firstArgs = Array.prototype.slice.call(arguments, 1); | |
return function fx2() { | |
var secondArgs = Array.prototype.slice.call(arguments, 0); | |
return fx.apply(null, firstArgs.concat(secondArgs)); | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sumWithXFixedToTen(20); // 30 | |
sumWithXFixedToTen(99); // 109 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sumWithXFixedToTen = _.partial(sum, 10); | |
(typeof sumWithXFixedToTen); // Function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1, 2, 3, 4, 5].map(_.partial(sum, 10)); // [11, 12, 13, 14, 15] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1, 2, 3, 4, 5].map(function(n) { | |
return sum(10, n); | |
}); // [11, 12, 13, 14, 15] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1, 2, 3, 4, 5].map(function(n) { | |
return sum(10, n); | |
}); // [11, 12, 13, 14, 15] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sum(x, y) { | |
return x + y; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return fruitsOfTheWorld.map(function(fruits) { | |
return fruits.map(capitalize); | |
}); |