Created
February 3, 2015 18:06
-
-
Save mwq27/8346934be9a6451ae01d to your computer and use it in GitHub Desktop.
Example of ES6 generator and a call to the nodejs Stripe API
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
var jobs = { | |
generatorCC(chargeId, amount) { | |
stripe.charges.capture(chargeId, {amount}, function(err, charge) { | |
if (err) { | |
it.throw(err); | |
} | |
it.next(charge); | |
}.bind(this)); | |
}, | |
testGen: function*() { | |
try { | |
var data = yield this.generatorCC('ch_msmms0', 1000); | |
console.log('Ummmmmm, the Data' , data); | |
} catch (e) { | |
console.log('error equals', e.message); | |
} | |
} | |
}; | |
var it = jobs.testGen(); | |
it.next(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment