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.
@@ -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 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;
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
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var debugFabFactory_1 = __importDefault(require("./debugFabFactory"));
7
- var spawn_1 = __importDefault(require("./extensions/spawn"));
8
- var fabulous = Object.assign(debugFabFactory_1.default, { spawnable: spawn_1.default });
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.1",
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": "yarn gulp default && yarn roll:it",
25
+ "build": "rollup -c ./rollup.config.js",
26
26
  "coveralls": "cat ./coverage/lcov.info | coveralls",
27
- "docs:api:markdown": "yarn typedoc --theme markdown --exclude ./src/test --out ./docs/api ./src",
28
- "docs:api:website": "yarn 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": "yarn js-common-editorconfig-clone",
34
- "postinstall:2": "yarn js-common-eslint-config-react-mono-clone && js-common-babel-config-clone",
35
- "postinstall:3": "yarn js-common-prettierrc-clone && yarn js-common-eslint-config-mono-clone",
36
- "prepare": "yarn postinstall:1 && yarn postinstall:2 && yarn postinstall:3 && yarn sort-package-json",
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
- "@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-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
- "bluebird": "^3.5.5",
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
- "react": "^16.8",
68
- "rollup": "^1.20.1",
69
- "rollup-plugin-commonjs": "^10.1.0",
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": ">= 8"
64
+ "node": ">= 14"
78
65
  },
79
66
  "umd": "umd/index.js"
80
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
+ }