HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
coolaj86
futures
OPEN SOURCE2011–2012
coolaj86 / futures

futures

Moved to https://github.com/FuturesJS

4Distinct people
7Mentions
0Explicit recommenders
1GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Moved to https://github.com/FuturesJS

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by month7 dated mentions

Observed mentions: 2011-02-26 18:34:32 UTC to 2012-11-26 16:10:45 UTC.

0122011-02-01 00:00:00 UTC to 2011-03-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 commentsFeb 20112011-03-01 00:00:00 UTC to 2011-04-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2011-04-01 00:00:00 UTC to 2011-05-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2011-05-01 00:00:00 UTC to 2011-06-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2011-06-01 00:00:00 UTC to 2011-07-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2011-07-01 00:00:00 UTC to 2011-08-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2011-08-01 00:00:00 UTC to 2011-09-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2011-09-01 00:00:00 UTC to 2011-10-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2011-10-01 00:00:00 UTC to 2011-11-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2011-11-01 00:00:00 UTC to 2011-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2011-12-01 00:00:00 UTC to 2012-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 commentsDec 20112012-01-01 00:00:00 UTC to 2012-02-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2012-02-01 00:00:00 UTC to 2012-03-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2012-03-01 00:00:00 UTC to 2012-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2012-04-01 00:00:00 UTC to 2012-05-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2012-05-01 00:00:00 UTC to 2012-06-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2012-06-01 00:00:00 UTC to 2012-07-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2012-07-01 00:00:00 UTC to 2012-08-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2012-08-01 00:00:00 UTC to 2012-09-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2012-09-01 00:00:00 UTC to 2012-10-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2012-10-01 00:00:00 UTC to 2012-11-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2012-11-01 00:00:00 UTC to 2012-12-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsNov 2012

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Feb 20112011-02-01 00:00:00 UTC2011-03-01 00:00:00 UTC110
Mar 20112011-03-01 00:00:00 UTC2011-04-01 00:00:00 UTC101
Apr 20112011-04-01 00:00:00 UTC2011-05-01 00:00:00 UTC000
May 20112011-05-01 00:00:00 UTC2011-06-01 00:00:00 UTC000
Jun 20112011-06-01 00:00:00 UTC2011-07-01 00:00:00 UTC000
Jul 20112011-07-01 00:00:00 UTC2011-08-01 00:00:00 UTC000
Aug 20112011-08-01 00:00:00 UTC2011-09-01 00:00:00 UTC000
Sep 20112011-09-01 00:00:00 UTC2011-10-01 00:00:00 UTC000
Oct 20112011-10-01 00:00:00 UTC2011-11-01 00:00:00 UTC000
Nov 20112011-11-01 00:00:00 UTC2011-12-01 00:00:00 UTC000
Dec 20112011-12-01 00:00:00 UTC2012-01-01 00:00:00 UTC000
Jan 20122012-01-01 00:00:00 UTC2012-02-01 00:00:00 UTC101
Feb 20122012-02-01 00:00:00 UTC2012-03-01 00:00:00 UTC000
Mar 20122012-03-01 00:00:00 UTC2012-04-01 00:00:00 UTC000
Apr 20122012-04-01 00:00:00 UTC2012-05-01 00:00:00 UTC202
May 20122012-05-01 00:00:00 UTC2012-06-01 00:00:00 UTC000
Jun 20122012-06-01 00:00:00 UTC2012-07-01 00:00:00 UTC000
Jul 20122012-07-01 00:00:00 UTC2012-08-01 00:00:00 UTC000
Aug 20122012-08-01 00:00:00 UTC2012-09-01 00:00:00 UTC000
Sep 20122012-09-01 00:00:00 UTC2012-10-01 00:00:00 UTC000
Oct 20122012-10-01 00:00:00 UTC2012-11-01 00:00:00 UTC101
Nov 20122012-11-01 00:00:00 UTC2012-12-01 00:00:00 UTC101

What Hacker News says

