{"version":3,"sources":["../src/misc/timer.ts"],"names":["times","timer","reset","tips","options","unit","log","now","value","result"],"mappings":";;;;AAGA,IAAIA,CAAiB,CAAA,EAORC,CAAAA,CAAAA,CAAqB,CAK7B,KAAA,CAAOC,CAAiB,EAAA,CAClBA,CAAOF,GAAAA,CAAAA,CAAQ,EAAC,CAAA,CACnBA,EAAM,IAAK,CAAA,IAAA,CAAK,GAAI,EAAC,EACxB,CAAA,CAOA,GAAI,CAAA,CAACG,CAAaC,CAAAA,CAAAA,GAA4C,CAC3D,GAAM,CAAC,IAAA,CAAAC,CAAK,CAAA,IAAA,CAAK,IAAAC,CAAI,CAAA,IAAI,CAAIF,CAAAA,CAAAA,EAAW,EAAC,CACnCG,CAAM,CAAA,IAAA,CAAK,GAAI,EAAA,CACfC,CAAQD,CAAAA,CAAAA,EAAOP,CAAM,CAAA,GAAA,EAASO,EAAAA,CAAAA,CAAAA,CAC9BE,EAASJ,CAAM,EAAA,GAAA,CAAMG,CAAQ,CAAA,GAAA,CAAQA,CAC3C,CAAA,OAAGF,CAAK,EAAA,OAAA,CAAQ,IAAIH,CAAQ,EAAA,iBAAA,CAAmB,CAAGM,EAAAA,CAAM,CAAGJ,EAAAA,CAAI,CAAE,CAAA,CAAA,CAC1DG,CACV,CACJ","file":"chunk-3TIREVLP.mjs","sourcesContent":["\n\n\nlet times:number[] = [];\n\nexport interface TimerOptions{\n    begin(reset?:boolean):void\n    end(tips?:string,options?:{unit:string,log:boolean}):number \n}\n\nexport const timer:TimerOptions = {\n    /**\n     * begin与end应该配对\n     * @param {Boolean} reset  是否重置计时\n     */\n     begin:(reset?:boolean)=>{ \n        if(reset) times = []\n        times.push(Date.now())\n     },\n     /**\n      * \n      * @param {*} unit 时间单位s=秒,ms=毫秒\n      * @param {*} returnWithUnit  是否返回包括单位的字符串      \n      * @returns \n      */\n     end:(tips?:string,options?:{unit:string,log:boolean}):number=>{        \n        const {unit='ms',log=true} = options || {}\n        const now = Date.now()\n        const value = now - (times.pop() || now)\n        const result = unit==\"s\" ? value / 1000  : value\n        if(log) console.log(tips || 'time consuming:', `${result}${unit}`)\n        return value\n     } \n } \n"]}