fix: gnc eslint error.
This commit is contained in:
parent
196212fa39
commit
c82ad68d32
|
@ -8,12 +8,15 @@ export class GNC {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
of(fn) {
|
of(fn) {
|
||||||
return this.is.generatorFunc(fn)
|
/**
|
||||||
? /**
|
|
||||||
* @param {Parameters<typeof fn>} args
|
* @param {Parameters<typeof fn>} args
|
||||||
* @returns {Promise<ReturnType<typeof fn>>}
|
* @returns {Promise<ReturnType<typeof fn>>}
|
||||||
*/
|
*/
|
||||||
function genCoroutine(...args) {
|
function genCoroutine(...args) {
|
||||||
|
/**
|
||||||
|
* @type {Generator<unknown, any, unknown> & { status: "next" | "throw" , state?: any}}
|
||||||
|
*/
|
||||||
|
// @ts-expect-error Must Ok
|
||||||
let gen = fn.apply(this, args);
|
let gen = fn.apply(this, args);
|
||||||
gen.status = "next";
|
gen.status = "next";
|
||||||
gen.state = undefined;
|
gen.state = undefined;
|
||||||
|
@ -44,9 +47,10 @@ export class GNC {
|
||||||
};
|
};
|
||||||
return new Promise(callback);
|
return new Promise(callback);
|
||||||
}
|
}
|
||||||
: (() => {
|
|
||||||
throw new TypeError("gnc.of needs a GeneratorFunction.");
|
if (!this.is.generatorFunc(fn)) throw new TypeError("gnc.of needs a GeneratorFunction.");
|
||||||
})();
|
|
||||||
|
return genCoroutine;
|
||||||
}
|
}
|
||||||
is = new Is();
|
is = new Is();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue