Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple promise.fold usage example
// Should log:
// 3
// Bob
// b
var when = require('when');
when.resolve(1).fold(sum, 2).done(console.log);
when.resolve({ name: 'Bob' }).fold(get, 'name').done(console.log);
when.resolve(['a', 'b', 'c']).fold(get, 1).done(console.log);
function sum(x, y) {
return x + y;
function get(k, o) {
return o[k];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.