Skip to content

Instantly share code, notes, and snippets.

View nashibao's full-sized avatar

Naoki Shibayama nashibao

View GitHub Profile
@nashibao
nashibao / co.js
Last active January 2, 2016 09:09
minimum coroutine module (without error handling, dictionary). like https://github.com/visionmedia/co.
var co = function(fn){
function is_gen(obj) {
return obj && obj.constructor && 'GeneratorFunctionPrototype' == obj.constructor.name;
}
return function(done){
var gen = fn;
if(typeof gen == 'function')
gen = gen();