I’ve been working with ES6 promises latelty, and i’m really liking them.

But everytime i use .then, in my head i’m really saying, “aannnnndtheeeen”

If this confuses you, check here

So i decided to make a little library that lets me do what i’m actually saying.


From the person who brought you “WoW Meet AeroGear” and “Aliens and iPhones, HUH?”

Say Hello to AndThen

It is basically a wrapper on top of ES6 promises. But now, instead of using .then and .catch

we can use .annddtheenn and .noandthen

Below are some examples


Lets modify the “Chaining” and “Error Handling” example from the HTML5 rocks Promises article located here

var promise = new AndThen(function(resolve, reject) {

promise.annddtheenn(function(val) {
  console.log(val); // 1
  return val + 2;
}).annddtheenn(function(val) {
  console.log(val); // 3

Error example:

var jsonPromise = new AndThen(function(resolve, reject) {
  // JSON.parse throws an error if you feed it some
  // invalid JSON, so this implicitly rejects:
  resolve(JSON.parse("This ain't JSON"));

jsonPromise.annddtheenn(function(data) {
  // This never happens:
  console.log("It worked!", data);
}).noandthen(function(err) {
  // Instead, this happens:
  console.log("It failed!", err);

It’s still a WIP and i want to implement the Promise.all method, which will be called AndThen.andthenandthenandthen

Fork the code here - fork me