@gesslar/toolkit 0.7.0 → 0.7.1
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 +2 -2
- package/src/lib/DirectoryObject.js +43 -19
- package/src/lib/FileObject.js +43 -20
- package/src/lib/Logger.js +1 -1
- package/src/lib/Util.js +3 -2
- package/src/types/lib/Chide.d.ts +37 -0
- package/src/types/lib/Chide.d.ts.map +1 -0
- package/src/types/lib/DirectoryObject.d.ts +21 -4
- package/src/types/lib/DirectoryObject.d.ts.map +1 -1
- package/src/types/lib/FileObject.d.ts +20 -8
- package/src/types/lib/FileObject.d.ts.map +1 -1
- package/src/types/lib/TypeSpec.d.ts +1 -1
- package/src/types/lib/TypeSpec.d.ts.map +1 -1
- package/src/types/lib/Util.d.ts +2 -1
- package/src/types/lib/Util.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gesslar/toolkit",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Get in, bitches, we're going toolkitting.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=22"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"types:build": "tsc -p tsconfig.types.json",
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import fs from "node:fs/promises"
|
|
8
8
|
import path from "node:path"
|
|
9
9
|
import util from "node:util"
|
|
10
|
+
import {URL} from "node:url"
|
|
10
11
|
|
|
11
12
|
import FS from "./FS.js"
|
|
12
13
|
import FileObject from "./FileObject.js"
|
|
@@ -18,7 +19,7 @@ import Sass from "./Sass.js"
|
|
|
18
19
|
*
|
|
19
20
|
* @property {string} supplied - The supplied directory
|
|
20
21
|
* @property {string} path - The resolved path
|
|
21
|
-
* @property {
|
|
22
|
+
* @property {URL} url - The directory URL
|
|
22
23
|
* @property {string} name - The directory name
|
|
23
24
|
* @property {string} module - The directory name without extension
|
|
24
25
|
* @property {string} extension - The directory extension (usually empty)
|
|
@@ -32,7 +33,7 @@ export default class DirectoryObject extends FS {
|
|
|
32
33
|
* @private
|
|
33
34
|
* @property {string|null} supplied - User-supplied path
|
|
34
35
|
* @property {string|null} path - The absolute file path
|
|
35
|
-
* @property {
|
|
36
|
+
* @property {URL|null} url - The file URL
|
|
36
37
|
* @property {string|null} name - The file name
|
|
37
38
|
* @property {string|null} module - The file name without extension
|
|
38
39
|
* @property {string|null} extension - The file extension
|
|
@@ -42,7 +43,7 @@ export default class DirectoryObject extends FS {
|
|
|
42
43
|
#meta = Object.seal({
|
|
43
44
|
supplied: null,
|
|
44
45
|
path: null,
|
|
45
|
-
|
|
46
|
+
url: null,
|
|
46
47
|
name: null,
|
|
47
48
|
module: null,
|
|
48
49
|
extension: null,
|
|
@@ -61,16 +62,15 @@ export default class DirectoryObject extends FS {
|
|
|
61
62
|
super()
|
|
62
63
|
|
|
63
64
|
const fixedDir = FS.fixSlashes(directory ?? ".")
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const trail = filePath.split(path.sep)
|
|
65
|
+
const resolved = path.resolve(fixedDir)
|
|
66
|
+
const url = new URL(FS.pathToUri(resolved))
|
|
67
|
+
const baseName = path.basename(resolved) || "."
|
|
68
|
+
const trail = resolved.split(path.sep)
|
|
69
69
|
const sep = path.sep
|
|
70
70
|
|
|
71
71
|
this.#meta.supplied = fixedDir
|
|
72
|
-
this.#meta.path =
|
|
73
|
-
this.#meta.
|
|
72
|
+
this.#meta.path = resolved
|
|
73
|
+
this.#meta.url = url
|
|
74
74
|
this.#meta.name = baseName
|
|
75
75
|
this.#meta.extension = ""
|
|
76
76
|
this.#meta.module = baseName
|
|
@@ -98,7 +98,7 @@ export default class DirectoryObject extends FS {
|
|
|
98
98
|
return {
|
|
99
99
|
supplied: this.supplied,
|
|
100
100
|
path: this.path,
|
|
101
|
-
|
|
101
|
+
url: this.url.toString(),
|
|
102
102
|
name: this.name,
|
|
103
103
|
module: this.module,
|
|
104
104
|
extension: this.extension,
|
|
@@ -144,12 +144,12 @@ export default class DirectoryObject extends FS {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
|
-
* Returns the
|
|
147
|
+
* Returns the URL of the current directory.
|
|
148
148
|
*
|
|
149
|
-
* @returns {
|
|
149
|
+
* @returns {URL} The directory URL
|
|
150
150
|
*/
|
|
151
|
-
get
|
|
152
|
-
return this.#meta.
|
|
151
|
+
get url() {
|
|
152
|
+
return this.#meta.url
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
@@ -239,10 +239,7 @@ export default class DirectoryObject extends FS {
|
|
|
239
239
|
* @returns {Promise<{files: Array<FileObject>, directories: Array<DirectoryObject>}>} The files and directories in the directory.
|
|
240
240
|
*/
|
|
241
241
|
async read() {
|
|
242
|
-
const found = await fs.readdir(
|
|
243
|
-
new URL(this.uri),
|
|
244
|
-
{withFileTypes: true}
|
|
245
|
-
)
|
|
242
|
+
const found = await fs.readdir(this.url, {withFileTypes: true})
|
|
246
243
|
|
|
247
244
|
const files = found
|
|
248
245
|
.filter(dirent => dirent.isFile())
|
|
@@ -331,4 +328,31 @@ export default class DirectoryObject extends FS {
|
|
|
331
328
|
get walkUp() {
|
|
332
329
|
return this.#walkUp()
|
|
333
330
|
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Deletes an empty directory from the filesystem.
|
|
334
|
+
*
|
|
335
|
+
* Recursive deletion is intentionally not supported. If you need to delete
|
|
336
|
+
* a directory with contents, you must imperatively decide your deletion
|
|
337
|
+
* strategy and handle it explicitly.
|
|
338
|
+
*
|
|
339
|
+
* @returns {Promise<void>} Resolves when directory is deleted
|
|
340
|
+
* @throws {Sass} If the directory URL is invalid
|
|
341
|
+
* @throws {Sass} If the directory does not exist
|
|
342
|
+
* @throws {Error} If the directory is not empty (from fs.rmdir)
|
|
343
|
+
* @example
|
|
344
|
+
* const dir = new DirectoryObject('./temp/cache')
|
|
345
|
+
* await dir.delete() // Only works if directory is empty
|
|
346
|
+
*/
|
|
347
|
+
async delete() {
|
|
348
|
+
const dirPath = this.path
|
|
349
|
+
|
|
350
|
+
if(!dirPath)
|
|
351
|
+
throw Sass.new("This object does not represent a valid resource.")
|
|
352
|
+
|
|
353
|
+
if(!(await this.exists))
|
|
354
|
+
throw Sass.new(`No such resource '${this.url.href}'`)
|
|
355
|
+
|
|
356
|
+
return await fs.rmdir(this.path)
|
|
357
|
+
}
|
|
334
358
|
}
|
package/src/lib/FileObject.js
CHANGED
|
@@ -9,6 +9,7 @@ import fs from "node:fs/promises"
|
|
|
9
9
|
import path from "node:path"
|
|
10
10
|
import util from "node:util"
|
|
11
11
|
import YAML from "yaml"
|
|
12
|
+
import {URL} from "node:url"
|
|
12
13
|
|
|
13
14
|
import Data from "./Data.js"
|
|
14
15
|
import DirectoryObject from "./DirectoryObject.js"
|
|
@@ -22,7 +23,7 @@ import Valid from "./Valid.js"
|
|
|
22
23
|
*
|
|
23
24
|
* @property {string} supplied - User-supplied path
|
|
24
25
|
* @property {string} path - The absolute file path
|
|
25
|
-
* @property {
|
|
26
|
+
* @property {URL} url - The file URL
|
|
26
27
|
* @property {string} name - The file name
|
|
27
28
|
* @property {string} module - The file name without extension
|
|
28
29
|
* @property {string} extension - The file extension
|
|
@@ -51,7 +52,7 @@ export default class FileObject extends FS {
|
|
|
51
52
|
* @private
|
|
52
53
|
* @property {string|null} supplied - User-supplied path
|
|
53
54
|
* @property {string|null} path - The absolute file path
|
|
54
|
-
* @property {
|
|
55
|
+
* @property {URL|null} url - The file URL
|
|
55
56
|
* @property {string|null} name - The file name
|
|
56
57
|
* @property {string|null} module - The file name without extension
|
|
57
58
|
* @property {string|null} extension - The file extension
|
|
@@ -62,7 +63,7 @@ export default class FileObject extends FS {
|
|
|
62
63
|
#meta = Object.seal({
|
|
63
64
|
supplied: null,
|
|
64
65
|
path: null,
|
|
65
|
-
|
|
66
|
+
url: null,
|
|
66
67
|
name: null,
|
|
67
68
|
module: null,
|
|
68
69
|
extension: null,
|
|
@@ -102,11 +103,11 @@ export default class FileObject extends FS {
|
|
|
102
103
|
const final = FS.resolvePath(directoryObject.path ?? ".", fixedFile)
|
|
103
104
|
|
|
104
105
|
const resolved = final
|
|
105
|
-
const
|
|
106
|
+
const url = new URL(FS.pathToUri(resolved))
|
|
106
107
|
|
|
107
108
|
this.#meta.supplied = fixedFile
|
|
108
109
|
this.#meta.path = resolved
|
|
109
|
-
this.#meta.
|
|
110
|
+
this.#meta.url = url
|
|
110
111
|
this.#meta.name = base
|
|
111
112
|
this.#meta.extension = ext
|
|
112
113
|
this.#meta.module = path.basename(this.supplied, this.extension)
|
|
@@ -133,7 +134,7 @@ export default class FileObject extends FS {
|
|
|
133
134
|
return {
|
|
134
135
|
supplied: this.supplied,
|
|
135
136
|
path: this.path,
|
|
136
|
-
|
|
137
|
+
url: this.url.toString(),
|
|
137
138
|
name: this.name,
|
|
138
139
|
module: this.module,
|
|
139
140
|
extension: this.extension,
|
|
@@ -162,30 +163,30 @@ export default class FileObject extends FS {
|
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
/**
|
|
165
|
-
* Return the
|
|
166
|
+
* Return the normalized path that was provided to the constructor.
|
|
166
167
|
*
|
|
167
|
-
* @returns {string} The file path
|
|
168
|
+
* @returns {string} The sanitized user-supplied file path
|
|
168
169
|
*/
|
|
169
170
|
get supplied() {
|
|
170
171
|
return this.#meta.supplied
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
/**
|
|
174
|
-
* Return the resolved path
|
|
175
|
+
* Return the fully resolved absolute path to the file on disk.
|
|
175
176
|
*
|
|
176
|
-
* @returns {string} The file path
|
|
177
|
+
* @returns {string} The fully resolved absolute file path
|
|
177
178
|
*/
|
|
178
179
|
get path() {
|
|
179
180
|
return this.#meta.path
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
/**
|
|
183
|
-
* Returns the
|
|
184
|
+
* Returns the URL of the current file.
|
|
184
185
|
*
|
|
185
|
-
* @returns {
|
|
186
|
+
* @returns {URL} The file URL
|
|
186
187
|
*/
|
|
187
|
-
get
|
|
188
|
-
return this.#meta.
|
|
188
|
+
get url() {
|
|
189
|
+
return this.#meta.url
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
/**
|
|
@@ -385,7 +386,7 @@ export default class FileObject extends FS {
|
|
|
385
386
|
await fs.writeFile(this.path, content, encoding)
|
|
386
387
|
|
|
387
388
|
else
|
|
388
|
-
throw Sass.new(`Invalid directory, ${this.directory.
|
|
389
|
+
throw Sass.new(`Invalid directory, ${this.directory.url.href}`)
|
|
389
390
|
}
|
|
390
391
|
|
|
391
392
|
/**
|
|
@@ -436,14 +437,36 @@ export default class FileObject extends FS {
|
|
|
436
437
|
* @returns {Promise<object>} The file contents as a module.
|
|
437
438
|
*/
|
|
438
439
|
async import() {
|
|
439
|
-
const
|
|
440
|
+
const url = this.url
|
|
440
441
|
|
|
441
|
-
if(!
|
|
442
|
-
throw Sass.new("No
|
|
442
|
+
if(!url)
|
|
443
|
+
throw Sass.new("No URL in file map")
|
|
443
444
|
|
|
444
445
|
if(!(await this.exists))
|
|
445
|
-
throw Sass.new(`No such file '${
|
|
446
|
+
throw Sass.new(`No such file '${url.href}'`)
|
|
446
447
|
|
|
447
|
-
return await import(
|
|
448
|
+
return await import(url.href)
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Deletes the file from the filesystem.
|
|
453
|
+
*
|
|
454
|
+
* @returns {Promise<void>} Resolves when file is deleted
|
|
455
|
+
* @throws {Sass} If the file URL is invalid
|
|
456
|
+
* @throws {Sass} If the file does not exist
|
|
457
|
+
* @example
|
|
458
|
+
* const file = new FileObject('./temp/data.json')
|
|
459
|
+
* await file.delete()
|
|
460
|
+
*/
|
|
461
|
+
async delete() {
|
|
462
|
+
const filePath = this.path
|
|
463
|
+
|
|
464
|
+
if(!filePath)
|
|
465
|
+
throw Sass.new("This object does not represent a valid resource.")
|
|
466
|
+
|
|
467
|
+
if(!(await this.exists))
|
|
468
|
+
throw Sass.new(`No such resource '${this.url.href}'`)
|
|
469
|
+
|
|
470
|
+
return await fs.unlink(this.path)
|
|
448
471
|
}
|
|
449
472
|
}
|
package/src/lib/Logger.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
options { depth: 0, colors: false, compact: 3 }.
|
|
9
9
|
* %d: Number will be used to convert all values except BigInt and Symbol.
|
|
10
10
|
* %i: parseInt(value, 10) is used for all values except BigInt and Symbol.
|
|
11
|
-
* %f: parseFloat(value) is used for all values
|
|
11
|
+
* %f: parseFloat(value) is used for all values except Symbol.
|
|
12
12
|
* %j: JSON. Replaced with the string '[Circular]' if the argument contains
|
|
13
13
|
circular references.
|
|
14
14
|
* %o: Object. A string representation of an object with generic JavaScript
|
package/src/lib/Util.js
CHANGED
|
@@ -290,13 +290,14 @@ export default class Util {
|
|
|
290
290
|
* Emits an event asynchronously and waits for all listeners to complete.
|
|
291
291
|
* Like asyncEmit, but uses duck typing for more flexible emitter validation.
|
|
292
292
|
* Accepts any object that has the required EventEmitter-like methods.
|
|
293
|
+
* If it walks like an EventEmitter and quacks like an EventEmitter...
|
|
293
294
|
*
|
|
294
295
|
* @param {object} emitter - Any object with EventEmitter-like interface
|
|
295
296
|
* @param {string} event - The event name to emit
|
|
296
297
|
* @param {...unknown} args - Arguments to pass to event listeners
|
|
297
|
-
* @returns {Promise<void>} Resolves when all listeners have completed
|
|
298
|
+
* @returns {Promise<void>} Resolves when all listeners have completed, but no grapes.
|
|
298
299
|
*/
|
|
299
|
-
static async
|
|
300
|
+
static async asyncEmitQuack(emitter, event, ...args) {
|
|
300
301
|
try {
|
|
301
302
|
if(!emitter ||
|
|
302
303
|
typeof emitter.listeners !== "function" ||
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error class for toolkit errors.
|
|
3
|
+
* Provides error chaining, trace management, and formatted error reporting.
|
|
4
|
+
*/
|
|
5
|
+
export default class Chide extends Sass {
|
|
6
|
+
/**
|
|
7
|
+
* Creates an Chide from an existing Error object with additional
|
|
8
|
+
* trace message.
|
|
9
|
+
*
|
|
10
|
+
* @param {Error} error - The original error object
|
|
11
|
+
* @param {string} message - Additional trace message to add
|
|
12
|
+
* @returns {Chide} New Chide instance with trace from the original error
|
|
13
|
+
* @throws {Chide} If the first parameter is not an Error instance
|
|
14
|
+
*/
|
|
15
|
+
static from(error: Error, message: string): Chide;
|
|
16
|
+
/**
|
|
17
|
+
* Factory method to create or enhance Sass instances.
|
|
18
|
+
* If error parameter is provided, enhances existing Sass or wraps
|
|
19
|
+
* other errors. Otherwise creates a new Sass instance.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} message - The error message
|
|
22
|
+
* @param {Error|Sass|Tantrum|Chide} [error] - Optional existing error to wrap or enhance
|
|
23
|
+
* @returns {Chide} New or enhanced Sass instance
|
|
24
|
+
*/
|
|
25
|
+
static "new"(message: string, error?: Error | Sass | Tantrum | Chide): Chide;
|
|
26
|
+
/**
|
|
27
|
+
* Adds a trace message and returns this instance for chaining.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} message - The trace message to add
|
|
30
|
+
* @returns {this} This Chide instance for method chaining
|
|
31
|
+
*/
|
|
32
|
+
addTrace(message: string): this;
|
|
33
|
+
#private;
|
|
34
|
+
}
|
|
35
|
+
import Sass from "./Sass.js";
|
|
36
|
+
import Tantrum from "./Tantrum.js";
|
|
37
|
+
//# sourceMappingURL=Chide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chide.d.ts","sourceRoot":"","sources":["../../lib/Chide.js"],"names":[],"mappings":"AAkBA;;;GAGG;AACH;IA2GE;;;;;;;;OAQG;IACH,mBALW,KAAK,WACL,MAAM,GACJ,KAAK,CAWjB;IAED;;;;;;;;OAQG;IACH,sBAJW,MAAM,UACN,KAAK,GAAC,IAAI,GAAC,OAAO,GAAC,KAAK,GACtB,KAAK,CAWjB;IA/GD;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,IAAI,CAShB;;CAmGF;iBAzJgB,WAAW;oBAER,cAAc"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @property {string} supplied - The supplied directory
|
|
6
6
|
* @property {string} path - The resolved path
|
|
7
|
-
* @property {
|
|
7
|
+
* @property {URL} url - The directory URL
|
|
8
8
|
* @property {string} name - The directory name
|
|
9
9
|
* @property {string} module - The directory name without extension
|
|
10
10
|
* @property {string} extension - The directory extension (usually empty)
|
|
@@ -44,11 +44,11 @@ export default class DirectoryObject extends FS {
|
|
|
44
44
|
*/
|
|
45
45
|
get path(): string;
|
|
46
46
|
/**
|
|
47
|
-
* Returns the
|
|
47
|
+
* Returns the URL of the current directory.
|
|
48
48
|
*
|
|
49
|
-
* @returns {
|
|
49
|
+
* @returns {URL} The directory URL
|
|
50
50
|
*/
|
|
51
|
-
get
|
|
51
|
+
get url(): URL;
|
|
52
52
|
/**
|
|
53
53
|
* Returns the directory name with extension (if any) without the path.
|
|
54
54
|
*
|
|
@@ -134,6 +134,22 @@ export default class DirectoryObject extends FS {
|
|
|
134
134
|
* }
|
|
135
135
|
*/
|
|
136
136
|
get walkUp(): object;
|
|
137
|
+
/**
|
|
138
|
+
* Deletes an empty directory from the filesystem.
|
|
139
|
+
*
|
|
140
|
+
* Recursive deletion is intentionally not supported. If you need to delete
|
|
141
|
+
* a directory with contents, you must imperatively decide your deletion
|
|
142
|
+
* strategy and handle it explicitly.
|
|
143
|
+
*
|
|
144
|
+
* @returns {Promise<void>} Resolves when directory is deleted
|
|
145
|
+
* @throws {Sass} If the directory URL is invalid
|
|
146
|
+
* @throws {Sass} If the directory does not exist
|
|
147
|
+
* @throws {Error} If the directory is not empty (from fs.rmdir)
|
|
148
|
+
* @example
|
|
149
|
+
* const dir = new DirectoryObject('./temp/cache')
|
|
150
|
+
* await dir.delete() // Only works if directory is empty
|
|
151
|
+
*/
|
|
152
|
+
delete(): Promise<void>;
|
|
137
153
|
/**
|
|
138
154
|
* Custom inspect method for Node.js console.
|
|
139
155
|
*
|
|
@@ -143,6 +159,7 @@ export default class DirectoryObject extends FS {
|
|
|
143
159
|
#private;
|
|
144
160
|
}
|
|
145
161
|
import FS from "./FS.js";
|
|
162
|
+
import { URL } from "node:url";
|
|
146
163
|
import FileObject from "./FileObject.js";
|
|
147
164
|
import util from "node:util";
|
|
148
165
|
//# sourceMappingURL=DirectoryObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/DirectoryObject.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/DirectoryObject.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;GAaG;AACH;IA0BE;;;;OAIG;IACH,uBAFW,MAAM,EAsBhB;IAWD;;;;OAIG;IACH,UAFa,MAAM,CAalB;IAWD;;;;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;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,mBAFa,OAAO,CAInB;IAiBD;;;;OAIG;IACH,QAFa,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,WAAW,EAAE,KAAK,CAAC,eAAe,CAAC,CAAA;KAAC,CAAC,CAcpF;IAED;;;;;;;;;;;;OAYG;IACH,uBARW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAqBzB;IA8BD;;;;;;;;;;;;;;;OAeG;IACH,cAZa,MAAM,CAclB;IAED;;;;;;;;;;;;;;OAcG;IACH,UARa,OAAO,CAAC,IAAI,CAAC,CAkBzB;IAvPD;;;;OAIG;IACH,yBAFa,MAAM,CAIlB;;CAiPF;eA1Vc,SAAS;oBAFN,UAAU;uBAGL,iBAAiB;iBAJvB,WAAW"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @property {string} supplied - User-supplied path
|
|
6
6
|
* @property {string} path - The absolute file path
|
|
7
|
-
* @property {
|
|
7
|
+
* @property {URL} url - The file URL
|
|
8
8
|
* @property {string} name - The file name
|
|
9
9
|
* @property {string} module - The file name without extension
|
|
10
10
|
* @property {string} extension - The file extension
|
|
@@ -43,23 +43,23 @@ export default class FileObject extends FS {
|
|
|
43
43
|
*/
|
|
44
44
|
get exists(): Promise<boolean>;
|
|
45
45
|
/**
|
|
46
|
-
* Return the
|
|
46
|
+
* Return the normalized path that was provided to the constructor.
|
|
47
47
|
*
|
|
48
|
-
* @returns {string} The file path
|
|
48
|
+
* @returns {string} The sanitized user-supplied file path
|
|
49
49
|
*/
|
|
50
50
|
get supplied(): string;
|
|
51
51
|
/**
|
|
52
|
-
* Return the resolved path
|
|
52
|
+
* Return the fully resolved absolute path to the file on disk.
|
|
53
53
|
*
|
|
54
|
-
* @returns {string} The file path
|
|
54
|
+
* @returns {string} The fully resolved absolute file path
|
|
55
55
|
*/
|
|
56
56
|
get path(): string;
|
|
57
57
|
/**
|
|
58
|
-
* Returns the
|
|
58
|
+
* Returns the URL of the current file.
|
|
59
59
|
*
|
|
60
|
-
* @returns {
|
|
60
|
+
* @returns {URL} The file URL
|
|
61
61
|
*/
|
|
62
|
-
get
|
|
62
|
+
get url(): URL;
|
|
63
63
|
/**
|
|
64
64
|
* Returns the file name with extension (if any) without the path.
|
|
65
65
|
*
|
|
@@ -173,6 +173,17 @@ export default class FileObject extends FS {
|
|
|
173
173
|
* @returns {Promise<object>} The file contents as a module.
|
|
174
174
|
*/
|
|
175
175
|
import(): Promise<object>;
|
|
176
|
+
/**
|
|
177
|
+
* Deletes the file from the filesystem.
|
|
178
|
+
*
|
|
179
|
+
* @returns {Promise<void>} Resolves when file is deleted
|
|
180
|
+
* @throws {Sass} If the file URL is invalid
|
|
181
|
+
* @throws {Sass} If the file does not exist
|
|
182
|
+
* @example
|
|
183
|
+
* const file = new FileObject('./temp/data.json')
|
|
184
|
+
* await file.delete()
|
|
185
|
+
*/
|
|
186
|
+
delete(): Promise<void>;
|
|
176
187
|
/**
|
|
177
188
|
* Custom inspect method for Node.js console.
|
|
178
189
|
*
|
|
@@ -182,6 +193,7 @@ export default class FileObject extends FS {
|
|
|
182
193
|
#private;
|
|
183
194
|
}
|
|
184
195
|
import FS from "./FS.js";
|
|
196
|
+
import { URL } from "node:url";
|
|
185
197
|
import DirectoryObject from "./DirectoryObject.js";
|
|
186
198
|
import util from "node:util";
|
|
187
199
|
import JSON5 from "json5";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../lib/FileObject.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../lib/FileObject.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;GAcG;AAEH;IACE;;;;;OAKG;IACH,yBAFU;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,GAAG,OAAO,IAAI,CAAC,CAAA;KAAC,CAO1D;IA2BF;;;;;OAKG;IAC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;kBAHV,OAAO;iBAIR,MAAM"}
|
|
@@ -86,7 +86,7 @@ export default class TypeSpec {
|
|
|
86
86
|
matches(value: unknown, options: {
|
|
87
87
|
allowEmpty: boolean;
|
|
88
88
|
}): boolean;
|
|
89
|
-
match(value: any, options: any):
|
|
89
|
+
match(value: any, options: any): unknown[];
|
|
90
90
|
#private;
|
|
91
91
|
}
|
|
92
92
|
//# sourceMappingURL=TypeSpec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeSpec.d.ts","sourceRoot":"","sources":["../../lib/TypeSpec.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAGE;;;;;OAKG;IACH,oBAHW,MAAM,WACN,MAAM,EAUhB;IAJC,aAAwB;IACxB,eAAgC;IAChC,6BAA2C;IAI7C;;;;OAIG;IACH,YAFa,MAAM,CAQlB;IAED;;;;OAIG;IACH,UAFa,MAAM,CASlB;IAED;;;;OAIG;IACH,kBAFW,CAAS,IAAO,EAAP,OAAO,KAAG,IAAI,QAIjC;IAED;;;;;OAKG;IACH,gBAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,OAAO,CAInB;IAED;;;;;OAKG;IACH,eAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,OAAO,CAInB;IAED;;;;;OAKG;IACH,iBAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;OAKG;IACH,cAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;;OAMG;IACH,iBAJW,CAAS,IAAO,EAAP,OAAO,EAAE,IAAO,EAAP,OAAO,KAAG,OAAO,gBACnC,OAAO,GACL,OAAO,CAInB;IAED;;;;;OAKG;IACH,eAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,MAAM,GAAC,SAAS,CAI5B;IAED;;;;;;;;OAQG;IACH,eALW,OAAO,WAEf;QAAyB,UAAU,EAA3B,OAAO;KACf,GAAU,OAAO,CAInB;IAED,
|
|
1
|
+
{"version":3,"file":"TypeSpec.d.ts","sourceRoot":"","sources":["../../lib/TypeSpec.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAGE;;;;;OAKG;IACH,oBAHW,MAAM,WACN,MAAM,EAUhB;IAJC,aAAwB;IACxB,eAAgC;IAChC,6BAA2C;IAI7C;;;;OAIG;IACH,YAFa,MAAM,CAQlB;IAED;;;;OAIG;IACH,UAFa,MAAM,CASlB;IAED;;;;OAIG;IACH,kBAFW,CAAS,IAAO,EAAP,OAAO,KAAG,IAAI,QAIjC;IAED;;;;;OAKG;IACH,gBAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,OAAO,CAInB;IAED;;;;;OAKG;IACH,eAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,OAAO,CAInB;IAED;;;;;OAKG;IACH,iBAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;OAKG;IACH,cAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;;OAMG;IACH,iBAJW,CAAS,IAAO,EAAP,OAAO,EAAE,IAAO,EAAP,OAAO,KAAG,OAAO,gBACnC,OAAO,GACL,OAAO,CAInB;IAED;;;;;OAKG;IACH,eAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,MAAM,GAAC,SAAS,CAI5B;IAED;;;;;;;;OAQG;IACH,eALW,OAAO,WAEf;QAAyB,UAAU,EAA3B,OAAO;KACf,GAAU,OAAO,CAInB;IAED,2CAkDC;;CAiCF"}
|
package/src/types/lib/Util.d.ts
CHANGED
|
@@ -166,13 +166,14 @@ export default class Util {
|
|
|
166
166
|
* Emits an event asynchronously and waits for all listeners to complete.
|
|
167
167
|
* Like asyncEmit, but uses duck typing for more flexible emitter validation.
|
|
168
168
|
* Accepts any object that has the required EventEmitter-like methods.
|
|
169
|
+
* If it walks like an EventEmitter and quacks like an EventEmitter...
|
|
169
170
|
*
|
|
170
171
|
* @param {object} emitter - Any object with EventEmitter-like interface
|
|
171
172
|
* @param {string} event - The event name to emit
|
|
172
173
|
* @param {...unknown} args - Arguments to pass to event listeners
|
|
173
174
|
* @returns {Promise<void>} Resolves when all listeners have completed
|
|
174
175
|
*/
|
|
175
|
-
static
|
|
176
|
+
static asyncEmitQuack(emitter: object, event: string, ...args: unknown[]): Promise<void>;
|
|
176
177
|
/**
|
|
177
178
|
* Determine the Levenshtein distance between two string values
|
|
178
179
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../lib/Util.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACE;;;;;OAKG;IACH,wBAHW,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;;OAMG;IACH,YAJa,CAAC,MACH,MAAM,OAAO,CAAC,CAAC,CAAC,GACd,OAAO,CAAC;QAAC,MAAM,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAQ9C;IAED;;;;;;;OAOG;IACH,4BAJW,MAAM,GAAC,MAAM,UACb,MAAM,GACJ,MAAM,CAWlB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,GAAC,MAAM,UACb,MAAM,GACJ,MAAM,CAalB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,mCAHW,MAAM,GACJ,KAAK,CAAC,MAAM,CAAC,CAazB;IAED;;;;;;OAMG;IACH,0BAHW,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GACrB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAInC;IAED;;;;;;OAMG;IACH,2BA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