@rtorcato/js-common 5.0.0 → 6.0.0
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/AGENTS.md +6 -5
- package/README.md +19 -20
- package/dist/cli/index.mjs +7 -10
- package/dist/currency/currencies.d.ts.map +1 -1
- package/dist/currency/index.d.ts.map +1 -1
- package/dist/env/index.d.ts +1 -1
- package/dist/env/index.d.ts.map +1 -1
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/mime-types/db.d.ts +1839 -1839
- package/dist/mime-types/db.d.ts.map +1 -1
- package/dist/mime-types/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/sleep/index.d.ts.map +1 -1
- package/dist/uuid/index.d.ts.map +1 -1
- package/package.json +59 -37
- package/CHANGELOG.md +0 -258
package/AGENTS.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Using @rtorcato/js-common
|
|
4
4
|
|
|
5
|
-
`@rtorcato/js-common` is a tree-shakeable, ESM-only utility library for Node.js >=
|
|
5
|
+
`@rtorcato/js-common` is a tree-shakeable, ESM-only utility library for Node.js >= 24 (TypeScript-first, JSDoc on every public API). One subpath export per concern — 42 of them. There is no package root export.
|
|
6
6
|
|
|
7
7
|
## Rules
|
|
8
8
|
|
|
@@ -101,12 +101,13 @@ Import from `@rtorcato/js-common/<module>`.
|
|
|
101
101
|
|
|
102
102
|
## CLI
|
|
103
103
|
|
|
104
|
-
The package also ships a binary for shell use
|
|
104
|
+
The package also ships a binary for shell use. Its UI packages are optional peers, so install them first
|
|
105
|
+
(`npm install -g @rtorcato/js-common @inquirer/prompts chalk chalk-animation commander figlet gradient-string`):
|
|
105
106
|
|
|
106
107
|
```bash
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
js-common date today
|
|
109
|
+
js-common math sum 1 2 3
|
|
110
|
+
js-common text capitalize "hello world"
|
|
110
111
|
```
|
|
111
112
|
|
|
112
113
|
See [CLI.md](https://github.com/rtorcato/js-common/blob/main/CLI.md) for the full command list.
|
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# js-common
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
<!-- brand-kit:banner:start -->
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(max-width: 640px)" srcset="./brand/banner-mobile.png">
|
|
6
|
+
<img src="./brand/banner.png" alt="js-common banner" width="1600">
|
|
7
|
+
</picture>
|
|
8
|
+
<!-- brand-kit:banner:end -->
|
|
9
9
|
|
|
10
10
|
[](https://github.com/rtorcato/js-common/actions/workflows/ci.yml)
|
|
11
11
|
[](https://badge.fury.io/js/%40rtorcato%2Fjs-common)
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
[](https://bundlephobia.com/package/@rtorcato/js-common)
|
|
14
14
|
[](https://opensource.org/licenses/MIT)
|
|
15
15
|
[](https://www.typescriptlang.org/)
|
|
16
|
-
[](https://codecov.io/gh/rtorcato/js-common)
|
|
16
|
+
[](https://nodejs.org/)
|
|
18
17
|
[](https://docs.torcato.dev/js-common/)
|
|
19
18
|
|
|
20
19
|
A comprehensive set of common JavaScript and TypeScript utilities for Node.js projects.
|
|
@@ -29,7 +28,7 @@ A comprehensive set of common JavaScript and TypeScript utilities for Node.js pr
|
|
|
29
28
|
- **TypeScript** — full type definitions, JSDoc on every public API
|
|
30
29
|
- **CLI included** — optional binary for use in scripts and terminals
|
|
31
30
|
- **Modular** — one module per concern, 42 subpaths
|
|
32
|
-
- **No required runtime deps** — `zod` (`./env`), `pino` (`./logger`) and `uuid` + `short-uuid` (`./uuid`) are optional peers: install one only if you import its module. CLI packages (`chalk`, `commander`, `figlet`, …) are
|
|
31
|
+
- **No required runtime deps** — `zod` (`./env`), `pino` (`./logger`, plus `pino-pretty` for pretty dev logs) and `uuid` + `short-uuid` (`./uuid`) are optional peers: install one only if you import its module. The CLI packages (`chalk`, `commander`, `figlet`, …) are optional peers too, needed only to run the `js-common` binary — see [CLI.md](CLI.md).
|
|
33
32
|
|
|
34
33
|
## Installation
|
|
35
34
|
|
|
@@ -42,7 +41,7 @@ Three modules need an optional peer you install yourself:
|
|
|
42
41
|
| Module | Peer |
|
|
43
42
|
|---|---|
|
|
44
43
|
| `./env` | `npm install zod` |
|
|
45
|
-
| `./logger` | `npm install pino` |
|
|
44
|
+
| `./logger` | `npm install pino` (add `pino-pretty` for pretty dev logs) |
|
|
46
45
|
| `./uuid` | `npm install uuid short-uuid` |
|
|
47
46
|
|
|
48
47
|
Pre-release builds are published to the `beta` dist-tag, so they never reach a plain `npm install`:
|
|
@@ -74,6 +73,8 @@ npx skills add https://github.com/rtorcato/js-common --skill js-common
|
|
|
74
73
|
|
|
75
74
|
## Migrating
|
|
76
75
|
|
|
76
|
+
**5.x → 6.x** — the Node floor is now 24 (`engines.node >=24`). The CLI packages (`@inquirer/prompts`, `chalk`, `chalk-animation`, `commander`, `figlet`, `gradient-string`) and `pino-pretty` moved from `optionalDependencies` to optional `peerDependencies`, so a plain install no longer downloads them. To run the CLI, install them alongside the package; for pretty `./logger` output in dev, add `pino-pretty`. Details in the [migration guide](https://docs.torcato.dev/js-common/docs/guides/migration).
|
|
77
|
+
|
|
77
78
|
**4.x → 5.x** — `zod`, `pino`, `uuid` and `short-uuid` moved from `dependencies` to optional `peerDependencies`. If you import `./env`, add `zod`; `./logger`, add `pino`; `./uuid`, add `uuid` and `short-uuid`. Every other module is unaffected. Details in the [migration guide](https://docs.torcato.dev/js-common/docs/guides/migration).
|
|
78
79
|
|
|
79
80
|
**3.x → 4.x** — everything the runtime already does was removed. `./sets` and `./interval` are gone as modules, and the pass-through wrappers inside surviving modules went with them: `promises.all`/`allSettled`/`race`/`delay`, `boolean.and`/`or`/`not`/`xor`, `strings.padStart`/`padEnd`/`replaceString`, `arrays.first`/`last`/`flatten`/`groupBy`, `numbers.isInteger`/`isFiniteNumber`/`min`/`max`, `objects.deepClone`, `json.deepCloneJson` and `uuid.getUUID`. Nothing moved to another module — the replacement is a JavaScript built-in in every case, which the Node 22 floor guarantees. Two are **not** drop-ins: `Object.groupBy` returns a null-prototype object with optional values, and `structuredClone` keeps `Date`s where the JSON round trip flattened them. The full before/after table is in the [migration guide](https://docs.torcato.dev/js-common/docs/guides/migration).
|
|
@@ -105,20 +106,18 @@ Prefer the Result-style `tryCatch` for new code; reserve `tryWithFallback` for c
|
|
|
105
106
|
|
|
106
107
|
## CLI Usage
|
|
107
108
|
|
|
108
|
-
This package includes a command-line interface for many utilities:
|
|
109
|
+
This package includes a command-line interface for many utilities. Its UI packages are optional peers, so install them alongside it:
|
|
109
110
|
|
|
110
111
|
```bash
|
|
111
112
|
# Install globally to use the CLI
|
|
112
|
-
npm install -g @rtorcato/js-common
|
|
113
|
-
|
|
114
|
-
# Or use with npx
|
|
115
|
-
npx @rtorcato/js-common@latest --help
|
|
113
|
+
npm install -g @rtorcato/js-common @inquirer/prompts chalk chalk-animation commander figlet gradient-string
|
|
114
|
+
js-common --help
|
|
116
115
|
|
|
117
116
|
# Examples
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
js-common date today
|
|
118
|
+
js-common math sum 1 2 3 4 5
|
|
119
|
+
js-common text capitalize "hello world"
|
|
120
|
+
js-common system node-version
|
|
122
121
|
```
|
|
123
122
|
|
|
124
123
|
See [CLI.md](./CLI.md) for complete CLI documentation.
|
|
@@ -230,7 +229,7 @@ import { info, warn, error, captureConsole } from '@rtorcato/js-common/logging'
|
|
|
230
229
|
|
|
231
230
|
## Requirements
|
|
232
231
|
|
|
233
|
-
- **Node.js** >=
|
|
232
|
+
- **Node.js** >= 24.0.0 (enforced via the `engines` field)
|
|
234
233
|
- **TypeScript** >= 5.0.0 (for TypeScript projects)
|
|
235
234
|
|
|
236
235
|
## Development
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Entry point for the js-common CLI binary.
|
|
3
|
-
// CLI-only npm deps (chalk, commander, figlet, …)
|
|
4
|
-
// `
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
3
|
+
// CLI-only npm deps (chalk, commander, figlet, …) are optional
|
|
4
|
+
// `peerDependencies`, so library-only consumers never install them. If any
|
|
5
|
+
// of them is missing at runtime we catch the resolution error and print one
|
|
6
|
+
// install line instead of letting Node emit an opaque ERR_MODULE_NOT_FOUND
|
|
7
|
+
// trace. cli.test.ts fails if this list misses a package cli.ts imports.
|
|
8
|
+
const CLI_PEERS = '@inquirer/prompts chalk chalk-animation commander figlet gradient-string';
|
|
8
9
|
try {
|
|
9
10
|
await import('./cli.mjs');
|
|
10
11
|
}
|
|
@@ -14,11 +15,7 @@ catch (err) {
|
|
|
14
15
|
'code' in err &&
|
|
15
16
|
err.code === 'ERR_MODULE_NOT_FOUND';
|
|
16
17
|
if (isMissingModule) {
|
|
17
|
-
process.stderr.write(
|
|
18
|
-
'Install them globally to use the CLI:\n\n' +
|
|
19
|
-
' npm install -g @rtorcato/js-common\n\n' +
|
|
20
|
-
'Or run it ad-hoc with npx, which installs them on demand:\n\n' +
|
|
21
|
-
' npx @rtorcato/js-common@latest --help\n');
|
|
18
|
+
process.stderr.write(`js-common CLI: missing peer dependencies. Install them with: npm i -D ${CLI_PEERS}\n`);
|
|
22
19
|
process.exit(1);
|
|
23
20
|
}
|
|
24
21
|
throw err;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currencies.d.ts","sourceRoot":"","sources":["../../src/currency/currencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,UAAU,UA4Cf,CAAA;
|
|
1
|
+
{"version":3,"file":"currencies.d.ts","sourceRoot":"","sources":["../../src/currency/currencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,UAAU,UA4Cf,CAAA;eAEc,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currency/index.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currency/index.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,aAAc,MAAM,KAAG,MAAM,GAAG,SAY7D,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAO,GAAG,MAAM,GAAG,SAAS,CAMnF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkC1D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,SAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAM7F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,SAAQ,EAChB,MAAM,CAAC,EAAE,MAAM,GACb,MAAM,CAQR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAevD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA2C9F;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAElF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGxE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOrD"}
|
package/dist/env/index.d.ts
CHANGED
|
@@ -77,9 +77,9 @@ export declare const RootApiEnvSchema: z.ZodObject<{
|
|
|
77
77
|
}>>;
|
|
78
78
|
LOG_LEVEL: z.ZodDefault<z.ZodEnum<{
|
|
79
79
|
debug: "debug";
|
|
80
|
+
error: "error";
|
|
80
81
|
info: "info";
|
|
81
82
|
warn: "warn";
|
|
82
|
-
error: "error";
|
|
83
83
|
}>>;
|
|
84
84
|
PORT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
85
85
|
}, z.core.$strip>;
|
package/dist/env/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM,QAAS,MAAM,iBAAiB,MAAM,WAUxD,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,QAAO,OAExB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,QAAO,OAEzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,QAAO,OAEzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAC/C,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACzB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,oCAc1D;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;iBAI3B,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAA;AAcvB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM,6BA4BQ,CAAA"}
|