@juisy/utils 3.0.0-beta.3 → 3.0.0-beta.4
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 +661 -661
- package/README.md +12 -10
- package/dist/assert/argsert.d.ts +23 -5
- package/dist/assert/argsert.js +50 -3
- package/dist/assert/assert.d.ts +31 -0
- package/dist/assert/assert.js +32 -2
- package/dist/blob/to-data-url.d.ts +14 -0
- package/dist/blob/to-data-url.js +23 -0
- package/dist/constructor/apply-mixins.js +1 -1
- package/dist/constructor/get-constructor-name.js +1 -1
- package/dist/date/date-format.js +1 -1
- package/dist/date/get-date-range.js +1 -1
- package/dist/date/get-duration-between-times.js +1 -1
- package/dist/date/get-duration-between.js +1 -1
- package/dist/date/get-i18n-timezone-value.js +1 -1
- package/dist/date/get-next-date-for-time.js +1 -1
- package/dist/date/get-utc-offset.js +1 -1
- package/dist/fs/get-file-urls.js +5 -3
- package/dist/fs/get-files-sync.js +1 -1
- package/dist/fs/get-files.js +1 -1
- package/dist/fs/get-root-dir.js +1 -1
- package/dist/fs/is-directory.js +1 -1
- package/dist/fs/is-file.js +1 -1
- package/dist/is/is-def.js +1 -1
- package/dist/is/is-valid-css-color.js +1 -1
- package/dist/is/is.js +1 -1
- package/dist/json/compile-pointer.d.ts +8 -5
- package/dist/json/compile-pointer.js +4 -3
- package/dist/json/escape-pointer-segment.d.ts +5 -1
- package/dist/json/escape-pointer-segment.js +1 -1
- package/dist/json/get-by-pointer.js +1 -1
- package/dist/json/has-value.js +1 -1
- package/dist/json/parse-pointer.d.ts +8 -5
- package/dist/json/parse-pointer.js +2 -2
- package/dist/json/remove-by-pointer.js +1 -1
- package/dist/json/set-by-pointer.js +1 -1
- package/dist/json/to-pointers-dictionary.js +1 -1
- package/dist/json/traverse.js +1 -1
- package/dist/json/unescape-pointer-segment.d.ts +5 -1
- package/dist/json/unescape-pointer-segment.js +1 -1
- package/dist/misc/compose.js +1 -1
- package/dist/misc/detect-browser.js +1 -1
- package/dist/misc/get-aspect-ratio.d.ts +18 -0
- package/dist/misc/get-aspect-ratio.js +13 -0
- package/dist/misc/type-check.js +1 -1
- package/dist/number/get-greatest-common-divider.d.ts +17 -0
- package/dist/number/get-greatest-common-divider.js +17 -0
- package/dist/number/get-least-common-multiple.d.ts +16 -0
- package/dist/number/get-least-common-multiple.js +19 -0
- package/dist/object/deep-merge.js +1 -1
- package/dist/object/deep-parse.js +1 -1
- package/dist/object/get.js +1 -1
- package/dist/path/is-absolute.d.ts +19 -0
- package/dist/path/is-absolute.js +13 -0
- package/dist/path/is-invalid.d.ts +42 -0
- package/dist/path/is-invalid.js +23 -0
- package/dist/path/is-posix.js +1 -1
- package/dist/path/is-relative.d.ts +19 -0
- package/dist/path/is-relative.js +12 -0
- package/dist/path/is-same-as.d.ts +1 -0
- package/dist/path/is-same-as.js +1 -1
- package/dist/path/is-valid.d.ts +16 -0
- package/dist/path/is-valid.js +12 -0
- package/dist/path/is-win32.js +1 -1
- package/dist/path/normalize.d.ts +1 -0
- package/dist/path/normalize.js +2 -2
- package/dist/path/resolve-abs-from-root.js +2 -2
- package/dist/path/resolve-rel-from-root.js +1 -1
- package/dist/path/resolve-rel.d.ts +1 -0
- package/dist/path/resolve-rel.js +4 -3
- package/dist/path/strip-extension.d.ts +1 -0
- package/dist/path/strip-extension.js +2 -2
- package/dist/path/to-os-format.d.ts +1 -0
- package/dist/path/to-os-format.js +2 -2
- package/dist/path/to-posix.d.ts +1 -0
- package/dist/path/to-posix.js +2 -2
- package/dist/path/to-win32.d.ts +1 -0
- package/dist/path/to-win32.js +2 -2
- package/dist/random/random-alpha-numeric.js +7 -2
- package/dist/random/random-number.js +1 -1
- package/dist/string/camelcase.js +1 -1
- package/dist/string/capitalize.js +1 -1
- package/dist/string/constantcase.d.ts +4 -4
- package/dist/string/constantcase.js +1 -1
- package/dist/string/kebabcase.js +1 -1
- package/dist/string/lowercase.js +1 -1
- package/dist/string/pascalcase.js +1 -1
- package/dist/string/snakecase.js +1 -1
- package/dist/string/uppercase.js +1 -1
- package/package.json +22 -4
- package/skills/juisy-utils/SKILL.md +55 -0
- package/skills/juisy-utils/references/deep-imports.md +38 -0
package/dist/string/kebabcase.js
CHANGED
package/dist/string/lowercase.js
CHANGED
package/dist/string/snakecase.js
CHANGED
package/dist/string/uppercase.js
CHANGED
package/package.json
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juisy/utils",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"description": "Juisy utils",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=20.0.0"
|
|
8
|
+
},
|
|
6
9
|
"files": [
|
|
7
10
|
"dist",
|
|
8
11
|
"LICENSE",
|
|
9
|
-
"README.md"
|
|
12
|
+
"README.md",
|
|
13
|
+
"skills"
|
|
10
14
|
],
|
|
11
15
|
"exports": {
|
|
12
16
|
"./assert/*": {
|
|
13
17
|
"types": "./dist/assert/*.d.ts",
|
|
14
18
|
"import": "./dist/assert/*.js"
|
|
15
19
|
},
|
|
20
|
+
"./blob/*": {
|
|
21
|
+
"types": "./dist/blob/*.d.ts",
|
|
22
|
+
"import": "./dist/blob/*.js"
|
|
23
|
+
},
|
|
16
24
|
"./constructor/*": {
|
|
17
25
|
"types": "./dist/constructor/*.d.ts",
|
|
18
26
|
"import": "./dist/constructor/*.js"
|
|
@@ -37,6 +45,10 @@
|
|
|
37
45
|
"types": "./dist/misc/*.d.ts",
|
|
38
46
|
"import": "./dist/misc/*.js"
|
|
39
47
|
},
|
|
48
|
+
"./number/*": {
|
|
49
|
+
"types": "./dist/number/*.d.ts",
|
|
50
|
+
"import": "./dist/number/*.js"
|
|
51
|
+
},
|
|
40
52
|
"./object/*": {
|
|
41
53
|
"types": "./dist/object/*.d.ts",
|
|
42
54
|
"import": "./dist/object/*.js"
|
|
@@ -68,7 +80,9 @@
|
|
|
68
80
|
"test": "vitest",
|
|
69
81
|
"test:dev": "npm test -- --watch",
|
|
70
82
|
"test:ui": "vitest --ui",
|
|
71
|
-
"root:cli": "node ../../bin/cli"
|
|
83
|
+
"root:cli": "node ../../bin/cli",
|
|
84
|
+
"check:exports": "publint .",
|
|
85
|
+
"check:attw": "attw --pack . --profile esm-only --ignore-rules internal-resolution-error"
|
|
72
86
|
},
|
|
73
87
|
"repository": {
|
|
74
88
|
"type": "git",
|
|
@@ -119,10 +133,14 @@
|
|
|
119
133
|
"lodash.snakecase": "^4.1.1",
|
|
120
134
|
"lodash.uppercase": "^4.3.0",
|
|
121
135
|
"ow": "^2.0.0",
|
|
136
|
+
"path-unified": "^0.2.0",
|
|
122
137
|
"pkg-dir": "^8.0.0",
|
|
123
138
|
"type-fest": "^5.2.0"
|
|
124
139
|
},
|
|
125
140
|
"release-it": {
|
|
126
|
-
"git": false
|
|
141
|
+
"git": false,
|
|
142
|
+
"npm": {
|
|
143
|
+
"publish": false
|
|
144
|
+
}
|
|
127
145
|
}
|
|
128
146
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: juisy-utils
|
|
3
|
+
description: >-
|
|
4
|
+
Uses @juisy/utils deep-import helpers for assert/argsert, is-* predicates,
|
|
5
|
+
path/fs/json/string/date/object utilities in Node and browser. Use when
|
|
6
|
+
installing @juisy/utils, picking the correct subpath import, adding
|
|
7
|
+
validation with argsert/assert, or replacing ad-hoc helpers with juisy utils.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# @juisy/utils
|
|
11
|
+
|
|
12
|
+
Portable Agent Skill for **consuming** [`@juisy/utils`](https://www.npmjs.com/package/@juisy/utils).
|
|
13
|
+
|
|
14
|
+
Sync after install:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx skills experimental_sync -y
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## When to use
|
|
21
|
+
|
|
22
|
+
- Shared runtime helpers across Node and (where supported) browser
|
|
23
|
+
- Argument validation (`argsert` / `assert*`) and type predicates (`is*`)
|
|
24
|
+
- Path/JSON/string/date/fs utilities without pulling all of juisy DX
|
|
25
|
+
- **Not** for juisy CLI / release / docs tooling — use the `juisy` skill
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npm install @juisy/utils
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Requires **Node `>=20`** (`package.json#engines`).
|
|
34
|
+
|
|
35
|
+
## Import style (critical)
|
|
36
|
+
|
|
37
|
+
There is **no** root `"."` export. Always deep-import (categories + tables → [references/deep-imports.md](./references/deep-imports.md)):
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import camelcase from '@juisy/utils/string/camelcase'
|
|
41
|
+
import { argsert } from '@juisy/utils/assert/argsert'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- Prefer **`argsert`** at public API boundaries; **`assert*`** / **`is*`** for internal narrowing.
|
|
45
|
+
- Some path/blob helpers differ Node vs browser — use the published dual builds.
|
|
46
|
+
|
|
47
|
+
## With juisy
|
|
48
|
+
|
|
49
|
+
`juisy` depends on `@juisy/utils`. You can still import `@juisy/utils/...` directly — keep versions aligned.
|
|
50
|
+
|
|
51
|
+
## References
|
|
52
|
+
|
|
53
|
+
- Guide / API: <https://hperchec.gitlab.io/juisy/api/@juisy/utils/>
|
|
54
|
+
- LLM index: <https://hperchec.gitlab.io/juisy/llms.txt>
|
|
55
|
+
- Optional deep-import catalog: [references/deep-imports.md](./references/deep-imports.md)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Deep imports
|
|
2
|
+
|
|
3
|
+
`@juisy/utils` has **no** root `"."` export. Always import a concrete subpath.
|
|
4
|
+
|
|
5
|
+
## Examples by category
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { argsert } from '@juisy/utils/assert/argsert'
|
|
9
|
+
import isDef from '@juisy/utils/is/is-def'
|
|
10
|
+
import camelcase from '@juisy/utils/string/camelcase'
|
|
11
|
+
import { deepMerge } from '@juisy/utils/object/deep-merge'
|
|
12
|
+
import getByPointer from '@juisy/utils/json/get-by-pointer'
|
|
13
|
+
import normalize from '@juisy/utils/path/normalize'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
| Subpath | Examples |
|
|
17
|
+
| ------- | -------- |
|
|
18
|
+
| `assert/*` | `argsert`, `assert`, `assertString`, … |
|
|
19
|
+
| `is/*` | `is`, `isDef`, `isValidCSSColor`, … |
|
|
20
|
+
| `path/*` | `normalize`, `to-posix`, `is-absolute`, … |
|
|
21
|
+
| `fs/*` | `getFiles`, `getRootDir`, … |
|
|
22
|
+
| `json/*` | JSON Pointer helpers |
|
|
23
|
+
| `string/*` | `camelcase`, `kebabcase`, `pascalcase`, … |
|
|
24
|
+
| `object/*` | `get`, `deepMerge`, … |
|
|
25
|
+
| `date/*`, `blob/*`, `number/*`, `random/*`, `misc/*`, `constructor/*` | specialized helpers |
|
|
26
|
+
|
|
27
|
+
## argsert at a public boundary
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { argsert } from '@juisy/utils/assert/argsert'
|
|
31
|
+
|
|
32
|
+
export function greet (name: string) {
|
|
33
|
+
argsert<string>(name, 'name', [ 'string', 'string.nonBlank' ])
|
|
34
|
+
return `Hello ${name}`
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Prefer **`argsert`** at public APIs; prefer **`assert*`** / **`is*`** for internal narrowing.
|