determine the arg of `gnc.of` as a generator function.
`gnc.of` needs a generator function, so we check the input value to make the error clear.
This commit is contained in:
parent
5893baaf9a
commit
31c96dd4ea
|
@ -32,7 +32,7 @@
|
||||||
const GeneratorFunction=(function*(){}).constructor;
|
const GeneratorFunction=(function*(){}).constructor;
|
||||||
// gnc: GeNCoroutine
|
// gnc: GeNCoroutine
|
||||||
const gnc={
|
const gnc={
|
||||||
of:fn=>function genCoroutine(){
|
of:fn=>gnc.is.generatorFunc(fn)?function genCoroutine(){
|
||||||
let gen=fn.apply(this,arguments);
|
let gen=fn.apply(this,arguments);
|
||||||
gen.status="next";
|
gen.status="next";
|
||||||
gen.state=undefined;
|
gen.state=undefined;
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
result=result.value;
|
result=result.value;
|
||||||
Promise.resolve(result).then(nexts,throws);
|
Promise.resolve(result).then(nexts,throws);
|
||||||
});
|
});
|
||||||
},
|
}:(()=>{throw new TypeError("gnc.of needs a GeneratorFunction.")})(),
|
||||||
/*
|
/*
|
||||||
await:gen=>new Promise((resolve,reject)=>{
|
await:gen=>new Promise((resolve,reject)=>{
|
||||||
let result=gen;
|
let result=gen;
|
||||||
|
|
Loading…
Reference in New Issue