serby/flow-control-examples — pull request #2 by ForbesLindesay (2013-02-21 18:36:54+00:00)
Title: Add promise implementation

I've included a commented out ES6 implementation. It would throw a syntax error in ES5.

Incidentally, the following would work in Firefox if you specify the JavaScript version appropriately (I think it's 1.8 or something):

```javascript
var findMe = Q.async(function (user) {
Q.return((yield userModel.findByEmail(user.email)) ||
(yield userModel.findByName(user.name)) ||
(yield userModel.findByGithub(user.github)) || null);
});

module.exports.findMe = function(user, callback){
findMe(user).nodeify(callback);
};
```

But that isn't compatible with the current ES6 spec since ES6 requries a `*` after the word function if it contains the `yield` keyword and ES6 supports straightforward `return` statements whereas Firefox requires you to throw an exception (Which is what `Q.return` does)