@leafer/debug
Advanced tools
+68
| import { IBooleanMap } from '@leafer/interface' | ||
| export class Debug { | ||
| static enable: boolean | ||
| static filterList: string[] = [] | ||
| static excludeList: string[] = [] | ||
| // other | ||
| static showRepaint: boolean | ||
| static showHitView: boolean | string | string[] | ||
| static showBoundsView: boolean | string | string[] | ||
| public name: string | ||
| public repeatMap: IBooleanMap = {} | ||
| constructor(name: string) { | ||
| this.name = name | ||
| } | ||
| static get(name: string): Debug { | ||
| return new Debug(name) | ||
| } | ||
| static set filter(name: string | string[]) { | ||
| if (!name) name = [] | ||
| else if (typeof name === 'string') name = [name] | ||
| this.filterList = name | ||
| } | ||
| static set exclude(name: string | string[]) { | ||
| if (!name) name = [] | ||
| else if (typeof name === 'string') name = [name] | ||
| this.excludeList = name | ||
| } | ||
| log(...messages: unknown[]): void { | ||
| if (D.enable) { | ||
| if (D.filterList.length && D.filterList.every(name => name !== this.name)) return | ||
| if (D.excludeList.length && D.excludeList.some(name => name === this.name)) return | ||
| console.log('%c' + this.name, 'color:#21ae62', ...messages) | ||
| } | ||
| } | ||
| warn(...messages: unknown[]): void { | ||
| if (D.enable) console.warn(this.name, ...messages) | ||
| } | ||
| repeat(name: string, ...messages: unknown[]) { | ||
| if (!this.repeatMap[name]) { | ||
| this.warn('repeat:' + name, ...messages) | ||
| this.repeatMap[name] = true | ||
| } | ||
| } | ||
| error(...messages: unknown[]): void { | ||
| try { | ||
| throw new Error() | ||
| } catch (e) { | ||
| console.error(this.name, ...messages, e) | ||
| } | ||
| } | ||
| } | ||
| const D = Debug |
+51
| import { IncrementId } from '@leafer/math' | ||
| import { Debug } from './Debug' | ||
| interface ids { | ||
| [name: string]: number | ||
| } | ||
| interface names { | ||
| [name: string]: string | ||
| } | ||
| const debug = Debug.get('RunTime') | ||
| export class Run { | ||
| static currentId: number | ||
| static currentTime: number | ||
| static currentName: string | ||
| static idMap: ids = {} | ||
| static nameMap: names = {} | ||
| static nameToIdMap: ids = {} | ||
| static start(name: string, microsecond?: boolean): number { | ||
| const id = IncrementId.create(IncrementId.RUNTIME) | ||
| R.currentId = R.idMap[id] = microsecond ? performance.now() : Date.now() | ||
| R.currentName = R.nameMap[id] = name | ||
| R.nameToIdMap[name] = id | ||
| return id | ||
| } | ||
| static end(id: number, microsecond?: boolean): void { | ||
| const time = R.idMap[id] | ||
| const name = R.nameMap[id] | ||
| R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined | ||
| if (microsecond) { | ||
| debug.log(name, performance.now() - time, 'µs') | ||
| } else { | ||
| debug.log(name, Date.now() - time, 'ms') | ||
| } | ||
| } | ||
| static endOfName(name: string, microsecond?: boolean): void { | ||
| const id = R.nameToIdMap[name] | ||
| if (id !== undefined) R.end(id, microsecond) | ||
| } | ||
| } | ||
| const R = Run |
+4
-3
| { | ||
| "name": "@leafer/debug", | ||
| "version": "1.0.0-beta.15", | ||
| "version": "1.0.0-beta.16", | ||
| "description": "@leafer/debug", | ||
@@ -10,2 +10,3 @@ "author": "Chao (Leafer) Wan", | ||
| "files": [ | ||
| "src", | ||
| "types", | ||
@@ -25,7 +26,7 @@ "dist" | ||
| "dependencies": { | ||
| "@leafer/math": "1.0.0-beta.15" | ||
| "@leafer/math": "1.0.0-beta.16" | ||
| }, | ||
| "devDependencies": { | ||
| "@leafer/interface": "1.0.0-beta.15" | ||
| "@leafer/interface": "1.0.0-beta.16" | ||
| } | ||
| } |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
6007
100.1%7
40%127
234.21%1
Infinity%+ Added
- Removed
Updated