@puq/debug 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -6,7 +6,9 @@
6
6
 
7
7
  ## Summary
8
8
 
9
- debug
9
+ The library privides 3 functions, `start`, `end`, and `debug`. These function only work when the `process.env.DEBUG_MODE` is `true`.
10
+
11
+ `start` function is for indicating context of the debug such as `operationName` and the `end` function is for indicating the closing of the context.
10
12
 
11
13
  ## Install
12
14
 
@@ -14,6 +16,8 @@ debug
14
16
  pnpm add @puq/debug
15
17
  ```
16
18
 
19
+ ### Useage
20
+
17
21
  ## Funding
18
22
 
19
23
  Thank you for using `@puq/debug` It's an open-source project, and maintaining it takes time and effort. If you find this library useful, please consider supporting its ongoing development. Your contributions help ensure that the project stays up-to-date, secure, and well-maintained.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from './lib/debug.js';
2
+ export * from './lib/end.js';
2
3
  export * from './lib/is-debug-mode.js';
4
+ export * from './lib/start.js';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // @index(['./**/*.ts', '!./**/*.{spec,test}.ts'], f => `export * from '${f.path}.js'`)
2
2
  export * from './lib/debug.js';
3
+ export * from './lib/end.js';
3
4
  export * from './lib/is-debug-mode.js';
5
+ export * from './lib/start.js';
4
6
 
5
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @index(['./**/*.ts', '!./**/*.{spec,test}.ts'], f => `export * from '${f.path}.js'`)\nexport * from './lib/debug.js';\nexport * from './lib/is-debug-mode.js';\n"],"names":[],"rangeMappings":";;","mappings":"AAAA,uFAAuF;AACvF,cAAc,iBAAiB;AAC/B,cAAc,yBAAyB"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @index(['./**/*.ts', '!./**/*.{spec,test}.ts'], f => `export * from '${f.path}.js'`)\nexport * from './lib/debug.js';\nexport * from './lib/end.js';\nexport * from './lib/is-debug-mode.js';\nexport * from './lib/start.js';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,uFAAuF;AACvF,cAAc,iBAAiB;AAC/B,cAAc,eAAe;AAC7B,cAAc,yBAAyB;AACvC,cAAc,iBAAiB"}
@@ -1,2 +1,6 @@
1
- export declare function debug<T>(record: T): void;
1
+ /**
2
+ * Print a debug message if DEBUG_MODE is active
3
+ * @returns
4
+ */
5
+ export declare function debug(...message: any[]): void;
2
6
  //# sourceMappingURL=debug.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/lib/debug.ts"],"names":[],"mappings":"AAEA,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC"}
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/lib/debug.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,GAAG,IAAI,CAW7C"}
package/dist/lib/debug.js CHANGED
@@ -1,15 +1,14 @@
1
1
  import { isDebugMode } from './is-debug-mode.js';
2
2
  /**
3
- * Debug console
3
+ * Print a debug message if DEBUG_MODE is active
4
4
  * @returns
5
5
  */ export function debug(...message) {
6
6
  if (!isDebugMode()) return;
7
7
  if (message.every((e)=>{
8
8
  return typeof e != 'object';
9
9
  })) {
10
- console.debug('[ Debug ]', ...message);
10
+ console.log(...message);
11
11
  } else {
12
- console.debug('[ Debug ]');
13
12
  console.table(message);
14
13
  }
15
14
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/debug.ts"],"sourcesContent":["import { isDebugMode } from './is-debug-mode.js';\n\nexport function debug<T>(record: T): void;\n/**\n * Debug console\n * @returns\n */\nexport function debug(...message: any[]): void {\n if (!isDebugMode()) return;\n\n if (\n message.every((e) => {\n return typeof e != 'object';\n })\n ) {\n console.debug('[ Debug ]', ...message);\n } else {\n console.debug('[ Debug ]');\n\n console.table(message);\n }\n}\n"],"names":["isDebugMode","debug","message","every","e","console","table"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAAA,SAASA,WAAW,QAAQ,qBAAqB;AAGjD;;;CAGC,GACD,OAAO,SAASC,MAAM,GAAGC,OAAc;IACrC,IAAI,CAACF,eAAe;IAEpB,IACEE,QAAQC,KAAK,CAAC,CAACC;QACb,OAAO,OAAOA,KAAK;IACrB,IACA;QACAC,QAAQJ,KAAK,CAAC,gBAAgBC;IAChC,OAAO;QACLG,QAAQJ,KAAK,CAAC;QAEdI,QAAQC,KAAK,CAACJ;IAChB;AACF"}
1
+ {"version":3,"sources":["../../src/lib/debug.ts"],"sourcesContent":["import { isDebugMode } from './is-debug-mode.js';\n\n/**\n * Print a debug message if DEBUG_MODE is active\n * @returns\n */\nexport function debug(...message: any[]): void {\n if (!isDebugMode()) return;\n if (\n message.every((e) => {\n return typeof e != 'object';\n })\n ) {\n console.log(...message);\n } else {\n console.table(message);\n }\n}\n"],"names":["isDebugMode","debug","message","every","e","console","log","table"],"rangeMappings":";;;;;;;;;;;;;","mappings":"AAAA,SAASA,WAAW,QAAQ,qBAAqB;AAEjD;;;CAGC,GACD,OAAO,SAASC,MAAM,GAAGC,OAAc;IACrC,IAAI,CAACF,eAAe;IACpB,IACEE,QAAQC,KAAK,CAAC,CAACC;QACb,OAAO,OAAOA,KAAK;IACrB,IACA;QACAC,QAAQC,GAAG,IAAIJ;IACjB,OAAO;QACLG,QAAQE,KAAK,CAACL;IAChB;AACF"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Print a closing indicator for the debugger if DEBUG_MODE is active
3
+ * @returns
4
+ */
5
+ export declare function end(): void;
6
+ //# sourceMappingURL=end.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"end.d.ts","sourceRoot":"","sources":["../../src/lib/end.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,GAAG,SAKlB"}
@@ -0,0 +1,12 @@
1
+ import { isDebugMode } from './is-debug-mode.js';
2
+ /**
3
+ * Print a closing indicator for the debugger if DEBUG_MODE is active
4
+ * @returns
5
+ */ export function end() {
6
+ if (!isDebugMode()) return;
7
+ console.log(`----------------------------End`);
8
+ console.log(' ');
9
+ console.log(' ');
10
+ }
11
+
12
+ //# sourceMappingURL=end.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/end.ts"],"sourcesContent":["import { isDebugMode } from './is-debug-mode.js';\r\n\r\n/**\r\n * Print a closing indicator for the debugger if DEBUG_MODE is active\r\n * @returns\r\n */\r\nexport function end() {\r\n if (!isDebugMode()) return;\r\n console.log(`----------------------------End`);\r\n console.log(' ');\r\n console.log(' ');\r\n}\r\n"],"names":["isDebugMode","end","console","log"],"rangeMappings":";;;;;;;;;","mappings":"AAAA,SAASA,WAAW,QAAQ,qBAAqB;AAEjD;;;CAGC,GACD,OAAO,SAASC;IACd,IAAI,CAACD,eAAe;IACpBE,QAAQC,GAAG,CAAC,CAAC,+BAA+B,CAAC;IAC7CD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;AACd"}
@@ -1,2 +1,6 @@
1
+ export declare const DEBUG_MODE = "DEBUG_MODE";
1
2
  export declare function isDebugMode(): boolean;
3
+ export declare function debugMode(): {
4
+ DEBUG_MODE: boolean;
5
+ };
2
6
  //# sourceMappingURL=is-debug-mode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-debug-mode.d.ts","sourceRoot":"","sources":["../../src/lib/is-debug-mode.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,IAAI,OAAO,CAErC"}
1
+ {"version":3,"file":"is-debug-mode.d.ts","sourceRoot":"","sources":["../../src/lib/is-debug-mode.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,eAAe,CAAC;AAEvC,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED,wBAAgB,SAAS;;EAIxB"}
@@ -1,9 +1,15 @@
1
+ export const DEBUG_MODE = 'DEBUG_MODE';
1
2
  export function isDebugMode() {
2
3
  return [
3
4
  true,
4
5
  'true',
5
6
  1
6
- ].some((e)=>process.env.DEBUG_MODE === e);
7
+ ].some((e)=>process.env[DEBUG_MODE] === e);
8
+ }
9
+ export function debugMode() {
10
+ return {
11
+ [DEBUG_MODE]: true
12
+ };
7
13
  }
8
14
 
9
15
  //# sourceMappingURL=is-debug-mode.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/is-debug-mode.ts"],"sourcesContent":["export function isDebugMode(): boolean {\r\n return [true, 'true', 1].some((e) => process.env.DEBUG_MODE === e);\r\n}\r\n"],"names":["isDebugMode","some","e","process","env","DEBUG_MODE"],"rangeMappings":";;;;;;","mappings":"AAAA,OAAO,SAASA;IACd,OAAO;QAAC;QAAM;QAAQ;KAAE,CAACC,IAAI,CAAC,CAACC,IAAMC,QAAQC,GAAG,CAACC,UAAU,KAAKH;AAClE"}
1
+ {"version":3,"sources":["../../src/lib/is-debug-mode.ts"],"sourcesContent":["export const DEBUG_MODE = 'DEBUG_MODE';\r\n\r\nexport function isDebugMode(): boolean {\r\n return [true, 'true', 1].some((e) => process.env[DEBUG_MODE] === e);\r\n}\r\n\r\nexport function debugMode() {\r\n return {\r\n [DEBUG_MODE]: true,\r\n };\r\n}\r\n"],"names":["DEBUG_MODE","isDebugMode","some","e","process","env","debugMode"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAAA,OAAO,MAAMA,aAAa,aAAa;AAEvC,OAAO,SAASC;IACd,OAAO;QAAC;QAAM;QAAQ;KAAE,CAACC,IAAI,CAAC,CAACC,IAAMC,QAAQC,GAAG,CAACL,WAAW,KAAKG;AACnE;AAEA,OAAO,SAASG;IACd,OAAO;QACL,CAACN,WAAW,EAAE;IAChB;AACF"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * Print a opening indicator for the debugger if DEBUG_MODE is active
4
+ * @param context Debug context
5
+ */
6
+ export declare function start(context?: string): void;
7
+ //# sourceMappingURL=start.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/lib/start.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,OAAO,SAAU,QAGtC"}
@@ -0,0 +1,11 @@
1
+ import { isDebugMode } from './is-debug-mode.js';
2
+ /**
3
+ *
4
+ * Print a opening indicator for the debugger if DEBUG_MODE is active
5
+ * @param context Debug context
6
+ */ export function start(context = 'Debug') {
7
+ if (!isDebugMode()) return;
8
+ console.log(`[ ${context} ] ----------------------------Start`);
9
+ }
10
+
11
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/start.ts"],"sourcesContent":["import { isDebugMode } from './is-debug-mode.js';\r\n\r\n/**\r\n *\r\n * Print a opening indicator for the debugger if DEBUG_MODE is active\r\n * @param context Debug context\r\n */\r\nexport function start(context = 'Debug') {\r\n if (!isDebugMode()) return;\r\n console.log(`[ ${context} ] ----------------------------Start`);\r\n}\r\n"],"names":["isDebugMode","start","context","console","log"],"rangeMappings":";;;;;;;;","mappings":"AAAA,SAASA,WAAW,QAAQ,qBAAqB;AAEjD;;;;CAIC,GACD,OAAO,SAASC,MAAMC,UAAU,OAAO;IACrC,IAAI,CAACF,eAAe;IACpBG,QAAQC,GAAG,CAAC,CAAC,EAAE,EAAEF,QAAQ,oCAAoC,CAAC;AAChE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@puq/debug",
3
3
  "license": "MIT",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "tag": "latest"
@@ -80,4 +80,4 @@
80
80
  "devDependencies": {
81
81
  "@swc/helpers": "~0.5.11"
82
82
  }
83
- }
83
+ }