7 sources
The general case of a Future/Promise is that you can design a nicer (sometimes) API. Instead of forcing the caller to provide their own callback functions immediately when they call your function, you can return a Future instead and the client can ask for the data on that whenever. e.g.: function read_key(key, cb) { database.getItem(domain, key, cb); } .. read_key(key, function(err, res) { ... }); VS. function read_key(key) { var future = Future(); database.getItem(domain, key, future.fulfill); return future; } ... var reader = read_key(key); ... reader.when(function(err, res) { .. } ); As others have noted, you can make a generalization into Sequences that eliminates nested-callback-hell. In Node especially there are a lot of asynchronous calls (and especially especiall
Read the rest
y if you are managing outside data) so they come in handy. I like this library: https://github.com/coolaj86/futures Instead of sequence-members having to return promises themselves, though, they can just call the next() function or not. As an example, you might define your program to do this: var obj; // shared data var seq = Futures.sequence(); seq.then(function(next) { ...dosetupstuff... next(obj); }) .then(fetchMetadataFromDB) .then(validateFile) .then(createFileInDB) .then(copyToOtherDB); And you might go on. Each function relies on the previous function having completed successfully and calling next(), otherwise the sequence is broken. You can more easily create standardized error handling mechanisms as well. Of course if all your functions are synchronous this doesn't really matter, but getting at an external DB might look something like this: function fetchMetadataFromDB(next, obj) { db.fetch(query, function(result) { // success obj.stuff = result.whatever; next(obj); }, function(err) { // error .. }); } A lot of libraries follow that pattern. Without a sequence, your code might start looking like this: ..setup stuff; function fetchMetadata(obj, cb) { .. } fetchMetadata(obj, function (metadata) { // validate file: validate(metadata, function(file) { // success // create file: db.create(file, function() { // success // copy to other db otherdb.copy(file, function() { // success ... }, function(err) { // copy failed ... }); }, function(err) { // create failed ... }, function(err) { // validate failed ... }); }); You could used named functions but that means a given named function must know the name of its successive named function, and that can make your program hard to follow and change. With the sequence approach, you have the whole sequential structure laid out at the top and can inspect functions themselves if you want to, and if a new async part enters the flow you can just insert it in the sequence. With a non-sequence named function approach, you have to jump around all the functions to get a sense of the sequence, and if a new async part enters the flow you have to change the function before to call the new function. You could define all your functions inline, which helps keep the order of execution straight and easy to follow, but adding a new async operation means adding a new level of indentation, so it's called nested-callback-hell.
In Missing the Point of Promises
Futures (aka Deferreds aka Promises) are indeed cool. For a more general toolbox, check out https://github.com/coolaj86/futures What the linked article doesn't show is how you would create your own future objects, which in my point of view is the more useful thing. (I can always specify the error function using the more general $.ajax() so knowing that $.get() finally allows specifying both success and error with futures isn't that useful...). Besides just plain futures, the join and chainify abstractions (and the sequence abstraction that you can of course get elsewhere) from the futures library I linked allow you to create really nice code. Sequences alone heavily reduced my initial frustrations when using Node.
In An introduction to jQuery Deferreds
Personally I've gotten more use out of the Futures library, though both are great. https://github.com/coolaj86/futures It contains a form of 'waterfall' known as merely a sequence. I use a lot of sequences and promises, it makes me not go insane from NodeJS programming. In the end I still think it was a mistake for Node to not support any sync features because there are times it's nice to have. TameJS doesn't solve the problem completely either (and I hate the compile step).
In Node.js - A giant step backwards?
There are many many attempts at solving this problem, both libraries and preprocessors. None seem to satisfy a large audience, most people seem to deal with the callback nesting and hope to avoid cases where it gets super ugly. I have a lot bookmarked on github, these are mostly libraries. https://github.com/coolaj86/futures https://github.com/substack/node-seq https://github.com/marcuswestin/fun https://github.com/creationix/step https://github.com/chriso/chain.js https://github.com/substack/node-chainsaw https://github.com/caolan/async https://github.com/kriszyp/promised-io https://github.com/kriszyp/node-promise https://github.com/technoweenie/node-chain-gang https://github.com/creationix/do https://github.com/willconant/flow-js https://github.com/creationix/conductor Some branches of CoffeeScript are also trying to ease the pain. Defe
Read the rest
r keyword didn't make it into CoffeeScript main. My impression is CoffeeScript makes callback hell less ugly anyway, so there is less need for adding a complex language feature that generates unreadable JavaScript.
In Three Routes to Spaghetti-Free Javascript

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.