debug-fabulous 2.0.2 → 2.0.3

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.
@@ -6,7 +6,7 @@ export interface DebugFabulous extends DebugLazy {
6
6
  (namespace: string): DebuggerExt;
7
7
  spawnable: (_namespace: string, _debugFabFactory?: Debug) => DebuggerExtSpawn;
8
8
  }
9
- export declare type LazyDebugFunc = () => string | any[];
9
+ export type LazyDebugFunc = () => string | any[];
10
10
  export interface DebuggerExt extends Debugger {
11
11
  (lazyFunc: LazyDebugFunc): void;
12
12
  (...args: any[]): void;
package/lib/index.js CHANGED
@@ -1,21 +1,51 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1
+ 'use strict';
2
+
3
+ var memoize = require('memoizee');
4
+
5
+ const extend = (_debugger) => {
6
+ const wrapped = (formatter, ...args) => {
7
+ if (typeof formatter === 'function') {
8
+ const ret = formatter();
9
+ const toApply = Array.isArray(ret) ? ret : [ret];
10
+ return _debugger(...toApply);
11
+ }
12
+ return _debugger(formatter, ...args);
13
+ };
14
+ return Object.assign(wrapped, _debugger);
11
15
  };
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ const lazyEval = (debugInst) => {
17
+ function debug(namespace) {
18
+ function noop() { }
19
+ const instance = debugInst(namespace);
20
+ if (!instance.enabled) {
21
+ return Object.assign(noop, instance);
22
+ }
23
+ return extend(instance);
24
+ }
25
+ const debugMemoized = memoize(debug);
26
+ return Object.assign(debugMemoized, debugInst);
14
27
  };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- var debugFabFactory_1 = __importDefault(require("./debugFabFactory"));
17
- var spawn_1 = __importDefault(require("./extensions/spawn"));
18
- __exportStar(require("./internals"), exports);
19
- var fabulous = Object.assign(debugFabFactory_1.default, { spawnable: spawn_1.default });
28
+
29
+ function debugFactory(debugApi = require('debug')) {
30
+ debugApi = lazyEval(debugApi);
31
+ return debugApi;
32
+ }
33
+ module.exports = debugFactory;
34
+
35
+ function spawnFactory(namespace = '', debugFabFactory = require('../debugFabFactory')()) {
36
+ function createDebugger(base = '', ns = '') {
37
+ const newNs = ns ? [base, ns].join(':') : base;
38
+ const debug = debugFabFactory(newNs);
39
+ debug.spawn = spawn;
40
+ return debug;
41
+ }
42
+ function spawn(ns) {
43
+ return createDebugger(this.namespace, ns);
44
+ }
45
+ return createDebugger(namespace);
46
+ }
47
+
48
+ const fabulous = Object.assign(debugFactory, { spawnable: spawnFactory });
49
+ module.exports = fabulous;
50
+
20
51
  module.exports = fabulous;
21
- exports.default = fabulous;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "debug-fabulous",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "visionmedia debug extensions rolled into one",
5
5
  "keywords": [
6
6
  "debug",
@@ -22,19 +22,15 @@
22
22
  "umd"
23
23
  ],
24
24
  "scripts": {
25
- "build": "npm run gulp default && npm run roll:it",
25
+ "build": "rollup -c ./rollup.config.js",
26
26
  "coveralls": "cat ./coverage/lcov.info | coveralls",
27
- "docs:api:markdown": "npm run typedoc --theme markdown --exclude ./src/test --out ./docs/api ./src",
28
- "docs:api:website": "npm run typedoc --exclude ./src/test --out docs ./src",
29
- "gulp": "node -r esm ./node_modules/.bin/gulp",
30
- "jest": "node -r esm ./node_modules/.bin/jest",
31
- "lint": "eslint --ext .js,.ts,.tsx *.js src test --color",
27
+ "docs:api:markdown": "npx typedoc --theme markdown --exclude ./src/test --out ./docs/api ./src",
28
+ "docs:api:website": "npx typedoc --exclude ./src/test --out docs ./src",
29
+ "jest": "npx jest",
30
+ "lint": "npm run build && eslint --ext .js,.ts,.tsx *.js src test --color",
32
31
  "mocha": "mocha",
33
- "postinstall:1": "js-common-editorconfig-clone && js-common-babel-config-clone",
34
- "postinstall:2": "js-common-prettierrc-clone",
35
- "prepare": "npm run postinstall:1 && npm run postinstall:2 && sort-package-json",
36
- "roll:it": "rollup -c ./rollup.config.ts",
37
- "test": "npm run lint && npm run jest",
32
+ "prepare": "npx sort-package-json",
33
+ "test": "npm run build && npm run jest",
38
34
  "test:ci": "npm run build && npm run test --coverage && npm run coveralls",
39
35
  "preversion": "npm run build"
40
36
  },
@@ -43,36 +39,29 @@
43
39
  "memoizee": "0.4"
44
40
  },
