@leafer/debug 1.0.0-rc.9 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/debug",
3
- "version": "1.0.0-rc.9",
3
+ "version": "1.0.1",
4
4
  "description": "@leafer/debug",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,9 +22,9 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/math": "1.0.0-rc.9"
25
+ "@leafer/math": "1.0.1"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.0.0-rc.9"
28
+ "@leafer/interface": "1.0.1"
29
29
  }
30
30
  }
package/src/Debug.ts CHANGED
@@ -8,6 +8,7 @@ export class Debug {
8
8
  static excludeList: string[] = []
9
9
 
10
10
  // other
11
+ static showWarn = true
11
12
  static showRepaint: boolean
12
13
  static showHitView: boolean | string | string[]
13
14
  static showBoundsView: boolean | string | string[]
@@ -25,15 +26,11 @@ export class Debug {
25
26
  }
26
27
 
27
28
  static set filter(name: string | string[]) {
28
- if (!name) name = []
29
- else if (typeof name === 'string') name = [name]
30
- this.filterList = name
29
+ this.filterList = getNameList(name)
31
30
  }
32
31
 
33
32
  static set exclude(name: string | string[]) {
34
- if (!name) name = []
35
- else if (typeof name === 'string') name = [name]
36
- this.excludeList = name
33
+ this.excludeList = getNameList(name)
37
34
  }
38
35
 
39
36
 
@@ -46,11 +43,11 @@ export class Debug {
46
43
  }
47
44
 
48
45
  tip(...messages: unknown[]): void {
49
- if (D.enable) console.warn(this.name, ...messages)
46
+ if (D.enable) this.warn(...messages)
50
47
  }
51
48
 
52
49
  warn(...messages: unknown[]): void {
53
- console.warn(this.name, ...messages)
50
+ if (D.showWarn) console.warn(this.name, ...messages)
54
51
  }
55
52
 
56
53
  repeat(name: string, ...messages: unknown[]) {
@@ -69,4 +66,10 @@ export class Debug {
69
66
  }
70
67
  }
71
68
 
69
+ function getNameList(name: string | string[]): string[] {
70
+ if (!name) name = []
71
+ else if (typeof name === 'string') name = [name]
72
+ return name
73
+ }
74
+
72
75
  const D = Debug
package/types/index.d.ts CHANGED
@@ -21,6 +21,7 @@ declare class Debug {
21
21
  static enable: boolean;
22
22
  static filterList: string[];
23
23
  static excludeList: string[];
24
+ static showWarn: boolean;
24
25
  static showRepaint: boolean;
25
26
  static showHitView: boolean | string | string[];
26
27
  static showBoundsView: boolean | string | string[];