@substrate-system/debug 0.9.2 → 0.9.5

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/LICENSE CHANGED
@@ -1,131 +1,168 @@
1
- # PolyForm Noncommercial License 1.0.0
1
+ # Big Time Public License
2
2
 
3
- <https://polyformproject.org/licenses/noncommercial/1.0.0>
3
+ Version 2.0.2
4
+
5
+ <https://bigtimelicense.com/versions/2.0.2>
6
+
7
+ ## Purpose
8
+
9
+ These terms let you use and share this software for noncommercial purposes
10
+ and in small business for free, while also guaranteeing that paid licenses
11
+ for big businesses will be available on fair, reasonable, and
12
+ nondiscriminatory terms.
4
13
 
5
14
  ## Acceptance
6
15
 
7
- In order to get any license under these terms, you must agree
8
- to them as both strict obligations and conditions to all
9
- your licenses.
16
+ In order to get any license under these terms, you must agree to them as
17
+ both strict obligations and conditions to all your licenses.
10
18
 
11
- ## Copyright License
19
+ ## Noncommercial Purposes
12
20
 
13
- The licensor grants you a copyright license for the
14
- software to do everything you might do with the software
15
- that would otherwise infringe the licensor's copyright
16
- in it for any permitted purpose. However, you may
17
- only distribute the software according to [Distribution
18
- License](#distribution-license) and make changes or new works
19
- based on the software according to [Changes and New Works
20
- License](#changes-and-new-works-license).
21
+ You may use the software for any noncommercial purpose.
21
22
 
22
- ## Distribution License
23
+ ## Personal Uses
23
24
 
24
- The licensor grants you an additional copyright license
25
- to distribute copies of the software. Your license
26
- to distribute covers distributing the software with
27
- changes and new works permitted by [Changes and New Works
28
- License](#changes-and-new-works-license).
25
+ Personal use for research, experiment, and testing for the benefit of
26
+ public knowledge, personal study, private entertainment, hobby projects,
27
+ amateur pursuits, or religious observance, without any anticipated
28
+ commercial application, count as use for noncommercial purposes.
29
29
 
30
- ## Notices
30
+ ## Noncommercial Organizations
31
31
 
32
- You must ensure that anyone who gets a copy of any part of
33
- the software from you also gets a copy of these terms or the
34
- URL for them above, as well as copies of any plain-text lines
35
- beginning with `Required Notice:` that the licensor provided
36
- with the software. For example:
32
+ Use by any charitable organization, educational institution, public
33
+ research organization, public safety or health organization, environmental
34
+ protection organization, or government institution counts as use for
35
+ noncommercial purposes, regardless of the source of funding or obligations
36
+ resulting from the funding.
37
37
 
38
- > Required Notice: Copyright Bicycle Computing (https://bicycle.codes/)
38
+ ## Small Business
39
39
 
40
- ## Changes and New Works License
40
+ You may use the software for the benefit of your company if it meets all
41
+ these criteria:
41
42
 
42
- The licensor grants you an additional copyright license to
43
- make changes and new works based on the software for any
44
- permitted purpose.
43
+ 1. had fewer than 20 total individuals working as employees and
44
+ independent contractors at all times during the last tax year
45
45
 
46
- ## Patent License
46
+ 2. earned less than $1,000,000 total revenue in the last tax year
47
47
 
48
- The licensor grants you a patent license for the software that
49
- covers patent claims the licensor can license, or becomes able
50
- to license, that you would infringe by using the software.
48
+ 3. received less than $1,000,000 total debt, equity, and other investment
49
+ in the last five tax years, counting investment in predecessor
50
+ companies that reorganized into, merged with, or spun out your company
51
51
 
52
- ## Noncommercial Purposes
52
+ All dollar figures are United States dollars as of 2019. Adjust for them
53
+ inflation according to the United States Bureau of Labor Statistics'
54
+ consumer price index for all urban consumers, United States city average,
55
+ for all items, not seasonally adjusted, with 1982–1984=100 reference base.
53
56
 
54
- Any noncommercial purpose is a permitted purpose.
57
+ ## Big Business
55
58
 
56
- ## Personal Uses
59
+ You may use the software for the benefit of your company:
57
60
 
58
- Personal use for research, experiment, and testing for
59
- the benefit of public knowledge, personal study, private
60
- entertainment, hobby projects, amateur pursuits, or religious
61
- observance, without any anticipated commercial application,
62
- is use for a permitted purpose.
61
+ 1. for 128 days after your company stops qualifying under
62
+ [Small Business](#small-business)
63
63
 
64
- ## Noncommercial Organizations
64
+ 2. indefinitely, if the licensor or their legal successor does not offer
65
+ fair, reasonable, and nondiscriminatory terms for a commercial license for
66
+ the software within 32 days of [written request](#how-to-request) and
67
+ negotiate in good faith to conclude a deal
68
+
69
+ ## How to Request
70
+
71
+ If this software includes an address for the licensor or an agent of the
72
+ licensor in a standard place, such as in documentation, software package
73
+ metadata, or an "about" page or screen, try to request a fair commercial
74
+ license at that address. If this package includes both online and offline
75
+ addresses, try online before offline. If you can't deliver a request that
76
+ way, or this software doesn't include any addressees, spend one hour online
77
+ researching an address, recording all your searches and inquiries as you
78
+ go, and try any addresses that you find. If you can't find any addresses,
79
+ or if those addresses also fail, that counts as failure to offer a fair
80
+ commercial license by the licensor under [Big Business](#big-business).
65
81
 
66
- Use by any charitable organization, educational institution,
67
- public research organization, public safety or health
68
- organization, environmental protection organization,
69
- or government institution is use for a permitted purpose
70
- regardless of the source of funding or obligations resulting
71
- from the funding.
82
+ ## Fair, Reasonable, and Nondiscriminatory Terms
83
+
84
+ Fair, reasonable, and nondiscriminatory terms may license the software
85
+ perpetually or for a term, and may or may not cover new versions of the
86
+ software. If the licensor advertises license terms and a pricing structure
87
+ for generally available commercial licenses, the licensor proposes license
88
+ terms and a price as advertised, and a customer not affiliated with the
89
+ licensor has bought a commercial license for the software on substantially
90
+ equivalent terms in the past year, the proposal is fair, reasonable, and
91
+ nondiscriminatory.
92
+
93
+ ## Copyright License
94
+
95
+ The licensor grants you a copyright license to do everything with the
96
+ software that would otherwise infringe the licensor's copyright in it for
97
+ any purpose allowed by these terms.
98
+
99
+ ## Notices
100
+
101
+ You must ensure that anyone who gets a copy of any part of the software
102
+ from you also gets a copy of these terms or the URL for them above, as well
103
+ as copies of any plain-text lines beginning with `Required Notice:` that
104
+ the licensor provided with the software. For example:
105
+
106
+ > Required Notice: Copyright Nick Thomas (https://nichoth.com)
107
+
108
+ ## Patent License
109
+
110
+ The licensor grants you a patent license for the software that covers
111
+ patent claims the licensor can license, or becomes able to license, that
112
+ you would infringe by using the software.
72
113
 
73
114
  ## Fair Use
74
115
 
75
- You may have "fair use" rights for the software under the
76
- law. These terms do not limit them.
116
+ You may have "fair use" rights for the software under the law. These terms
117
+ do not limit them.
77
118
 
78
119
  ## No Other Rights
79
120
 
80
- These terms do not allow you to sublicense or transfer any of
81
- your licenses to anyone else, or prevent the licensor from
82
- granting licenses to anyone else. These terms do not imply
83
- any other licenses.
121
+ These terms do not allow you to sublicense or transfer any of your licenses
122
+ to anyone else, or prevent the licensor from granting licenses to anyone
123
+ else. These terms do not imply any other licenses.
84
124
 
85
125
  ## Patent Defense
86
126
 
87
- If you make any written claim that the software infringes or
88
- contributes to infringement of any patent, your patent license
89
- for the software granted under these terms ends immediately. If
90
- your company makes such a claim, your patent license ends
91
- immediately for work on behalf of your company.
127
+ If you make any written claim that the software infringes or contributes to
128
+ infringement of any patent, your patent license for the software granted
129
+ under these terms ends immediately. If your company makes such a claim,
130
+ your patent license ends immediately for work on behalf of your company.
92
131
 
93
132
  ## Violations
94
133
 
95
- The first time you are notified in writing that you have
96
- violated any of these terms, or done anything with the software
97
- not covered by your licenses, your licenses can nonetheless
98
- continue if you come into full compliance with these terms,
99
- and take practical steps to correct past violations, within
100
- 32 days of receiving notice. Otherwise, all your licenses
101
- end immediately.
134
+ The first time you are notified in writing that you have violated any of
135
+ these terms, or done anything with the software not covered by your
136
+ licenses, your licenses can nonetheless continue if you come into full
137
+ compliance with these terms, and take practical steps to correct past
138
+ violations, within 32 days of receiving notice. Otherwise, all your
139
+ licenses end immediately.
102
140
 
103
141
  ## No Liability
104
142
 
105
- ***As far as the law allows, the software comes as is, without
106
- any warranty or condition, and the licensor will not be liable
107
- to you for any damages arising out of these terms or the use
108
- or nature of the software, under any kind of legal claim.***
143
+ ***As far as the law allows, the software comes as is, without any warranty
144
+ or condition, and the licensor will not be liable to you for any damages
145
+ arising out of these terms or the use or nature of the software, under any
146
+ kind of legal claim.***
109
147
 
110
148
  ## Definitions
111
149
 
112
- The **licensor** is the individual or entity offering these
113
- terms, and the **software** is the software the licensor makes
114
- available under these terms.
115
-
116
- **You** refers to the individual or entity agreeing to these
150
+ The **licensor** is the individual or entity offering these terms, and
151
+ the **software** is the software the licensor makes available under these
117
152
  terms.
118
153
 
119
- **Your company** is any legal entity, sole proprietorship,
120
- or other kind of organization that you work for, plus all
121
- organizations that have control over, are under the control of,
122
- or are under common control with that organization. **Control**
123
- means ownership of substantially all the assets of an entity,
124
- or the power to direct its management and policies by vote,
154
+ **You** refers to the individual or entity agreeing to these terms.
155
+
156
+ **Your company** is any legal entity, sole proprietorship, or other kind of
157
+ organization that you work for, plus all organizations that have control
158
+ over, are under the control of, or are under common control with that
159
+ organization. **Control** means ownership of substantially all the assets
160
+ of an entity, or the power to direct its management and policies by vote,
125
161
  contract, or otherwise. Control can be direct or indirect.
126
162
 
127
- **Your licenses** are all the licenses granted to you for the
128
- software under these terms.
163
+ **Your licenses** are all the licenses granted to you for the software
164
+ under these terms.
165
+
166
+ **Use** means anything you do with the software requiring one of your
167
+ licenses.
129
168
 
130
- **Use** means anything you do with the software requiring one
131
- of your licenses.
package/README.md CHANGED
@@ -1,160 +1,145 @@
1
1
  # debug
2
- ![tests](https://github.com/substrate-system/debug/actions/workflows/nodejs.yml/badge.svg)
2
+ [![tests](https://img.shields.io/github/actions/workflow/status/substrate-system/debug/nodejs.yml?style=flat-square)](https://github.com/substrate-system/debug/actions/workflows/nodejs.yml)
3
3
  [![module](https://img.shields.io/badge/module-ESM-blue?style=flat-square)](README.md)
4
4
  [![types](https://img.shields.io/npm/types/@substrate-system/debug?style=flat-square)](README.md)
5
5
  [![semantic versioning](https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&style=flat-square)](https://semver.org/)
6
6
  [![install size](https://flat.badgen.net/packagephobia/install/@substrate-system/debug)](https://packagephobia.com/result?p=@substrate-system/debug)
7
- [![license](https://img.shields.io/badge/license-Polyform_Non_Commercial-26bc71?style=flat-square)](LICENSE)
7
+ [![license](https://img.shields.io/badge/license-Big_Time-blue?style=flat-square)](LICENSE)
8
8
 
9
9
 
10
- A tiny JavaScript debugging utility that works in Node.js and browsers. Use environment variables to control logging, so there are no ridiculous console log statements in production.
10
+ A tiny JavaScript debugging utility that works in Node.js and browsers.
11
+ Use environment variables to control logging in Node.js, and localStorage
12
+ to control logging in browsers, so there are no ridiculous console log
13
+ statements in production.
11
14
 
12
- This is based on [debug](https://github.com/debug-js/debug). It's been rewritten to use contemporary JS.
15
+ This is based on [debug](https://github.com/debug-js/debug).
16
+ It's been rewritten to use contemporary JS.
13
17
 
14
- In the browser, this should work well with [vite](https://vite.dev/). As is
15
- convention, this will look for an env variable prefixed with `VITE_`. So pass
16
- env variables like `VITE_DEBUG="foo"`.
18
+ In the browser, this uses localStorage to control debug output.
19
+ In Node.js, it uses the environmen variable `DEBUG`.
17
20
 
18
21
  **Featuring:**
19
- * Use [exports](https://github.com/substrate-system/debug/blob/main/package.json#L31) field in `package.json` to choose node JS or browser version
22
+ * Use [exports](https://github.com/substrate-system/debug/blob/main/package.json#L31)
23
+ field in `package.json` to choose node JS or browser version
20
24
  * ESM only
21
25
 
22
- Plus, [see the docs](https://substrate-system.github.io/debug/) generated by typescript.
26
+ Plus, [see the docs](https://substrate-system.github.io/debug/)
27
+ generated by typescript.
23
28
 
24
29
  ## Contents
25
30
 
26
31
  <!-- toc -->
27
32
 
28
- - [config](#config)
29
- * [namespace](#namespace)
30
- * [NODE_ENV + Vite](#node_env--vite)
31
- - [install](#install)
33
+ - [Install](#install)
34
+ - [Browser](#browser)
32
35
  - [Node JS](#node-js)
33
- * [NODE_ENV](#node_env)
34
- - [develop](#develop)
36
+ - [Config](#config)
37
+ * [Namespace](#namespace)
38
+ * [Enable all namespaces](#enable-all-namespaces)
39
+ * [Enable specific namespaces](#enable-specific-namespaces)
40
+ * [Force logging with boolean true](#force-logging-with-boolean-true)
41
+ - [Develop](#develop)
35
42
  * [browser](#browser)
36
- - [test](#test)
37
- * [node](#node)
43
+ - [Test](#test)
44
+ * [Node](#node)
38
45
 
39
46
  <!-- tocstop -->
40
47
 
41
- ## config
48
+ ## Install
42
49
 
43
- ### namespace
44
- Works with `vite` or other systems. This will look at `import.meta.env`, or
45
- an arbitrary object you can pass in.
50
+ ```sh
51
+ npm i -D @substrate-system/debug
52
+ ```
46
53
 
47
- ```js
48
- import Debug from '@substrate-system/debug'
54
+ **Browser usage**: Use `localStorage` `DEBUG` key.
55
+ **Node.js usage**: Use environment variable `DEBUG`.
49
56
 
50
- // look at `import.meta.env.VITE_DEBUG`
51
- const debug = Debug('example')
57
+ ## Browser
52
58
 
53
- // or call with your own env object
54
- const debug = Debug('example', { DEBUG: 'example' })
55
- ```
56
-
57
- If you create an instance without passing in a `namespace` string, then this
58
- will log iff anything other than `false` is passed as an argument.
59
+ In the browser, this looks for the `DEBUG` key in `localStorage`.
59
60
 
60
61
  ```js
61
62
  import Debug from '@substrate-system/debug'
62
63
 
63
- // log b/c we are not calling with `false`
64
- const debug = Debug()
64
+ // Set DEBUG in localStorage
65
+ localStorage.setItem('DEBUG', 'myapp:*')
65
66
 
66
- debug('hello')
67
+ const debug = Debug('myapp:component')
68
+ debug('hello logs')
69
+ // will log, because DEBUG in localStorage matches 'myapp:*'
67
70
  ```
68
71
 
69
- You can use any variable as debug status:
72
+ ## Node JS
73
+ Run your script with an env variable, `DEBUG`.
70
74
 
71
75
  ```js
72
- import Debug from '@substrate-system/debug'
73
-
74
- // in Vite
75
- const debug = Debug(!!(import.meta.env && import.meta.env.DEV))
76
-
77
- // in an arbitrary server
78
- const debug = Debug(window.EXAMPLE_DEBUG_MODE)
76
+ // in node JS
77
+ import createDebug from '@substrate-system/debug/node'
78
+ const debug = createDebug('fooo')
79
+ debug('testing')
79
80
  ```
80
81
 
81
- Use an env variable of `*` to log everything.
82
-
83
-
84
- ### NODE_ENV + Vite
85
-
86
- Build the site with a `NODE_ENV` variable to set `import.meta.env.DEV`:
87
-
82
+ Call this with an env var of `DEBUG=fooo`
88
83
  ```sh
89
- NODE_ENV=development vite build
84
+ DEBUG=fooo node ./test/fixture/node.js
90
85
  ```
91
86
 
92
- Any value of `NODE_ENV`, except `production`, wil equate to
93
- `import.meta.env.DEV` being true.
87
+ ## Config
94
88
 
95
- ```sh
96
- NODE_ENV=staging vite build
97
- ```
89
+ ### Namespace
90
+ In browsers, this checks `localStorage` for `DEBUG` key. In Node.js, this checks
91
+ the environment variable `DEBUG`.
98
92
 
99
- ----------------------------------------------------------------------
93
+ ```js
94
+ import Debug from '@substrate-system/debug'
100
95
 
101
- ## install
96
+ // In browser: checks localStorage.getItem('DEBUG')
97
+ const debug = Debug('example')
102
98
 
103
- ```sh
104
- npm i -D @substrate-system/debug
99
+ // Log if no namespace is set in localStorage
100
+ const debug = Debug(import.meta.env.DEV)
105
101
  ```
106
102
 
107
- Use this with [vite](https://vitejs.dev/) in the [browser](#browser), or
108
- in [node](#node-JS).
109
-
110
-
111
- ------------------------------------------------------------------
112
-
113
-
114
- ## Node JS
115
- Run your script with an env variable, `DEBUG`.
103
+ ### Enable all namespaces
116
104
 
117
105
  ```js
118
- // in node JS
119
- import createDebug from '@substrate-system/debug/node'
120
- const debug = createDebug('fooo')
121
- debug('testing')
106
+ localStorage.setItem('DEBUG', '*')
122
107
  ```
123
108
 
124
- Call this with an env var of `DEBUG=fooo`
125
- ```sh
126
- DEBUG=fooo node ./test/fixture/node.js
109
+ ### Enable specific namespaces
110
+ ```js
111
+ localStorage.setItem('DEBUG', 'myapp:auth,myapp:api')
127
112
  ```
128
113
 
129
- ### NODE_ENV
130
- If you are in dev mode (`process.env.NODE_ENV === 'development'`), then this will log things in a random color if you don't initialize it with a namespace --
114
+ ### Force logging with boolean true
115
+
116
+ You can also pass `true` to force logging regardless of `localStorage`.
117
+ For example, in Vite, this will log on your localhost server, but not
118
+ in production:
131
119
 
132
120
  ```js
133
- import createDebug from '@substrate-system/debug'
134
- const debug = createDebug()
135
- debug('hello')
121
+ const debug = Debug(import.meta.env.DEV)
122
+ debug('This logs')
136
123
  ```
137
124
 
138
- Run the script like this:
139
- ```sh
140
- NODE_ENV=development node ./my-script.js
141
- ```
125
+ ------------------------------------------------------------------
142
126
 
143
- -------------------------------------------------------------------
144
127
 
145
- ## develop
128
+ ## Develop
146
129
 
147
130
  ### browser
148
- Start a `vite` server and log some things. This uses [the example directory](./example/).
131
+ Start a `vite` server and log some things. This uses
132
+ [the example directory](./example/).
149
133
 
150
134
  ```sh
151
135
  npm start
152
136
  ```
153
137
 
154
138
 
155
- ## test
139
+ ## Test
140
+
141
+ ### Node
156
142
 
157
- ### node
158
143
  Run tests:
159
144
 
160
145
  ```sh
@@ -1,4 +1,4 @@
1
1
  export { createDebug };
2
2
  export default createDebug;
3
- declare function createDebug(namespace?: string | boolean, env?: Record<string, string>): (...args: any[]) => void;
3
+ declare function createDebug(namespace?: string | boolean): (...args: any[]) => void;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,CAAA;AACtB,eAAe,WAAW,CAAA;AAuK1B,iBAAS,WAAW,CAAE,SAAS,CAAC,EAAC,MAAM,GAAC,OAAO,EAAE,GAAG,CAAC,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,aAQnD,GAAG,EAAE,KAAG,IAAI,CAUpC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,CAAA;AACtB,eAAe,WAAW,CAAA;AA2K1B,iBAAS,WAAW,CAAE,SAAS,CAAC,EAAC,MAAM,GAAC,OAAO,aAYtB,GAAG,EAAE,KAAG,IAAI,CAUpC"}
@@ -7,24 +7,30 @@ export default createDebug;
7
7
  /**
8
8
  * Check if the given namespace is enabled.
9
9
  * `namespace` is the name that is passed into debug.
10
- * Need to check it against the env var.
10
+ * `forcedEnabled` is a boolean that forces logging when true.
11
+ * Only checks localStorage for the DEBUG key, unless forced.
11
12
  */
12
- function isEnabled(namespace, env) {
13
- if (env && (env.VITE_DEBUG === '*' || env.DEBUG === '*'))
13
+ function isEnabled(namespace, forcedEnabled) {
14
+ // If explicitly forced to be enabled via boolean true
15
+ if (forcedEnabled === true)
16
+ return true;
17
+ const DEBUG = localStorage.getItem('DEBUG');
18
+ // Check for wildcard
19
+ if (DEBUG === '*')
14
20
  return true;
15
21
  // if we were not called with a namespace
16
22
  if (namespace === 'DEV') {
17
- // We want to log iff we were not passed a VITE_DEBUG variable.
18
- // Pass in VITE_DEBUG="*" to log everything
19
- if (!env || (!env.VITE_DEBUG && !env.DEBUG)) {
23
+ // We want to log iff there is no DEBUG variable.
24
+ if (!DEBUG) {
20
25
  return true;
21
26
  }
22
27
  return false;
23
28
  }
24
- if (!env || (!env.VITE_DEBUG && !env.DEBUG))
29
+ // No DEBUG variable set
30
+ if (!DEBUG)
25
31
  return false;
26
- const envVars = createRegexFromEnvVar(namespace);
27
- return envVars.some(regex => regex.test(env.VITE_DEBUG || env.DEBUG));
32
+ const envVars = createRegexFromEnvVar(DEBUG);
33
+ return envVars.some(regex => regex.test(namespace));
28
34
  }
29
35
  /**
30
36
  * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
@@ -41,9 +47,9 @@ function createFormatters() {
41
47
  }
42
48
  };
43
49
  }
44
- function logger(namespace, args, { prevTime, color }, env) {
50
+ function logger(namespace, args, { prevTime, color }, forcedEnabled) {
45
51
  args = args || [];
46
- if (!isEnabled(namespace, env))
52
+ if (!isEnabled(namespace, forcedEnabled))
47
53
  return;
48
54
  // Set `diff` timestamp
49
55
  const curr = Number(new Date());
@@ -115,7 +121,7 @@ function formatArgs({ diff, color, namespace, useColors }, args) {
115
121
  (useColors ? ' %c' : ' ') +
116
122
  args[0] +
117
123
  (useColors ? '%c ' : ' ') +
118
- '+' + humanize(diff);
124
+ '+' + humanize(diff, {});
119
125
  if (!useColors)
120
126
  return;
121
127
  const c = 'color: ' + color;
@@ -139,13 +145,16 @@ function formatArgs({ diff, color, namespace, useColors }, args) {
139
145
  args.splice(lastC, 0, c);
140
146
  return args;
141
147
  }
142
- function createDebug(namespace, env) {
148
+ function createDebug(namespace) {
143
149
  if (namespace === false)
144
150
  return noop;
145
151
  const prevTime = Number(new Date());
146
152
  const color = selectColor(typeof namespace === 'string' ? namespace : generateRandomString(10), colors);
153
+ // Determine if this is a boolean true passed as the namespace
154
+ const forcedEnabled = namespace === true;
155
+ const actualNamespace = typeof namespace === 'string' ? namespace : 'DEV';
147
156
  const debug = function (...args) {
148
- return logger(typeof namespace === 'string' ? namespace : 'DEV', args, { prevTime, color }, env);
157
+ return logger(actualNamespace, args, { prevTime, color }, forcedEnabled);
149
158
  };
150
159
  return debug;
151
160
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,IAAI,CAAA;AACzB,OAAO,EACH,oBAAoB,EACpB,MAAM,EACN,WAAW,EACX,qBAAqB,EACxB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;AAErC,OAAO,EAAE,WAAW,EAAE,CAAA;AACtB,eAAe,WAAW,CAAA;AAE1B;;;;GAIG;AACH,SAAS,SAAS,CACd,SAAgB,EAChB,GAAyC;IAEzC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC;QAAE,OAAO,IAAI,CAAA;IAErE,yCAAyC;IACzC,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;QACtB,+DAA+D;QAC/D,2CAA2C;QAC3C,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAA;QACf,CAAC;QAED,OAAO,KAAK,CAAA;IAChB,CAAC;IAED,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,GAAG,C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AoB,CAAC,EAAE,CAAC,EACpE,MAAM,CACT,CAAA;IAED,8DAA8D;IAC9D,MAAM,aAAa,GAAG,SAAS,KAAK,IAAI,CAAA;IACxC,MAAM,eAAe,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;IAEzE,MAAM,KAAK,GAAyB,UAAU,GAAG,IAAU;QACvD,OAAO,MAAM,CACT,eAAe,EACf,IAAI,EACJ,EAAE,QAAQ,EAAE,KAAK,EAAE,EACnB,aAAa,CAChB,CAAA;IACL,CAAC,CAAA;IAED,OAAO,KAAK,CAAA;AAChB,CAAC;AAED,SAAS,IAAI,KAAK,CAAC"}
package/dist/ms.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Helpers.
3
+ */
4
+ /**
5
+ * Parse or format the given `val`.
6
+ *
7
+ * Options:
8
+ *
9
+ * - `long` verbose formatting [false]
10
+ *
11
+ * @param {String|Number} val
12
+ * @param {Object} [options]
13
+ * @throws {Error} throw an error if val is not a non-empty string or a number
14
+ * @return {String|Number}
15
+ * @api public
16
+ */
17
+ export default function (val: any, options?: {
18
+ long?: boolean;
19
+ }): string | number | undefined;
20
+ //# sourceMappingURL=ms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ms.d.ts","sourceRoot":"","sources":["../src/ms.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,OAAO,WAAW,GAAG,KAAA,EAAE,OAAO,GAAC;IAAE,IAAI,CAAC,EAAC,OAAO,CAAA;CAAO,+BAY3D"}
package/dist/ms.js ADDED
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Helpers.
3
+ */
4
+ const s = 1000;
5
+ const m = s * 60;
6
+ const h = m * 60;
7
+ const d = h * 24;
8
+ const w = d * 7;
9
+ const y = d * 365.25;
10
+ /**
11
+ * Parse or format the given `val`.
12
+ *
13
+ * Options:
14
+ *
15
+ * - `long` verbose formatting [false]
16
+ *
17
+ * @param {String|Number} val
18
+ * @param {Object} [options]
19
+ * @throws {Error} throw an error if val is not a non-empty string or a number
20
+ * @return {String|Number}
21
+ * @api public
22
+ */
23
+ export default function (val, options = {}) {
24
+ options = options || {};
25
+ const type = typeof val;
26
+ if (type === 'string' && val.length > 0) {
27
+ return parse(val);
28
+ }
29
+ else if (type === 'number' && isFinite(val)) {
30
+ return options.long ? fmtLong(val) : fmtShort(val);
31
+ }
32
+ throw new Error('val is not a non-empty string or a valid number. val=' +
33
+ JSON.stringify(val));
34
+ }
35
+ /**
36
+ * Parse the given `str` and return milliseconds.
37
+ *
38
+ * @param {String} str
39
+ * @return {Number}
40
+ * @api private
41
+ */
42
+ function parse(str) {
43
+ str = String(str);
44
+ if (str.length > 100) {
45
+ return;
46
+ }
47
+ const match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
48
+ if (!match) {
49
+ return;
50
+ }
51
+ const n = parseFloat(match[1]);
52
+ const type = (match[2] || 'ms').toLowerCase();
53
+ switch (type) {
54
+ case 'years':
55
+ case 'year':
56
+ case 'yrs':
57
+ case 'yr':
58
+ case 'y':
59
+ return n * y;
60
+ case 'weeks':
61
+ case 'week':
62
+ case 'w':
63
+ return n * w;
64
+ case 'days':
65
+ case 'day':
66
+ case 'd':
67
+ return n * d;
68
+ case 'hours':
69
+ case 'hour':
70
+ case 'hrs':
71
+ case 'hr':
72
+ case 'h':
73
+ return n * h;
74
+ case 'minutes':
75
+ case 'minute':
76
+ case 'mins':
77
+ case 'min':
78
+ case 'm':
79
+ return n * m;
80
+ case 'seconds':
81
+ case 'second':
82
+ case 'secs':
83
+ case 'sec':
84
+ case 's':
85
+ return n * s;
86
+ case 'milliseconds':
87
+ case 'millisecond':
88
+ case 'msecs':
89
+ case 'msec':
90
+ case 'ms':
91
+ return n;
92
+ default:
93
+ return undefined;
94
+ }
95
+ }
96
+ /**
97
+ * Short format for `ms`.
98
+ *
99
+ * @param {Number} ms
100
+ * @return {String}
101
+ * @api private
102
+ */
103
+ function fmtShort(ms) {
104
+ const msAbs = Math.abs(ms);
105
+ if (msAbs >= d) {
106
+ return Math.round(ms / d) + 'd';
107
+ }
108
+ if (msAbs >= h) {
109
+ return Math.round(ms / h) + 'h';
110
+ }
111
+ if (msAbs >= m) {
112
+ return Math.round(ms / m) + 'm';
113
+ }
114
+ if (msAbs >= s) {
115
+ return Math.round(ms / s) + 's';
116
+ }
117
+ return ms + 'ms';
118
+ }
119
+ /**
120
+ * Long format for `ms`.
121
+ *
122
+ * @param {Number} ms
123
+ * @return {String}
124
+ * @api private
125
+ */
126
+ function fmtLong(ms) {
127
+ const msAbs = Math.abs(ms);
128
+ if (msAbs >= d) {
129
+ return plural(ms, msAbs, d, 'day');
130
+ }
131
+ if (msAbs >= h) {
132
+ return plural(ms, msAbs, h, 'hour');
133
+ }
134
+ if (msAbs >= m) {
135
+ return plural(ms, msAbs, m, 'minute');
136
+ }
137
+ if (msAbs >= s) {
138
+ return plural(ms, msAbs, s, 'second');
139
+ }
140
+ return ms + ' ms';
141
+ }
142
+ /**
143
+ * Pluralization helper.
144
+ */
145
+ function plural(ms, msAbs, n, name) {
146
+ const isPlural = msAbs >= n * 1.5;
147
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
148
+ }
149
+ //# sourceMappingURL=ms.js.map
package/dist/ms.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ms.js","sourceRoot":"","sources":["../src/ms.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,GAAG,IAAI,CAAA;AACd,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;AAChB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;AAChB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;AAChB,MAAM,CAA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KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAClE,CAAC"}
package/dist/node.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import '@substrate-system/util/node/self';
2
2
  import supportsColor from 'supports-color';
3
- import ms from 'ms';
3
+ import ms from './ms.js';
4
4
  import tty from 'tty';
5
5
  import util from 'util';
6
6
  import { generateRandomString, coerce, createRegexFromEnvVar } from './common.js';
package/dist/node.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAA;AACzC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEjF,MAAM,MAAM,GAAY,CAAC,aAAa;IAClC,uBAAuB;IACvB,CAAC,aAAa,CAAC,MAAM,IAAI,aAAa,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,GAAG;IACH,GAAG;IACH,GAAG;I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S,GAAG,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACvD,MAAM,MAAM,GAAG,KAAK,SAAS,MAAM,SAAS,YAAY,CAAA;QAExD,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,CAAA;QAC1D,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAA;IACxD,CAAC;SAAM,CAAC;QACJ,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,GAAG,GAAG,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IACzD,CAAC;IAED,OAAO,IAAI,CAAA;AACf,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAE,SAAgB,EAAE,MAAe;IACnD,IAAI,IAAI,GAAG,CAAC,CAAA;IAEZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QACrD,IAAI,IAAI,CAAC,CAAA,CAAE,2BAA2B;IAC1C,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;AACjD,CAAC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@substrate-system/debug",
3
3
  "description": "Debug utility",
4
4
  "type": "module",
5
- "version": "0.9.2",
5
+ "version": "0.9.5",
6
6
  "main": "./dist/node.js",
7
7
  "files": [
8
8
  "./dist/*"
@@ -18,9 +18,10 @@
18
18
  },
19
19
  "scripts": {
20
20
  "lint": "eslint \"./**/*.{ts,js}\"",
21
+ "test-browser": "esbuild ./test/test-browser.ts --target=es2020 --bundle | npx tapout",
21
22
  "build-tests": "esbuild test/index.ts --platform=node --bundle --format=esm --keep-names > test/index.js",
22
23
  "test-node": "esbuild ./example/node.js --platform=node --bundle --format=esm --keep-names | node --input-type=module",
23
- "test": "npm run lint && npm run build && esbuild test/index.ts --target=es2020 --bundle --platform=node --format=esm | DEBUG=test NODE_ENV=development node --input-type=module",
24
+ "test": "npm run build && esbuild test/index.ts --target=es2020 --bundle --platform=node --format=esm | DEBUG=test NODE_ENV=development node --input-type=module",
24
25
  "build-browser-tests": "esbuild test/index.ts --platform=node --target=es2020 --bundle --keep-names > test/test-bundle.js",
25
26
  "test-tape-run": "npm run build-browser-tests && cat test/index.html | tape-run --input=html --static=test | tap-spec",
26
27
  "build": "mkdir -p dist && rm -rf dist/* && tsc --project tsconfig.build.json",
@@ -29,6 +30,7 @@
29
30
  "build-docs": "typedoc ./src/browser.ts ./src/node.ts",
30
31
  "toc": "markdown-toc --maxdepth 3 -i README.md",
31
32
  "start": "vite --mode=staging",
33
+ "start:ls": "vite --config vite-ls.config.js example-ls",
32
34
  "start:star": "VITE_DEBUG=\"*\" vite",
33
35
  "start:vite-production": "NODE_EN\"production\" vite",
34
36
  "start:bar-production": "NODE_ENV=\"production\" VITE_DEBUG=\"barrr\" vite",
@@ -42,11 +44,11 @@
42
44
  },
43
45
  "dependencies": {
44
46
  "@substrate-system/util": "^0.1.19",
45
- "ms": "2.1.3",
46
47
  "supports-color": "^10.0.0"
47
48
  },
48
49
  "devDependencies": {
49
- "@bicycle-codes/tapzero": "^0.10.0",
50
+ "@substrate-system/tapzero": "^0.10.15",
51
+ "@substrate-system/tapout": "^0.0.16",
50
52
  "@types/node": "^22.0.0",
51
53
  "@typescript-eslint/eslint-plugin": "^8.0.0",
52
54
  "@typescript-eslint/parser": "^8.0.0",
@@ -59,7 +61,7 @@
59
61
  "tape-run": "^11.0.0",
60
62
  "typedoc": "^0.28.1",
61
63
  "typescript": "^5.4.5",
62
- "vite": "^6.0.0"
64
+ "vite": "^7.0.1"
63
65
  },
64
66
  "author": "nichoth <nichoth@gmail.com> (https://nichoth.com)",
65
67
  "license": "SEE LICENSE IN LICENSE",