"We must not promise what we ought not, lest we be called on to perform what we cannot."
-Abraham Lincoln

This library springs directly out of a problem Promises/Deferreds created a problem at work, we wanted to chain promises without termination should an error occur, essentially the libraries concept of failure was different than our own. This made me realize how limited promises were (as an error is inextricably tied to failure, and the only solution is nesting another deferred, which is way more indirect than 'callback hell')

But as we were talking I realized if you had a generalized textual state machine you can attach events to certain configurations, in some cases to change state, in others to provide a terminal condition, all without spewing new promises all over memory, and what's better you could rewind states (like if you wanted to retry a specific action, or perhaps there was an incremental error and you want to back up many states), or in our case modify the success condition to ignore failures, or a percentage of fails, or fails a certain tasks... really anything. Suddenly the promises interface and underlying state mechanics(though not the spec) seemed extremely powerful.

But none of the existing promise implementations are built this way. But before you use this, I'd like to make it clear: I don't think you should be using promises... but if you do, I think more expressiveness(with less complexity) can be had from a state machine based approach than an closure encapsulation approach. So in the end, use this library as a last resort when callbacks get you down.

"The man who promises everything is sure to fulfill nothing,
and everyone who promises too much is in danger of using evil means in order to carry out his promises,
and is already on the road to perdition."
-Carl Jung

So the simple case of this statemachine is a rough (eventually exact, via a 'strict' mode) implementation of promises/A and integrating (rather than externalizing) deferreds.

"The promise given was a necessity of the past: the word broken is a necessity of the present."
-Niccolo Machiavelli

Lies are very simply textual state machines which allow you to attach transitions and logic to particular states. The Covenant is simply a particular usage of a lie. You could, for instance, modify the basic covenant implementation to always resolve even if individual covenants fail:

"The woods are lovely, dark and deep. But I have promises to keep, and miles to go before I sleep.
-Robert Frost

After much discussion, thought and code perusal, I think promises/deferreds are over hyped bullshit that solve next to nothing other than mindless transformations for pseudo imperative metalanguages.

They are:

State machines that are only capable of moving in 1 direction

functional compositions which have indeterminate returns

claim to solve callback nesting hell, but actually exchange a callback which executes as a byproduct of the task to one which must be called by you when the unrewindable state machine terminates.

internally you have a ton of nested callbacks, so from a performance standpoint there is no gain

have no concept of partial error, then succeed

Conventional wisdom from other languages is that exception handling is needlessly indirect and leads to non-obvious code paths, which hurts maintainability. Node's error passing paradigm was ever an issue for me (intuitive, even)... frankly I feel errors should be trapped within a level or two and always from within the module they originate in. From that perspective I gain nothing. I still have to manually transfer an error event across any scope/event return boundary, so really all I got is that chained callbacks can all throw to the same block. That's literally the only feature I got from all that indirection.

The insidious thing is that it requires every async activity to be implemented as a promise in order for this to be useful. Let's recode everything!! Yay!! It will infect every return of every call... which is great for guys who like metalanguages built on top of JS, but pretty terrible for those of us who like JS for what it is.

When people describe how great promises are, I seriously question their sanity and/or their code.

So, I don't really like this example, because it's something pointless that I would never implement this way in the real world, but I want to compare apples to apples, so there you go (listed as an elegant example of the power of promises). In this example all we've gained is indirection through a library and the ability to simply translate seemingly imperative statements in metalanguages. Let's try something a little more 'real world':

So what was it you were saying about the woes of 'callback hell'... the need for pointless indirection through another library? I think the man in black said it so much more eloquently than I ever could:

Not to burst everyone's bubble, but if you just use objects, who's members handle a limited depth of asynchronous callbacks, not only will your functions be short and action specific, but you can stop the indirect imperative mishmash of functions that most JS is, and promises only encourages.

Currently the tests only run a primitive set of tests for conformance to the promises/A spec, there will eventually be a 'strict' (wasteful) mode which should pass the full suite of Promises/A tests. Eventually I'll implement a 3rd interface for Promises/B but it remains to be seen if Promises/A+ is worth implementing. Part of the premise of this library is that in celebrating what promises are, people have totally passed over the power of implementing them as extension of a generalized state machine.

I'm probably being needlessly aggressive in my tone here, but it's deliberate to match those voices hailing promises as some radical new programming paradigm, rather than a clever layover from project Xanadu, much like the equally clever [Enfilade](http://en.wikipedia.org/wiki/Enfilade_(Xanadu)). This is nothing new, but in it's current incarnation threatens to completely infect js libs and I feel like voices are needed to stem this tide of needless indirection. If you disagree, I'd love to hear about your reasoning even if you just think I'm being a prick.

"Should my voice fade in your ears, and my love vanish in your memory, then I will come again,
And with a richer heart and lips more yielding to the spirit will I speak.
Yea, I shall return with the tide…
If aught I have said is truth, that truth shall reveal itself in a clearer voice, and in words more kin to your thoughts…
And if this day is not a fulfillment of your needs and my love, then let it be a promise till another day…
Know, therefore, that from the greater silence I shall return…
A little while, a moment of rest upon the wind, and another woman shall bear me."
-Kahlil Gibran : The Promise