45
41
  "devDependencies": {
46
- "@raghb1/node-memwatch": "^3.0.1",
42
+ "@biiaidt/node-memwatch": "2.0.1",
43
+ "@commitlint/cli": "^19",
44
+ "@commitlint/config-conventional": "^19",
45
+ "@rollup/plugin-commonjs": "^26.0.1",
46
+ "@rollup/plugin-typescript": "^11.1.6",
47
47
  "@types/debug": "^4",
48
- "@znemz/js-common-babel-config": "^0.0.23",
49
- "@znemz/js-common-babel-config-clone": "^0.0.23",
50
- "@znemz/js-common-editorconfig-clone": "^0.0.23",
51
- "@znemz/js-common-eslint-config": "^0.2.1",
52
- "@znemz/js-common-gulp-monorepo-typescript": "^0.0.23",
53
- "@znemz/js-common-prettierrc-clone": "^0.0.23",
54
- "@znemz/react-extras-jest": "^1.1.0",
48
+ "@types/jest": "^29.5.13",
49
+ "@znemz/js-common-eslint-config": "^0.2.2",
50
+ "@znemz/react-extras-jest": "1.5.1",
55
51
  "JSONStream": "1.X",
56
- "bluebird": "^3.5.5",
52
+ "commitlint": "19",
57
53
  "config": "^3.2.2",
58
54
  "coveralls": "^3.0.4",
59
55
  "del": "^4.1.1",
60
- "esm": "^3.2.22",
61
- "gulp-run": "^1.7.1",
62
- "gulp-typescript": "^5.0.1",
63
56
  "hook-std": "0.X",
57
+ "jest": "^29.7.0",
64
58
  "prettier": "^1.18.2",
65
- "react": "^16.8",
66
- "rollup": "^1.20.1",
67
- "rollup-plugin-commonjs": "^10.1.0",
68
- "rollup-plugin-typescript": "^1.0.1",
69
- "sort-package-json": "^1.21.0",
70
- "typedoc": "~0.15.0",
71
- "typedoc-plugin-markdown": "~2.1.4",
72
- "typescript": "~4.4"
59
+ "rollup": "4.21.3",
60
+ "sort-package-json": "^2.10.1",
61
+ "typescript": "^4.2.4"
73
62
  },
74
63
  "engines": {
75
- "node": ">= 8"
64
+ "node": ">= 14"
76
65
  },
77
66
  "umd": "umd/index.js"
78
67
  }
@@ -0,0 +1,4 @@
1
+ import { Debug } from 'debug';
2
+ import { DebugLazy } from './internals';
3
+ declare function debugFactory(debugApi?: Debug): DebugLazy;
4
+ export default debugFactory;
@@ -0,0 +1,3 @@
1
+ import { Debug } from 'debug';
2
+ declare const lazyEval: (debugInst: Debug) => any;
3
+ export default lazyEval;
@@ -0,0 +1,2 @@
1
+ import { DebuggerExtSpawn, DebugFabulous } from '../internals';
2
+ export default function spawnFactory(namespace?: string, debugFabFactory?: DebugFabulous): DebuggerExtSpawn;
@@ -0,0 +1,4 @@
1
+ import { DebugFabulous } from './internals';
2
+ export * from './internals';
3
+ declare const fabulous: DebugFabulous;
4
+ export default fabulous;
@@ -0,0 +1,17 @@
1
+ import { Debug, Debugger } from 'debug';
2
+ export interface DebugLazy extends Debug {
3
+ (namespace: string): DebuggerExt;
4
+ }
5
+ export interface DebugFabulous extends DebugLazy {
6
+ (namespace: string): DebuggerExt;
7
+ spawnable: (_namespace: string, _debugFabFactory?: Debug) => DebuggerExtSpawn;
8
+ }
9
+ export type LazyDebugFunc = () => string | any[];
10
+ export interface DebuggerExt extends Debugger {
11
+ (lazyFunc: LazyDebugFunc): void;
12
+ (...args: any[]): void;
13
+ spawn: (ns: string) => DebuggerExt;
14
+ }
15
+ export interface DebuggerExtSpawn extends DebuggerExt {
16
+ spawn: (ns: string) => DebuggerExt;
17
+ }