@gesslar/toolkit 3.37.0 → 3.38.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/package.json +1 -1
- package/src/node/lib/DirectoryObject.js +57 -0
- package/src/node/lib/FileObject.js +55 -0
- package/types/node/lib/DirectoryObject.d.ts +31 -0
- package/types/node/lib/DirectoryObject.d.ts.map +1 -1
- package/types/node/lib/FileObject.d.ts +31 -0
- package/types/node/lib/FileObject.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import {glob, mkdir, opendir, readdir, rmdir, stat} from "node:fs/promises"
|
|
8
8
|
import path, {relative} from "node:path"
|
|
9
9
|
import {URL} from "node:url"
|
|
10
|
+
import {inspect} from "node:util"
|
|
10
11
|
|
|
11
12
|
import Data from "../../browser/lib/Data.js"
|
|
12
13
|
import FileObject from "./FileObject.js"
|
|
@@ -158,6 +159,62 @@ export default class DirectoryObject extends FS {
|
|
|
158
159
|
return `[${this.constructor.name}: ${this.path}]`
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Returns a JSON-serializable representation of the DirectoryObject.
|
|
164
|
+
*
|
|
165
|
+
* @returns {object} Plain object with directory metadata
|
|
166
|
+
*/
|
|
167
|
+
toJSON() {
|
|
168
|
+
return {
|
|
169
|
+
supplied: this.supplied,
|
|
170
|
+
path: this.path,
|
|
171
|
+
name: this.name,
|
|
172
|
+
module: this.module,
|
|
173
|
+
extension: this.extension,
|
|
174
|
+
isDirectory: this.isDirectory,
|
|
175
|
+
parentPath: this.#meta.parentPath,
|
|
176
|
+
sep: this.sep,
|
|
177
|
+
trail: this.trail,
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Custom Node.js inspect implementation for console.log output.
|
|
183
|
+
*
|
|
184
|
+
* @param {number} depth - Inspection depth
|
|
185
|
+
* @param {object} options - Inspect options
|
|
186
|
+
* @param {Function} ins - The inspect function
|
|
187
|
+
* @returns {string} Formatted string representation
|
|
188
|
+
*/
|
|
189
|
+
[inspect.custom](depth, options, ins) {
|
|
190
|
+
return `${this.constructor.name} ${ins(this.toJSON(), options)}`
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Returns the directory path as a primitive value, enabling natural use in
|
|
195
|
+
* string contexts. String and default hints return the directory path; number
|
|
196
|
+
* hint returns NaN.
|
|
197
|
+
*
|
|
198
|
+
* @param {"string"|"number"|"default"} hint - The coercion type hint
|
|
199
|
+
* @returns {string|number} The directory path, or NaN for numeric coercion
|
|
200
|
+
*/
|
|
201
|
+
[Symbol.toPrimitive](hint) {
|
|
202
|
+
if(hint === "number") {
|
|
203
|
+
return NaN
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return this.path
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Returns the directory path as a primitive string value.
|
|
211
|
+
*
|
|
212
|
+
* @returns {string} The directory path
|
|
213
|
+
*/
|
|
214
|
+
valueOf() {
|
|
215
|
+
return this.path
|
|
216
|
+
}
|
|
217
|
+
|
|
161
218
|
/**
|
|
162
219
|
* Checks if the directory exists (async).
|
|
163
220
|
*
|
|
@@ -9,6 +9,7 @@ import fs from "node:fs/promises"
|
|
|
9
9
|
import YAML from "yaml"
|
|
10
10
|
import {URL} from "node:url"
|
|
11
11
|
import {Buffer} from "node:buffer"
|
|
12
|
+
import {inspect} from "node:util"
|
|
12
13
|
|
|
13
14
|
import Data from "../../browser/lib/Data.js"
|
|
14
15
|
import DirectoryObject from "./DirectoryObject.js"
|
|
@@ -147,6 +148,60 @@ export default class FileObject extends FS {
|
|
|
147
148
|
return `[${this.constructor.name}: ${this.path}]`
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Returns a JSON-serializable representation of the FileObject.
|
|
153
|
+
*
|
|
154
|
+
* @returns {object} Plain object with file metadata
|
|
155
|
+
*/
|
|
156
|
+
toJSON() {
|
|
157
|
+
return {
|
|
158
|
+
supplied: this.supplied,
|
|
159
|
+
path: this.path,
|
|
160
|
+
name: this.name,
|
|
161
|
+
module: this.module,
|
|
162
|
+
extension: this.extension,
|
|
163
|
+
isFile: this.isFile,
|
|
164
|
+
parentPath: this.parentPath,
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Custom Node.js inspect implementation for console.log output.
|
|
170
|
+
*
|
|
171
|
+
* @param {number} depth - Inspection depth
|
|
172
|
+
* @param {object} options - Inspect options
|
|
173
|
+
* @param {Function} ins - The inspect function
|
|
174
|
+
* @returns {string} Formatted string representation
|
|
175
|
+
*/
|
|
176
|
+
[inspect.custom](depth, options, ins) {
|
|
177
|
+
return `${this.constructor.name} ${ins(this.toJSON(), options)}`
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Returns the file path as a primitive value, enabling natural use in
|
|
182
|
+
* string contexts. String and default hints return the file path; number
|
|
183
|
+
* hint returns NaN.
|
|
184
|
+
*
|
|
185
|
+
* @param {"string"|"number"|"default"} hint - The coercion type hint
|
|
186
|
+
* @returns {string|number} The file path, or NaN for numeric coercion
|
|
187
|
+
*/
|
|
188
|
+
[Symbol.toPrimitive](hint) {
|
|
189
|
+
if(hint === "number") {
|
|
190
|
+
return NaN
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return this.path
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Returns the file path as a primitive string value.
|
|
198
|
+
*
|
|
199
|
+
* @returns {string} The file path
|
|
200
|
+
*/
|
|
201
|
+
valueOf() {
|
|
202
|
+
return this.path
|
|
203
|
+
}
|
|
204
|
+
|
|
150
205
|
/**
|
|
151
206
|
* Checks if the file exists (async).
|
|
152
207
|
*
|
|
@@ -80,6 +80,18 @@ export default class DirectoryObject extends FS {
|
|
|
80
80
|
* @param {string?} [supplied="."] - The directory path (defaults to current directory)
|
|
81
81
|
*/
|
|
82
82
|
constructor(supplied?: string | null);
|
|
83
|
+
/**
|
|
84
|
+
* Returns a JSON-serializable representation of the DirectoryObject.
|
|
85
|
+
*
|
|
86
|
+
* @returns {object} Plain object with directory metadata
|
|
87
|
+
*/
|
|
88
|
+
toJSON(): object;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the directory path as a primitive string value.
|
|
91
|
+
*
|
|
92
|
+
* @returns {string} The directory path
|
|
93
|
+
*/
|
|
94
|
+
valueOf(): string;
|
|
83
95
|
/**
|
|
84
96
|
* Checks if the directory exists (async).
|
|
85
97
|
*
|
|
@@ -322,6 +334,24 @@ export default class DirectoryObject extends FS {
|
|
|
322
334
|
* console.log(escaped.path) // "/projects/git/toolkit/foo/bar.js"
|
|
323
335
|
*/
|
|
324
336
|
getFile(filename: string): FileObject;
|
|
337
|
+
/**
|
|
338
|
+
* Custom Node.js inspect implementation for console.log output.
|
|
339
|
+
*
|
|
340
|
+
* @param {number} depth - Inspection depth
|
|
341
|
+
* @param {object} options - Inspect options
|
|
342
|
+
* @param {Function} ins - The inspect function
|
|
343
|
+
* @returns {string} Formatted string representation
|
|
344
|
+
*/
|
|
345
|
+
[inspect.custom](depth: number, options: object, ins: Function): string;
|
|
346
|
+
/**
|
|
347
|
+
* Returns the directory path as a primitive value, enabling natural use in
|
|
348
|
+
* string contexts. String and default hints return the directory path; number
|
|
349
|
+
* hint returns NaN.
|
|
350
|
+
*
|
|
351
|
+
* @param {"string"|"number"|"default"} hint - The coercion type hint
|
|
352
|
+
* @returns {string|number} The directory path, or NaN for numeric coercion
|
|
353
|
+
*/
|
|
354
|
+
[Symbol.toPrimitive](hint: "string" | "number" | "default"): string | number;
|
|
325
355
|
#private;
|
|
326
356
|
}
|
|
327
357
|
export type GeneratorType = {
|
|
@@ -380,4 +410,5 @@ export type DirectoryMeta = {
|
|
|
380
410
|
import FS from "./FileSystem.js";
|
|
381
411
|
import { URL } from "node:url";
|
|
382
412
|
import FileObject from "./FileObject.js";
|
|
413
|
+
import { inspect } from "node:util";
|
|
383
414
|
//# sourceMappingURL=DirectoryObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/DirectoryObject.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/DirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH;IAuDE;;;;;;;;;OASG;IACH,kBALa,eAAe,CAO3B;IA7CD;;;;OAIG;IACH,uBAFW,MAAM,OAAC,EA4BjB;IAyBD;;;;OAIG;IACH,UAFa,MAAM,CAclB;IA8BD;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,GAAG,CAIf;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,aALa,KAAK,CAAC,MAAM,CAAC,CAOzB;IAED;;;;;;;;;;;;OAYG;IACH,cARa,eAAe,GAAC,IAAI,CAsBhC;IAED;;;;OAIG;IACH,mBAFa,OAAO,CAInB;IAmBD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAZW,MAAM,iBACJ,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,WAAW,EAAE,KA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AAM,GAAC,IAAI;;;;WACX,KAAK,CAAC,MAAM,CAAC,GAAC,IAAI;;;;SAClB,GAAG,GAAC,IAAI;;eAvBP,iBAAiB;oBALd,UAAU;uBAIL,iBAAiB;wBAHlB,WAAW"}
|
|
@@ -42,6 +42,18 @@ export default class FileObject extends FS {
|
|
|
42
42
|
* @param {DirectoryObject|string|null} [parent] - The parent directory (object or string)
|
|
43
43
|
*/
|
|
44
44
|
constructor(submitted: string, parent?: DirectoryObject | string | null);
|
|
45
|
+
/**
|
|
46
|
+
* Returns a JSON-serializable representation of the FileObject.
|
|
47
|
+
*
|
|
48
|
+
* @returns {object} Plain object with file metadata
|
|
49
|
+
*/
|
|
50
|
+
toJSON(): object;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the file path as a primitive string value.
|
|
53
|
+
*
|
|
54
|
+
* @returns {string} The file path
|
|
55
|
+
*/
|
|
56
|
+
valueOf(): string;
|
|
45
57
|
/**
|
|
46
58
|
* Checks if the file exists (async).
|
|
47
59
|
*
|
|
@@ -249,12 +261,31 @@ export default class FileObject extends FS {
|
|
|
249
261
|
* await file.delete()
|
|
250
262
|
*/
|
|
251
263
|
delete(): Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Custom Node.js inspect implementation for console.log output.
|
|
266
|
+
*
|
|
267
|
+
* @param {number} depth - Inspection depth
|
|
268
|
+
* @param {object} options - Inspect options
|
|
269
|
+
* @param {Function} ins - The inspect function
|
|
270
|
+
* @returns {string} Formatted string representation
|
|
271
|
+
*/
|
|
272
|
+
[inspect.custom](depth: number, options: object, ins: Function): string;
|
|
273
|
+
/**
|
|
274
|
+
* Returns the file path as a primitive value, enabling natural use in
|
|
275
|
+
* string contexts. String and default hints return the file path; number
|
|
276
|
+
* hint returns NaN.
|
|
277
|
+
*
|
|
278
|
+
* @param {"string"|"number"|"default"} hint - The coercion type hint
|
|
279
|
+
* @returns {string|number} The file path, or NaN for numeric coercion
|
|
280
|
+
*/
|
|
281
|
+
[Symbol.toPrimitive](hint: "string" | "number" | "default"): string | number;
|
|
252
282
|
#private;
|
|
253
283
|
}
|
|
254
284
|
import FS from "./FileSystem.js";
|
|
255
285
|
import { URL } from "node:url";
|
|
256
286
|
import DirectoryObject from "./DirectoryObject.js";
|
|
257
287
|
import { Buffer } from "node:buffer";
|
|
288
|
+
import { inspect } from "node:util";
|
|
258
289
|
import JSON5 from "json5";
|
|
259
290
|
import YAML from "yaml";
|
|
260
291
|
//# sourceMappingURL=FileObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;GAaG;AAEH;IACE;;;;;OAKG;IACH,yBAFU;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,GAAG,OAAO,IAAI,CAAC,CAAA;KAAC,CAO1D;IAskBF;;;;;;;;;;;OAWG;IACH,kBAPa,UAAU,CAsCtB;IAvlBD;;;;;OAKG;IACH,uBAHW,MAAM,WACN,eAAe,GAAC,MAAM,GAAC,IAAI,EA+DrC;IAWD;;;;OAIG;IACH,UAFa,MAAM,CAYlB;IA8BD;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,GAAG,CAIf;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAFa,MAAM,CAIlB;IACD;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;;;;;;;;;;;OAcG;I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