fix: gnc eslint error.

This commit is contained in:
Rintim 2024-04-17 13:15:11 +08:00
parent 196212fa39
commit c82ad68d32
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
1 changed files with 42 additions and 38 deletions

View File

@ -8,12 +8,15 @@ export class GNC {
* @returns
*/
of(fn) {
return this.is.generatorFunc(fn)
? /**
/**
* @param {Parameters<typeof fn>} args
* @returns {Promise<ReturnType<typeof fn>>}
*/
function genCoroutine(...args) {
/**
* @type {Generator<unknown, any, unknown> & { status: "next" | "throw" , state?: any}}
*/
// @ts-expect-error Must Ok
let gen = fn.apply(this, args);
gen.status = "next";
gen.state = undefined;
@ -44,9 +47,10 @@ export class GNC {
};
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();
}