Last active
April 15, 2016 06:50
-
-
Save magicdawn/af4a006c3371d5ca25c61cd4b1c214de to your computer and use it in GitHub Desktop.
kuaidi.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* http://v2ex.com/t/271065 | |
* http://www.kuaidadi.com/assets/js/animate.js | |
* | |
* ES6 环境可用 | |
* babelify: regenerator 到ES5可用。 | |
*/ | |
const pify = require('promise.ify').noerr; | |
const cowrap = require('co').wrap; | |
KXX.prototype.play = co.wrap(function*(){ | |
for(let i = 0; i < 17; i++){ | |
if(!this[`step${ i }Async`]) this[`step${ i }Async`] = pify(this[`step${ i }`]); | |
yield this[`step${ i }Async`](); | |
} | |
// blabla | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
promise.ify 支持的是 node style callback. 带err. 看来得调整下