@gesslar/toolkit 1.10.0 → 2.1.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/README.md +31 -50
- package/package.json +5 -7
- package/src/browser/lib/Collection.js +1 -1
- package/src/lib/FS.js +1 -2
- package/src/lib/Util.js +45 -1
- package/src/types/browser/lib/Collection.d.ts +2 -2
- package/src/types/browser/lib/Collection.d.ts.map +1 -1
- package/src/types/lib/FS.d.ts.map +1 -1
- package/src/types/lib/Util.d.ts +24 -0
- package/src/types/lib/Util.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Toolkit
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
project's consumption. Not the kind that gives you bleeding, hacking coughs,
|
|
5
|
-
but the kind that gives "yumyum."
|
|
6
|
-
|
|
7
|
-
There are file and directory abstractions, uhmm, there's also some terminal
|
|
8
|
-
things and validity checkers, lots of data functions.
|
|
3
|
+
A collection of utilities for Node.js and browser environments, including file and directory abstractions, terminal utilities, validation helpers, and data manipulation functions.
|
|
9
4
|
|
|
10
5
|
## Included Classes
|
|
11
6
|
|
|
@@ -16,37 +11,39 @@ a Tauri app.
|
|
|
16
11
|
|
|
17
12
|
| Name | Description |
|
|
18
13
|
| ---- | ----------- |
|
|
19
|
-
| Collection | Array, Map,
|
|
20
|
-
| Data | Primitive manipulation and identification |
|
|
21
|
-
| Disposer |
|
|
22
|
-
| HTML | HTML
|
|
23
|
-
| Notify |
|
|
24
|
-
| Sass |
|
|
25
|
-
| Tantrum |
|
|
26
|
-
|
|
|
27
|
-
| Util |
|
|
28
|
-
| Valid |
|
|
14
|
+
| Collection | Array, Map, Set, and other collection manipulation methods |
|
|
15
|
+
| Data | Primitive manipulation and type identification |
|
|
16
|
+
| Disposer | Lifecycle management for disposable resources |
|
|
17
|
+
| HTML | HTML loading and sanitization utilities |
|
|
18
|
+
| Notify | Event system wrapper for DOM events |
|
|
19
|
+
| Sass | Custom Error class with enhanced features |
|
|
20
|
+
| Tantrum | AggregateError implementation |
|
|
21
|
+
| Type | String-based type management (exported as TypeSpec in browser) |
|
|
22
|
+
| Util | General utility functions |
|
|
23
|
+
| Valid | Validation and assertion methods |
|
|
29
24
|
|
|
30
25
|
### Node.js
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
Includes all browser functionality plus Node.js-specific modules for file I/O, logging, and system operations.
|
|
33
28
|
|
|
34
29
|
| Name | Description |
|
|
35
30
|
| ---- | ----------- |
|
|
36
|
-
| Cache | Cache management for
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
31
|
+
| Cache | Cache management for file I/O operations |
|
|
32
|
+
| CappedDirectoryObject | Directory operations constrained to a specific tree |
|
|
33
|
+
| Contract | Contract management and validation |
|
|
34
|
+
| DirectoryObject | File system wrapper for directory operations |
|
|
35
|
+
| FileObject | File system wrapper for file operations |
|
|
36
|
+
| FS | Base class for file system operations with static utilities |
|
|
37
|
+
| Glog | Logging framework |
|
|
38
|
+
| Notify | Event system wrapper for Node.js events |
|
|
39
|
+
| Sass | Custom Error class with enhanced features |
|
|
40
|
+
| Schemer | JSON schema validation and management |
|
|
41
|
+
| Tantrum | AggregateError implementation |
|
|
42
|
+
| TempDirectoryObject | Temporary directory management with automatic cleanup |
|
|
43
|
+
| Term | Terminal formatting and output utilities |
|
|
47
44
|
| Terms | Terms for use with Contract |
|
|
48
|
-
| Util |
|
|
49
|
-
| Valid |
|
|
45
|
+
| Util | General utility functions (Node-enhanced version) |
|
|
46
|
+
| Valid | Validation and assertion methods |
|
|
50
47
|
|
|
51
48
|
## Installation
|
|
52
49
|
|
|
@@ -56,9 +53,7 @@ npm i @gesslar/toolkit
|
|
|
56
53
|
|
|
57
54
|
## Usage
|
|
58
55
|
|
|
59
|
-
Toolkit is environment aware and
|
|
60
|
-
Node.js. It is not strictly necessary to specify whether you require the `node` or
|
|
61
|
-
`browser` variant, but you may do so if you like to feel like a nice control daddy.
|
|
56
|
+
Toolkit is environment aware and automatically detects whether it is being used in a web browser or in Node.js. You can optionally specify the `node` or `browser` variant explicitly.
|
|
62
57
|
|
|
63
58
|
### Browser-like
|
|
64
59
|
|
|
@@ -90,25 +85,11 @@ import {Data, FileObject, Cache} from "@gesslar/toolkit"
|
|
|
90
85
|
```
|
|
91
86
|
|
|
92
87
|
```javascript
|
|
93
|
-
import {Data,
|
|
88
|
+
import {Data, FileObject} from "@gesslar/toolkit/node"
|
|
94
89
|
```
|
|
95
90
|
|
|
96
91
|
```javascript
|
|
97
92
|
import { Data, Collection, Util } from '@gesslar/toolkit/browser'
|
|
98
93
|
```
|
|
99
94
|
|
|
100
|
-
The browser version includes: Data,
|
|
101
|
-
Sass, and Tantrum. Node-only modules (FileObject, Cache, FS, etc.) are not
|
|
102
|
-
available in the browser version.
|
|
103
|
-
|
|
104
|
-
Basically, if you want it, it is most definitely here, and working 100% and
|
|
105
|
-
absolutely none of that is true. There are only a few classes here, but they're
|
|
106
|
-
pretty. And if you bug-shame them, I will *come for you like* ...
|
|
107
|
-
|
|
108
|
-
nah. Just don't be a dick, okay? Play nice, share, lick a veggie and gentlemen,
|
|
109
|
-
spend fewer than 5 minutes washing your pits, chest, and downstairs and maybe
|
|
110
|
-
give some time to the other parts. Like the parts that walk on things, sit
|
|
111
|
-
on things. Some things that enjoy being sat upon do not enjoy being sat upon
|
|
112
|
-
by gross sitter-upon-things.
|
|
113
|
-
|
|
114
|
-
Also,
|
|
95
|
+
The browser version includes: Collection, Data, Disposer, HTML, Notify, Sass, Tantrum, Type (TypeSpec), Util, and Valid. Node-only modules (Cache, CappedDirectoryObject, Contract, DirectoryObject, FileObject, FS, Glog, Schemer, TempDirectoryObject, Term, Terms) are not available in the browser version.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gesslar/toolkit",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "A collection of utilities for Node.js and browser environments.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./src/types/index.d.ts",
|
|
@@ -50,13 +50,11 @@
|
|
|
50
50
|
"file",
|
|
51
51
|
"directory",
|
|
52
52
|
"data",
|
|
53
|
-
"flavaflav",
|
|
54
|
-
"chuck",
|
|
55
|
-
"norris",
|
|
56
53
|
"validation",
|
|
57
54
|
"typescript",
|
|
58
55
|
"nodejs",
|
|
59
|
-
"
|
|
56
|
+
"browser",
|
|
57
|
+
"node"
|
|
60
58
|
],
|
|
61
59
|
"author": "gesslar",
|
|
62
60
|
"license": "Unlicense",
|
|
@@ -69,7 +67,7 @@
|
|
|
69
67
|
"yaml": "^2.8.2"
|
|
70
68
|
},
|
|
71
69
|
"devDependencies": {
|
|
72
|
-
"@gesslar/uglier": "^0.0.
|
|
70
|
+
"@gesslar/uglier": "^0.0.8",
|
|
73
71
|
"typescript": "^5.9.3"
|
|
74
72
|
}
|
|
75
73
|
}
|
|
@@ -525,7 +525,7 @@ export default class Collection {
|
|
|
525
525
|
/**
|
|
526
526
|
* Allocates an object from a source array and a spec array or function.
|
|
527
527
|
*
|
|
528
|
-
* @param {unknown} source The source array
|
|
528
|
+
* @param {Array<unknown>} source The source array
|
|
529
529
|
* @param {Array<unknown>|function(Array<unknown>): Promise<Array<unknown>>|Array<unknown>} spec The spec array or function
|
|
530
530
|
* @returns {Promise<object>} The allocated object
|
|
531
531
|
*/
|
package/src/lib/FS.js
CHANGED
|
@@ -153,9 +153,8 @@ export default class FS {
|
|
|
153
153
|
const to = path2.split(sep).filter(Boolean)
|
|
154
154
|
|
|
155
155
|
// If they're the same, just return path1
|
|
156
|
-
if(to.length === from.length && from.every((f, i) => to[i] === f))
|
|
156
|
+
if(to.length === from.length && from.every((f, i) => to[i] === f))
|
|
157
157
|
return path1
|
|
158
|
-
}
|
|
159
158
|
|
|
160
159
|
const overlapIndex = from.findLastIndex(curr => curr === to.at(0))
|
|
161
160
|
|
package/src/lib/Util.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {createHash} from "node:crypto"
|
|
2
2
|
import {EventEmitter} from "node:events"
|
|
3
|
-
import Sass from "./Sass.js"
|
|
4
3
|
import {Util as BrowserUtil} from "../browser/index.js"
|
|
4
|
+
import Sass from "./Sass.js"
|
|
5
|
+
import process from "node:process"
|
|
6
|
+
import JSON5 from "json5"
|
|
7
|
+
import Valid from "./Valid.js"
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Utility class providing common helper functions for string manipulation,
|
|
@@ -152,4 +155,45 @@ export default class Util extends BrowserUtil {
|
|
|
152
155
|
)
|
|
153
156
|
}
|
|
154
157
|
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Retrieves an environment variable and parses it as JSON5.
|
|
161
|
+
*
|
|
162
|
+
* This method fetches the value of the specified environment variable and
|
|
163
|
+
* attempts to parse it using JSON5. If the variable doesn't exist or is
|
|
164
|
+
* empty, the default value is returned. If parsing fails, an error is
|
|
165
|
+
* thrown.
|
|
166
|
+
*
|
|
167
|
+
* Example:
|
|
168
|
+
* // export MY_CONFIG='{"debug": true, timeout: 5000}'
|
|
169
|
+
* Util.getEnv("MY_CONFIG", {debug: false})
|
|
170
|
+
* → {debug: true, timeout: 5000}
|
|
171
|
+
*
|
|
172
|
+
* Edge cases:
|
|
173
|
+
* - If the environment variable doesn't exist, returns the default value
|
|
174
|
+
* - If the value is an empty string, returns the default value
|
|
175
|
+
* - If JSON5 parsing fails, throws a Sass error with context
|
|
176
|
+
*
|
|
177
|
+
* @param {string} ev - Name of the environment variable to retrieve
|
|
178
|
+
* @param {unknown} [def=undefined] - Default value if variable doesn't exist or is empty
|
|
179
|
+
* @returns {unknown} Parsed JSON5 value or default
|
|
180
|
+
* @throws {Sass} If JSON5 parsing fails
|
|
181
|
+
*/
|
|
182
|
+
static getEnv(ev, def=undefined) {
|
|
183
|
+
Valid.type(ev, "String")
|
|
184
|
+
|
|
185
|
+
const value = process.env[ev]
|
|
186
|
+
|
|
187
|
+
if(!value)
|
|
188
|
+
return def
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
return JSON5.parse(value)
|
|
192
|
+
} catch(error) {
|
|
193
|
+
throw Sass.new(
|
|
194
|
+
`Failed to parse environment variable '${ev}' as JSON5`,
|
|
195
|
+
error
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
155
199
|
}
|
|
@@ -190,11 +190,11 @@ export default class Collection {
|
|
|
190
190
|
/**
|
|
191
191
|
* Allocates an object from a source array and a spec array or function.
|
|
192
192
|
*
|
|
193
|
-
* @param {unknown} source The source array
|
|
193
|
+
* @param {Array<unknown>} source The source array
|
|
194
194
|
* @param {Array<unknown>|function(Array<unknown>): Promise<Array<unknown>>|Array<unknown>} spec The spec array or function
|
|
195
195
|
* @returns {Promise<object>} The allocated object
|
|
196
196
|
*/
|
|
197
|
-
static allocateObject(source: unknown
|
|
197
|
+
static allocateObject(source: Array<unknown>, spec: Array<unknown> | ((arg0: Array<unknown>) => Promise<Array<unknown>> | Array<unknown>)): Promise<object>;
|
|
198
198
|
/**
|
|
199
199
|
* Trims falsy values from both ends of an array (in-place).
|
|
200
200
|
* Optionally preserves specific falsy values.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../browser/lib/Collection.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH;IACE;;;;;;;;;OASG;IACH,6BANW,KAAK,CAAC,OAAO,CAAC,aACd,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,OAAO,YACjE,OAAO,GACL,OAAO,GAAC,S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O,CAAC,QACd,KAAK,CAAC,OAAO,CAAC,GACZ,KAAK,CAAC,OAAO,CAAC,CAa1B;IAED;;;;;;;;;;;;;;OAcG;IACH,wBAJW,KAAK,CAAC,OAAO,CAAC,QACd,KAAK,CAAC,OAAO,CAAC,GACZ,OAAO,CAanB;IAED;;;;;;;;;OASG;IACH,qBANW,KAAK,CAAC,OAAO,CAAC,UACd,MAAM,SACN,OAAO,aACP,MAAM,GACJ,KAAK,CAAC,OAAO,CAAC,CAyB1B;IAED;;;;;;;OAOG;IACH,wBAJW,KAAK,CAAC,OAAO,CAAC,aACd,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GACxE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAanC;IAED;;;;;;OAMG;IACH,wBAJW,MAAM,WACN,OAAO,GACL,MAAM,CAqBlB;IAED;;;;;OAKG;IACH,0BAHW,MAAM,GACJ,OAAO,CASnB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,QACN,KAAK,CAAC,MAAM,CAAC,GACX,MAAM,CA2BlB;IAED;;;;;;;OAOG;IACH,2BAJW,MAAM,QACN,KAAK,CAAC,MAAM,CAAC,SACb,OAAO,QAiBjB;IAED;;;;;OAKG;IACH,+BAHc,MAAM,EAAA,GACP,MAAM,CAqBlB;IAED;;;;;OAKG;IACH,6BAHW,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;;;;OAOG;IACH,2BALW,MAAM,eACN,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,WAC1B,OAAO,GACL,OAAO,CAAC,MAAM,CAAC,CAe3B;IAED;;;;;;OAMG;IACH,8BAJW,OAAO,
|
|
1
|
+
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../browser/lib/Collection.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH;IACE;;;;;;;;;OASG;IACH,6BAN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C,UAAU,CAAC,CAAC,CAmCtC;IAED;;;;;;;;;;OAUG;IACH,oCAJW,UAAU,GAAC,eAAe,MAC1B,UAAU,GAAC,eAAe,GACxB,MAAM,CAYlB;IAED;;;;;;;;OAQG;IACH,oCALW,MAAM,SACN,MAAM,QACN,MAAM,GACJ,MAAM,
|
|
1
|
+
{"version":3,"file":"FS.d.ts","sourceRoot":"","sources":["../../lib/FS.js"],"names":[],"mappings":"AAwBA;;GAEG;AACH;IACE,kCAAwB;IACxB,uCAAkC;IAClC,mBAAsB;IAEtB;;;;;;OAMG;IACH,4BAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAUlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;;OAQG;IACH,sBALW,MAAM,GAAC,KAAK,CAAC,MAAM,CAAC,GAClB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAmCtC;IAED;;;;;;;;;;OAUG;IACH,oCAJW,UAAU,GAAC,eAAe,MAC1B,UAAU,GAAC,eAAe,GACxB,MAAM,CAYlB;IAED;;;;;;;;OAQG;IACH,oCALW,MAAM,SACN,MAAM,QACN,MAAM,GACJ,MAAM,CA0BlB;IAED;;;;;;;;OAQG;IACH,6BAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAgClB;CACF;yBAxMa,OAAO,iBAAiB,EAAE,OAAO;8BACjC,OAAO,sBAAsB,EAAE,OAAO"}
|
package/src/types/lib/Util.d.ts
CHANGED
|
@@ -71,6 +71,30 @@ export default class Util extends BrowserUtil {
|
|
|
71
71
|
* @returns {Promise<void>} Resolves when all listeners have completed, but no grapes.
|
|
72
72
|
*/
|
|
73
73
|
static asyncEmitQuack(emitter: object, event: string, ...args: unknown[]): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Retrieves an environment variable and parses it as JSON5.
|
|
76
|
+
*
|
|
77
|
+
* This method fetches the value of the specified environment variable and
|
|
78
|
+
* attempts to parse it using JSON5. If the variable doesn't exist or is
|
|
79
|
+
* empty, the default value is returned. If parsing fails, an error is
|
|
80
|
+
* thrown.
|
|
81
|
+
*
|
|
82
|
+
* Example:
|
|
83
|
+
* // export MY_CONFIG='{"debug": true, timeout: 5000}'
|
|
84
|
+
* Util.getEnv("MY_CONFIG", {debug: false})
|
|
85
|
+
* → {debug: true, timeout: 5000}
|
|
86
|
+
*
|
|
87
|
+
* Edge cases:
|
|
88
|
+
* - If the environment variable doesn't exist, returns the default value
|
|
89
|
+
* - If the value is an empty string, returns the default value
|
|
90
|
+
* - If JSON5 parsing fails, throws a Sass error with context
|
|
91
|
+
*
|
|
92
|
+
* @param {string} ev - Name of the environment variable to retrieve
|
|
93
|
+
* @param {unknown} [def=undefined] - Default value if variable doesn't exist or is empty
|
|
94
|
+
* @returns {unknown} Parsed JSON5 value or default
|
|
95
|
+
* @throws {Sass} If JSON5 parsing fails
|
|
96
|
+
*/
|
|
97
|
+
static getEnv(ev: string, def?: unknown): unknown;
|
|
74
98
|
}
|
|
75
99
|
import { Util as BrowserUtil } from "../browser/index.js";
|
|
76
100
|
//# sourceMappingURL=Util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../lib/Util.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../lib/Util.js"],"names":[],"mappings":"AAQA;;;GAGG;AACH;IACE;;;;;OAKG;IACH,iBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,mCAHW,MAAM,GACJ,KAAK,CAAC,MAAM,CAAC,CAazB;IAED;;;;;;;;OAQG;IACH,+CALW,MAAM,SACN,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAmBzB;IAED;;;;;;;;;;;;OAYG;IACH,0BALW,YAAY,SACZ,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAqBzB;IAED;;;;;;;;;;OAUG;IACH,+BALW,MAAM,SACN,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAyBzB;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,kBALW,MAAM,QACN,OAAO,GACL,OAAO,CAmBnB;CACF;oCApMiC,qBAAqB"}
|