From f99ec24852cb9b47f90d93cc5b5eada351aac16c Mon Sep 17 00:00:00 2001 From: Rintim Date: Wed, 6 Sep 2023 00:53:11 +0800 Subject: [PATCH] modify names. --- game/game.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/game/game.js b/game/game.js index 59ad07a93..9a6df79fa 100644 --- a/game/game.js +++ b/game/game.js @@ -32,17 +32,18 @@ const GeneratorFunction=(function*(){}).constructor; // gnc: GeNCoroutine const gnc={ - async:(fn)=>function genCoroutine(){ + async:fn=>function genCoroutine(){ return gnc.await(fn.apply(this,arguments)) }, - await:(gen)=>new Promise((resolve,reject)=>{ + await:gen=>new Promise((resolve,reject)=>{ const _next=value=>gnc.next(gen,resolve,reject,"next",value,_next,_throw); const _throw=err=>gnc.next(gen,resolve,reject,"throw",err,_next,_throw); _next(undefined); }), is:{ - coroutine:(item)=>typeof item=="function"&&item.name=="genCoroutine", - generator:(item)=>item instanceof GeneratorFunction + coroutine:item=>typeof item=="function"&&item.name=="genCoroutine", + generator:item=>item instanceof GeneratorFunction, + a:item=>item.constructor==GeneratorFunction }, next:(gen,resolve,reject,key,arg,_next,_throw)=>{ let info,value; @@ -7157,8 +7158,9 @@ }, genAsync:fn=>gnc.async(fn), genAwait:gen=>gnc.await(gen), - isGenCoroutine:(item)=>typeof item=="function"&&item.name=="genCoroutine", - isGenerator:(item)=>item instanceof GeneratorFunction, + isGenCoroutine:item=>gnc.is.coroutine(item), + isGeneratorFunc:item=>gnc.is.generator(item), + isGenerator:item=>gnc.is.a(item), init:{ init:function(){ if(typeof __dirname==='string'&&__dirname.length){