debug-fabulous 2.0.1 → 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.
- package/lib/{internals.d.ts → .tmp/internals.d.ts} +2 -1
- package/lib/index.js +49 -8
- package/package.json +25 -38
- package/umd/.tmp/debugFabFactory.d.ts +4 -0
- package/umd/.tmp/extensions/lazyEval.d.ts +3 -0
- package/umd/.tmp/extensions/spawn.d.ts +2 -0
- package/umd/.tmp/index.d.ts +4 -0
- package/umd/.tmp/internals.d.ts +17 -0
- package/umd/index.js +52 -2061
- package/lib/debugFabFactory.js +0 -13
- package/lib/extensions/lazyEval.js +0 -34
- package/lib/extensions/spawn.js +0 -19
- package/lib/internals.js +0 -2
- /package/lib/{debugFabFactory.d.ts → .tmp/debugFabFactory.d.ts} +0 -0
- /package/lib/{extensions → .tmp/extensions}/lazyEval.d.ts +0 -0
- /package/lib/{extensions → .tmp/extensions}/spawn.d.ts +0 -0
- /package/lib/{index.d.ts → .tmp/index.d.ts} +0 -0
|
@@ -6,10 +6,11 @@ export interface DebugFabulous extends DebugLazy {
|
|
|
6
6
|
(namespace: string): DebuggerExt;
|
|
7
7
|
spawnable: (_namespace: string, _debugFabFactory?: Debug) => DebuggerExtSpawn;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type LazyDebugFunc = () => string | any[];
|
|
10
10
|
export interface DebuggerExt extends Debugger {
|
|
11
11
|
(lazyFunc: LazyDebugFunc): void;
|
|
12
12
|
(...args: any[]): void;
|
|
13
|
+
spawn: (ns: string) => DebuggerExt;
|
|
13
14
|
}
|
|
14
15
|
export interface DebuggerExtSpawn extends DebuggerExt {
|
|
15
16
|
spawn: (ns: string) => DebuggerExt;
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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);
|
|
4
15
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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);
|
|
27
|
+
};
|
|
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
|
+
|
|
9
51
|
module.exports = fabulous;
|
|
10
|
-
exports.default = fabulous;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "debug-fabulous",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "visionmedia debug extensions rolled into one",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"debug",
|
|
@@ -16,65 +16,52 @@
|
|
|
16
16
|
"contributors": [
|
|
17
17
|
"Joe Ibershoff (https://github.com/zacronos)"
|
|
18
18
|
],
|
|
19
|
+
"main": "lib/index.js",
|
|
19
20
|
"files": [
|
|
20
21
|
"lib",
|
|
21
22
|
"umd"
|
|
22
23
|
],
|
|
23
|
-
"main": "lib/index.js",
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "
|
|
25
|
+
"build": "rollup -c ./rollup.config.js",
|
|
26
26
|
"coveralls": "cat ./coverage/lcov.info | coveralls",
|
|
27
|
-
"docs:api:markdown": "
|
|
28
|
-
"docs:api:website": "
|
|
29
|
-
"
|
|
30
|
-
"
|
|
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
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"roll:it": "yarn rollup -c ./rollup.config.ts",
|
|
38
|
-
"test": "yarn lint && yarn jest",
|
|
39
|
-
"test:ci": "yarn build && yarn test --coverage && yarn coveralls",
|
|
40
|
-
"preversion": "yarn build"
|
|
32
|
+
"prepare": "npx sort-package-json",
|
|
33
|
+
"test": "npm run build && npm run jest",
|
|
34
|
+
"test:ci": "npm run build && npm run test --coverage && npm run coveralls",
|
|
35
|
+
"preversion": "npm run build"
|
|
41
36
|
},
|
|
42
37
|
"dependencies": {
|
|
43
38
|
"debug": "^4",
|
|
44
39
|
"memoizee": "0.4"
|
|
45
40
|
},
|
|
46
41
|
"devDependencies": {
|
|
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
|
-
"@
|
|
49
|
-
"@znemz/js-common-
|
|
50
|
-
"@znemz/
|
|
51
|
-
"@znemz/js-common-eslint-config-mono-clone": "^0.0.23",
|
|
52
|
-
"@znemz/js-common-eslint-config-react-mono-clone": "^0.0.23",
|
|
53
|
-
"@znemz/js-common-gulp-monorepo-typescript": "^0.0.23",
|
|
54
|
-
"@znemz/js-common-prettierrc-clone": "^0.0.23",
|
|
55
|
-
"@znemz/node-memwatch": "^1.0.2",
|
|
56
|
-
"@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",
|
|
57
51
|
"JSONStream": "1.X",
|
|
58
|
-
"
|
|
52
|
+
"commitlint": "19",
|
|
59
53
|
"config": "^3.2.2",
|
|
60
54
|
"coveralls": "^3.0.4",
|
|
61
55
|
"del": "^4.1.1",
|
|
62
|
-
"esm": "^3.2.22",
|
|
63
|
-
"gulp-run": "^1.7.1",
|
|
64
|
-
"gulp-typescript": "^5.0.1",
|
|
65
56
|
"hook-std": "0.X",
|
|
57
|
+
"jest": "^29.7.0",
|
|
66
58
|
"prettier": "^1.18.2",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"rollup-plugin-typescript": "^1.0.1",
|
|
71
|
-
"sort-package-json": "^1.21.0",
|
|
72
|
-
"typedoc": "^0.15.0",
|
|
73
|
-
"typedoc-plugin-markdown": "^2.1.4",
|
|
74
|
-
"typescript": "3.5"
|
|
59
|
+
"rollup": "4.21.3",
|
|
60
|
+
"sort-package-json": "^2.10.1",
|
|
61
|
+
"typescript": "^4.2.4"
|
|
75
62
|
},
|
|
76
63
|
"engines": {
|
|
77
|
-
"node": ">=
|
|
64
|
+
"node": ">= 14"
|
|
78
65
|
},
|
|
79
66
|
"umd": "umd/index.js"
|
|
80
67
|
}
|
|
@@ -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
|
+
}
|