Skip to content

Instantly share code, notes, and snippets.

@magicdawn
Last active April 15, 2016 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magicdawn/af4a006c3371d5ca25c61cd4b1c214de to your computer and use it in GitHub Desktop.
Save magicdawn/af4a006c3371d5ca25c61cd4b1c214de to your computer and use it in GitHub Desktop.
kuaidi.js
/**
* 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
});
@magicdawn
Copy link
Author

promise.ify 支持的是 node style callback. 带err. 看来得调整下

@magicdawn
Copy link
Author

promise.ify@0.3.0 已发布

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment