@gesslar/toolkit 3.13.0 → 3.14.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.
Files changed (76) hide show
  1. package/README.md +5 -4
  2. package/package.json +2 -2
  3. package/src/{index.js → node/index.js} +11 -10
  4. package/src/{lib → node/lib}/DirectoryObject.js +47 -56
  5. package/src/{lib → node/lib}/FileObject.js +76 -149
  6. package/src/{lib/FS.js → node/lib/FileSystem.js} +7 -7
  7. package/src/{lib → node/lib}/Glog.js +2 -2
  8. package/src/{lib → node/lib}/Logger.js +1 -1
  9. package/src/{lib → node/lib}/Sass.js +1 -1
  10. package/src/{lib → node/lib}/Tantrum.js +1 -1
  11. package/src/{lib → node/lib}/TempDirectoryObject.js +9 -9
  12. package/src/{lib → node/lib}/Util.js +1 -1
  13. package/src/{lib/CappedDirectoryObject.js → node/lib/VDirectoryObject.js} +37 -92
  14. package/src/node/lib/VFileObject.js +61 -0
  15. package/src/{lib → node/lib}/Valid.js +11 -5
  16. package/src/types/browser/index.d.ts +0 -13
  17. package/src/types/browser/index.d.ts.map +0 -1
  18. package/src/types/browser/lib/Collection.d.ts +0 -248
  19. package/src/types/browser/lib/Collection.d.ts.map +0 -1
  20. package/src/types/browser/lib/Data.d.ts +0 -250
  21. package/src/types/browser/lib/Data.d.ts.map +0 -1
  22. package/src/types/browser/lib/Disposer.d.ts +0 -33
  23. package/src/types/browser/lib/Disposer.d.ts.map +0 -1
  24. package/src/types/browser/lib/HTML.d.ts +0 -40
  25. package/src/types/browser/lib/HTML.d.ts.map +0 -1
  26. package/src/types/browser/lib/Notify.d.ts +0 -60
  27. package/src/types/browser/lib/Notify.d.ts.map +0 -1
  28. package/src/types/browser/lib/Promised.d.ts +0 -119
  29. package/src/types/browser/lib/Promised.d.ts.map +0 -1
  30. package/src/types/browser/lib/Sass.d.ts +0 -63
  31. package/src/types/browser/lib/Sass.d.ts.map +0 -1
  32. package/src/types/browser/lib/Tantrum.d.ts +0 -52
  33. package/src/types/browser/lib/Tantrum.d.ts.map +0 -1
  34. package/src/types/browser/lib/Time.d.ts +0 -42
  35. package/src/types/browser/lib/Time.d.ts.map +0 -1
  36. package/src/types/browser/lib/TypeSpec.d.ts +0 -90
  37. package/src/types/browser/lib/TypeSpec.d.ts.map +0 -1
  38. package/src/types/browser/lib/Util.d.ts +0 -62
  39. package/src/types/browser/lib/Util.d.ts.map +0 -1
  40. package/src/types/browser/lib/Valid.d.ts +0 -33
  41. package/src/types/browser/lib/Valid.d.ts.map +0 -1
  42. package/src/types/browser/lib/vendor/dompurify.esm.d.ts +0 -29
  43. package/src/types/browser/lib/vendor/dompurify.esm.d.ts.map +0 -1
  44. package/src/types/index.d.ts +0 -20
  45. package/src/types/index.d.ts.map +0 -1
  46. package/src/types/lib/Cache.d.ts +0 -27
  47. package/src/types/lib/Cache.d.ts.map +0 -1
  48. package/src/types/lib/CappedDirectoryObject.d.ts +0 -144
  49. package/src/types/lib/CappedDirectoryObject.d.ts.map +0 -1
  50. package/src/types/lib/DirectoryObject.d.ts +0 -277
  51. package/src/types/lib/DirectoryObject.d.ts.map +0 -1
  52. package/src/types/lib/FS.d.ts +0 -188
  53. package/src/types/lib/FS.d.ts.map +0 -1
  54. package/src/types/lib/FileObject.d.ts +0 -238
  55. package/src/types/lib/FileObject.d.ts.map +0 -1
  56. package/src/types/lib/Glog.d.ts +0 -228
  57. package/src/types/lib/Glog.d.ts.map +0 -1
  58. package/src/types/lib/Logger.d.ts +0 -46
  59. package/src/types/lib/Logger.d.ts.map +0 -1
  60. package/src/types/lib/Notify.d.ts +0 -54
  61. package/src/types/lib/Notify.d.ts.map +0 -1
  62. package/src/types/lib/Sass.d.ts +0 -9
  63. package/src/types/lib/Sass.d.ts.map +0 -1
  64. package/src/types/lib/Tantrum.d.ts +0 -9
  65. package/src/types/lib/Tantrum.d.ts.map +0 -1
  66. package/src/types/lib/TempDirectoryObject.d.ts +0 -42
  67. package/src/types/lib/TempDirectoryObject.d.ts.map +0 -1
  68. package/src/types/lib/Term.d.ts +0 -127
  69. package/src/types/lib/Term.d.ts.map +0 -1
  70. package/src/types/lib/Util.d.ts +0 -100
  71. package/src/types/lib/Util.d.ts.map +0 -1
  72. package/src/types/lib/Valid.d.ts +0 -33
  73. package/src/types/lib/Valid.d.ts.map +0 -1
  74. /package/src/{lib → node/lib}/Cache.js +0 -0
  75. /package/src/{lib → node/lib}/Notify.js +0 -0
  76. /package/src/{lib → node/lib}/Term.js +0 -0
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file CappedDirectoryObject.js
2
+ * @file VDirectoryObject.js
3
3
  * @description Abstract base class for directory objects that are constrained
4
4
  * to a specific directory tree (the "cap"). This provides security by ensuring
5
5
  * all operations remain within the capped directory hierarchy.
@@ -11,12 +11,11 @@
11
11
  import path from "node:path"
12
12
 
13
13
  import DirectoryObject from "./DirectoryObject.js"
14
- import FileObject from "./FileObject.js"
15
- import FS from "./FS.js"
14
+ import FileSystem from "./FileSystem.js"
16
15
  import Valid from "./Valid.js"
17
16
 
18
17
  /**
19
- * CappedDirectoryObject extends DirectoryObject with constraints that ensure
18
+ * VDirectoryObject extends DirectoryObject with constraints that ensure
20
19
  * all operations are restricted to a specific directory tree (the "cap").
21
20
  *
22
21
  * All path operations are validated to ensure they remain within the
@@ -24,45 +23,44 @@ import Valid from "./Valid.js"
24
23
  *
25
24
  * @augments DirectoryObject
26
25
  */
27
- export default class CappedDirectoryObject extends DirectoryObject {
26
+ export default class VDirectoryObject extends DirectoryObject {
28
27
  #real
29
28
  #cap
30
29
  #cappedParentPath
31
30
  #cappedParent
32
31
 
33
32
  /**
34
- * Constructs a CappedDirectoryObject instance.
33
+ * Constructs a VDirectoryObject instance.
35
34
  *
36
- * Without a parent, the path becomes both the directory location and the cap
37
- * (virtual root). With a parent, the path is resolved relative to the parent's
38
- * cap using virtual path semantics (absolute paths treated as cap-relative).
35
+ * Without a parent, creates a new cap at the specified real directory location
36
+ * with virtual path "/". With a parent, the path is resolved relative to the
37
+ * parent's virtual path (absolute paths treated as cap-relative).
39
38
  *
40
- * @param {string} [directory="."] - Directory path (becomes cap if no parent, else relative to parent's cap, defaults to current directory)
41
- * @param {CappedDirectoryObject?} [parent] - Optional parent capped directory
42
- * @throws {Sass} If parent is provided but not a CappedDirectoryObject
43
- * @throws {Sass} If the resulting path would escape the cap
39
+ * @param {string} [directory="."] - Real directory path when no parent (becomes cap), or relative/absolute virtual path when parent provided
40
+ * @param {VDirectoryObject?} [parent] - Optional parent capped directory
41
+ * @throws {Sass} If parent is provided but not a VDirectoryObject
44
42
  * @example
45
43
  * // Create new capped directory at current directory
46
- * const cwd = new CappedDirectoryObject()
47
- * // path: process.cwd(), cap: process.cwd()
44
+ * const cwd = new VDirectoryObject()
45
+ * // Virtual path: "/", Real path: process.cwd(), Cap: itself
48
46
  *
49
47
  * @example
50
48
  * // Create new capped directory
51
- * const cache = new CappedDirectoryObject("/home/user/.cache")
52
- * // path: /home/user/.cache, cap: /home/user/.cache
49
+ * const cache = new VDirectoryObject("/home/user/.cache")
50
+ * // Virtual path: "/", Real path: /home/user/.cache, Cap: itself
53
51
  *
54
52
  * @example
55
53
  * // Create subdirectory with parent
56
- * const data = new CappedDirectoryObject("data", cache)
57
- * // path: /home/user/.cache/data, cap: /home/user/.cache
54
+ * const data = new VDirectoryObject("data", cache)
55
+ * // Virtual path: /data, Real path: /home/user/.cache/data, Cap: cache
58
56
  *
59
57
  * @example
60
- * // Virtual absolute path with parent
61
- * const config = new CappedDirectoryObject("/etc/config", cache)
62
- * // path: /home/user/.cache/etc/config, cap: /home/user/.cache
58
+ * // Virtual absolute path with parent (treated as cap-relative)
59
+ * const config = new VDirectoryObject("/etc/config", cache)
60
+ * // Virtual path: /etc/config, Real path: /home/user/.cache/etc/config, Cap: cache
63
61
  */
64
62
  constructor(directory, source=null) {
65
- Valid.type(source, "Null|CappedDirectoryObject")
63
+ Valid.type(source, "Null|VDirectoryObject")
66
64
 
67
65
  directory ||= "."
68
66
 
@@ -73,9 +71,9 @@ export default class CappedDirectoryObject extends DirectoryObject {
73
71
  directory = directory.slice(1)
74
72
 
75
73
  // Find out what directory means to the basePath
76
- const realResolved = FS.resolvePath(baseRealPath, directory)
74
+ const realResolved = FileSystem.resolvePath(baseRealPath, directory)
77
75
  const localResolved = source
78
- ? FS.resolvePath(baseLocalPath, directory)
76
+ ? FileSystem.resolvePath(baseLocalPath, directory)
79
77
  : path.parse(path.resolve("")).root
80
78
 
81
79
  super(localResolved)
@@ -93,14 +91,14 @@ export default class CappedDirectoryObject extends DirectoryObject {
93
91
  }
94
92
 
95
93
  /**
96
- * Creates a CappedDirectoryObject from the current working directory.
94
+ * Creates a VDirectoryObject from the current working directory.
97
95
  * This is useful when working with pnpx or other tools where you need to
98
96
  * cap at the project's root directory determined at runtime.
99
97
  *
100
- * @returns {CappedDirectoryObject} A CappedDirectoryObject capped at the current working directory
98
+ * @returns {VDirectoryObject} A VDirectoryObject capped at the current working directory
101
99
  * @example
102
100
  * // When using pnpx or similar tools
103
- * const projectRoot = CappedDirectoryObject.fromCwd()
101
+ * const projectRoot = VDirectoryObject.fromCwd()
104
102
  * const srcDir = projectRoot.getDirectory("src")
105
103
  * // srcDir is capped at the project root
106
104
  */
@@ -110,26 +108,26 @@ export default class CappedDirectoryObject extends DirectoryObject {
110
108
 
111
109
  /**
112
110
  * Indicates whether this directory is capped (constrained to a specific tree).
113
- * Always returns true for CappedDirectoryObject instances.
111
+ * Always returns true for VDirectoryObject instances.
114
112
  *
115
- * @returns {boolean} True for all CappedDirectoryObject instances
113
+ * @returns {boolean} True for all VDirectoryObject instances
116
114
  * @example
117
115
  * const capped = new TempDirectoryObject("myapp")
118
- * console.log(capped.isCapped) // true
116
+ * console.log(capped.isVirtual) // true
119
117
  *
120
118
  * const regular = new DirectoryObject("/tmp")
121
- * console.log(regular.isCapped) // false
119
+ * console.log(regular.isVirtual) // false
122
120
  */
123
- get isCapped() {
121
+ get isVirtual() {
124
122
  return true
125
123
  }
126
124
 
127
125
  /**
128
126
  * Returns the cap (root) of the capped directory tree.
129
- * For root CappedDirectoryObject instances, returns itself.
127
+ * For root VDirectoryObject instances, returns itself.
130
128
  * For children, returns the inherited cap from the parent chain.
131
129
  *
132
- * @returns {CappedDirectoryObject} The cap directory object (root of the capped tree)
130
+ * @returns {VDirectoryObject} The cap directory object (root of the capped tree)
133
131
  * @example
134
132
  * const temp = new TempDirectoryObject("myapp")
135
133
  * console.log(temp.cap === temp) // true (root is its own cap)
@@ -167,14 +165,14 @@ export default class CappedDirectoryObject extends DirectoryObject {
167
165
  * Returns the parent directory of this capped directory.
168
166
  * Returns null only if this directory is at the cap (the "root" of the capped tree).
169
167
  *
170
- * Note: The returned parent is a CappedDirectoryObject with the same cap.
168
+ * Note: The returned parent is a VDirectoryObject with the same cap.
171
169
  * This maintains the capping behavior throughout the directory hierarchy.
172
170
  *
173
- * @returns {CappedDirectoryObject|null} Parent directory or null if at cap root
171
+ * @returns {VDirectoryObject|null} Parent directory or null if at cap root
174
172
  * @example
175
173
  * const capped = new TempDirectoryObject("myapp")
176
174
  * const subdir = capped.getDirectory("data")
177
- * console.log(subdir.parent.path) // Returns parent CappedDirectoryObject
175
+ * console.log(subdir.parent.path) // Returns parent VDirectoryObject
178
176
  * console.log(capped.parent) // null (at cap root)
179
177
  */
180
178
  get parent() {
@@ -191,63 +189,10 @@ export default class CappedDirectoryObject extends DirectoryObject {
191
189
  * console.log(temp.parentPath) // null (at cap root)
192
190
  *
193
191
  * const subdir = temp.getDirectory("data")
194
- * console.log(subdir.parentPath) // "/data" or similar (parent's virtual path)
192
+ * console.log(subdir.parentPath) // "/" (parent's virtual path)
195
193
  */
196
194
  get parentPath() {
197
195
  return this.#cappedParentPath
198
196
  }
199
197
 
200
- /**
201
- * Override exists to use real filesystem path.
202
- *
203
- * @returns {Promise<boolean>} Whether the directory exists
204
- */
205
- get exists() {
206
- return this.real.exists
207
- }
208
-
209
- /**
210
- * Override read to use real filesystem path and return capped objects.
211
- *
212
- * @param {string} [pat=""] - Optional glob pattern
213
- * @returns {Promise<{files: Array<FileObject>, directories: Array}>} Directory contents
214
- */
215
- async read(...arg) {
216
- const {files, directories} = await this.real.read(...arg)
217
-
218
- // we need to re-cast
219
- const recastDirs = directories.map(e => this.getDirectory(e.name))
220
- const recastFiles = files.map(f => new FileObject(f.name, this))
221
-
222
- return {files: recastFiles, directories: recastDirs}
223
- }
224
-
225
- /**
226
- * Override hasDirectory to use real filesystem path.
227
- *
228
- * @param {string} dirname - Directory name to check
229
- * @returns {Promise<boolean>} True if directory exists
230
- */
231
- async hasDirectory(dirname) {
232
- return await this.real.hasDirectory(dirname)
233
- }
234
-
235
- /**
236
- * Override assureExists to use real filesystem path.
237
- *
238
- * @param {object} [options] - Options for mkdir
239
- * @returns {Promise<void>}
240
- */
241
- async assureExists(options = {}) {
242
- return await this.real.assureExists(options)
243
- }
244
-
245
- /**
246
- * Override delete to use real filesystem path.
247
- *
248
- * @returns {Promise<void>}
249
- */
250
- async delete() {
251
- return await this.real.delete()
252
- }
253
198
  }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @file VFileObject.js
3
+ * @description Class representing a virtual file within a capped directory tree.
4
+ * Extends FileObject with virtual path support and real filesystem mapping.
5
+ */
6
+
7
+ import FileObject from "./FileObject.js"
8
+ import FS from "./FileSystem.js"
9
+ import Valid from "./Valid.js"
10
+
11
+ /**
12
+ * VFileObject extends FileObject with virtual path support, maintaining both
13
+ * a virtual path (relative to cap) and a real filesystem path.
14
+ *
15
+ * Virtual files must have a VDirectoryObject parent and cannot exist independently.
16
+ * All file operations use the real filesystem path while exposing clean virtual paths.
17
+ *
18
+ * @property {string} supplied - User-supplied path
19
+ * @property {string} path - The virtual file path (relative to cap)
20
+ * @property {URL} url - The file URL
21
+ * @property {string} name - The file name
22
+ * @property {string} module - The file name without extension
23
+ * @property {string} extension - The file extension
24
+ * @property {boolean} isFile - Always true for files
25
+ * @property {boolean} isVirtual - Always true for VFileObject instances
26
+ * @property {VDirectoryObject} parent - The parent virtual directory object
27
+ * @property {FileObject} real - The real filesystem FileObject
28
+ * @property {Promise<boolean>} exists - Whether the file exists (async)
29
+ */
30
+
31
+ export default class VFileObject extends FileObject {
32
+ #real
33
+
34
+ /**
35
+ * Constructs a VFileObject instance.
36
+ *
37
+ * @param {string} fileName - The file path
38
+ * @param {VDirectoryObject} parent - The parent virtual directory (required)
39
+ */
40
+ constructor(fileName, parent) {
41
+ Valid.type(fileName, "String", {allowEmpty: false})
42
+ Valid.type(parent, "VDirectoryObject")
43
+
44
+ super(fileName, parent)
45
+
46
+ const parentRealPath = this.parent.real.path
47
+ const relative = FS.absoluteToRelative(this.path, true)
48
+ const resolved = FS.resolvePath(parentRealPath, relative)
49
+ const {base, dir} = FS.pathParts(resolved)
50
+
51
+ this.#real = new FileObject(base, dir)
52
+ }
53
+
54
+ get isVirtual() {
55
+ return true
56
+ }
57
+
58
+ get real() {
59
+ return this.#real
60
+ }
61
+ }
@@ -6,8 +6,8 @@
6
6
  */
7
7
 
8
8
  import Sass from "./Sass.js"
9
- import Data from "../browser/lib/Data.js"
10
- import Collection from "../browser/lib/Collection.js"
9
+ import Data from "../../browser/lib/Data.js"
10
+ import Collection from "../../browser/lib/Collection.js"
11
11
 
12
12
  /**
13
13
  * Validation utility class providing type checking and assertion methods.
@@ -23,10 +23,14 @@ export default class Valid {
23
23
  * @param {object} [options] - Additional options for validation.
24
24
  */
25
25
  static type(value, type, options) {
26
+ const expected = [type]
27
+
28
+ if(options?.allowEmpty !== true)
29
+ expected.push("[no empty values]")
30
+
26
31
  Valid.assert(
27
32
  Data.isType(value, type, options),
28
- `Invalid type. Expected ${type}, got ${Data.typeOf(value)}`,
29
- 1,
33
+ `Invalid type. Expected ${expected.join(" ")}, got ${Data.typeOf(value)}`
30
34
  )
31
35
  }
32
36
 
@@ -57,7 +61,9 @@ export default class Valid {
57
61
  }
58
62
 
59
63
  /**
60
- * Protects against prototype pollution by checking keys for dangerous property names.
64
+ * Protects against prototype pollution by checking keys for dangerous
65
+ * property names.
66
+ *
61
67
  * Throws if any restricted prototype properties are found in the keys array.
62
68
  *
63
69
  * @param {Array<string>} keys - Array of property keys to validate
@@ -1,13 +0,0 @@
1
- export { default as Collection } from "./lib/Collection.js";
2
- export { default as Data } from "./lib/Data.js";
3
- export { default as Notify } from "./lib/Notify.js";
4
- export { default as Promised } from "./lib/Promised.js";
5
- export { default as Sass } from "./lib/Sass.js";
6
- export { default as Tantrum } from "./lib/Tantrum.js";
7
- export { default as Time } from "./lib/Time.js";
8
- export { default as Type } from "./lib/TypeSpec.js";
9
- export { default as Util } from "./lib/Util.js";
10
- export { default as Valid } from "./lib/Valid.js";
11
- export { default as Disposer, Disposer as DisposerClass } from "./lib/Disposer.js";
12
- export { default as HTML, HTML as HTMLClass } from "./lib/HTML.js";
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../browser/index.js"],"names":[],"mappings":""}
@@ -1,248 +0,0 @@
1
- /**
2
- * Utility class for collection operations.
3
- * Provides static methods for working with arrays, objects, sets, and maps.
4
- */
5
- export default class Collection {
6
- /**
7
- * Evaluates an array with a predicate function, optionally in reverse order.
8
- * Returns the first truthy result from the predicate.
9
- *
10
- * @param {Array<unknown>} collection - The array to evaluate
11
- * @param {(value: unknown, index: number, array: Array<unknown>) => unknown} predicate - Function to evaluate each element
12
- * @param {boolean} [forward] - Whether to iterate forward (true) or backward (false). Defaults to true
13
- * @returns {unknown|undefined} The first truthy result from the predicate, or undefined
14
- * @throws {Sass} If collection is not an array or predicate is not a function
15
- */
16
- static evalArray(collection: Array<unknown>, predicate: (value: unknown, index: number, array: Array<unknown>) => unknown, forward?: boolean): unknown | undefined;
17
- /**
18
- * Evaluates an object with a predicate function.
19
- * Returns the first truthy result from the predicate.
20
- *
21
- * @param {object} collection - The object to evaluate
22
- * @param {(value: unknown, key: string, object: object) => unknown} predicate - Function to evaluate each property
23
- * @returns {unknown|undefined} The first truthy result from the predicate, or undefined
24
- * @throws {Sass} If collection is not an object or predicate is not a function
25
- */
26
- static evalObject(collection: object, predicate: (value: unknown, key: string, object: object) => unknown): unknown | undefined;
27
- /**
28
- * Evaluates a Set with a predicate function.
29
- * Returns the first truthy result from the predicate.
30
- *
31
- * @param {Set<unknown>} collection - The Set to evaluate
32
- * @param {(value: unknown, set: Set<unknown>) => unknown} predicate - Function to evaluate each element
33
- * @returns {unknown|undefined} The first truthy result from the predicate, or undefined
34
- * @throws {Sass} If collection is not a Set or predicate is not a function
35
- */
36
- static evalSet(collection: Set<unknown>, predicate: (value: unknown, set: Set<unknown>) => unknown): unknown | undefined;
37
- /**
38
- * Evaluates a Map with a predicate function, optionally in reverse order.
39
- * Returns the first truthy result from the predicate.
40
- *
41
- * @param {Map<unknown, unknown>} collection - The Map to evaluate
42
- * @param {(value: unknown, key: unknown, map: Map<unknown, unknown>) => unknown} predicate - Function to evaluate each entry
43
- * @param {boolean} [forward] - Whether to iterate forward (true) or backward (false). Defaults to true
44
- * @returns {unknown|undefined} The first truthy result from the predicate, or undefined
45
- * @throws {Sass} If collection is not a Map or predicate is not a function
46
- */
47
- static evalMap(collection: Map<unknown, unknown>, predicate: (value: unknown, key: unknown, map: Map<unknown, unknown>) => unknown, forward?: boolean): unknown | undefined;
48
- /**
49
- * Zips two arrays together into an array of pairs.
50
- * The resulting array length equals the shorter input array.
51
- *
52
- * @param {Array<unknown>} array1 - The first array
53
- * @param {Array<unknown>} array2 - The second array
54
- * @returns {Array<[unknown, unknown]>} Array of paired elements
55
- */
56
- static zip(array1: Array<unknown>, array2: Array<unknown>): Array<[unknown, unknown]>;
57
- /**
58
- * Unzips an array of pairs into separate arrays.
59
- * Transposes a 2D array structure.
60
- *
61
- * @param {Array<Array<unknown>>} array - Array of arrays to unzip
62
- * @returns {Array<Array<unknown>>} Array of unzipped arrays, or empty array for invalid input
63
- */
64
- static unzip(array: Array<Array<unknown>>): Array<Array<unknown>>;
65
- /**
66
- * Maps an array using an async function, processing items sequentially.
67
- * Unlike Promise.all(array.map()), this processes one item at a time.
68
- *
69
- * @param {Array<unknown>} array - The array to map
70
- * @param {(item: unknown) => Promise<unknown>} asyncFn - Async function to apply to each element
71
- * @returns {Promise<Array<unknown>>} Promise resolving to the mapped array
72
- * @throws {Sass} If array is not an Array or asyncFn is not a function
73
- */
74
- static asyncMap(array: Array<unknown>, asyncFn: (item: unknown) => Promise<unknown>): Promise<Array<unknown>>;
75
- /**
76
- * Checks if all elements in an array are of a specified type
77
- *
78
- * @param {Array<unknown>} arr - The array to check
79
- * @param {string} [type] - The type to check for (optional, defaults to the type of the first element)
80
- * @param {unknown} options - Options for checking types
81
- * @param {boolean} [options.strict] - Whether to use strict type or looser TypeSpec checking
82
- * @returns {boolean} Whether all elements are of the specified type
83
- */
84
- static isArrayUniform(arr: Array<unknown>, type?: string, options?: unknown): boolean;
85
- /**
86
- * Checks if an array is unique
87
- *
88
- * @param {Array<unknown>} arr - The array of which to remove duplicates
89
- * @returns {Array<unknown>} The unique elements of the array
90
- */
91
- static isArrayUnique(arr: Array<unknown>): Array<unknown>;
92
- /**
93
- * Returns the intersection of two arrays.
94
- *
95
- * @param {Array<unknown>} arr1 - The first array.
96
- * @param {Array<unknown>} arr2 - The second array.
97
- * @returns {Array<unknown>} The intersection of the two arrays.
98
- */
99
- static intersection(arr1: Array<unknown>, arr2: Array<unknown>): Array<unknown>;
100
- /**
101
- * Checks whether two arrays have any elements in common.
102
- *
103
- * This function returns `true` if at least one element from `arr1` exists in
104
- * `arr2`, and `false` otherwise. It optimizes by iterating over the shorter
105
- * array for efficiency.
106
- *
107
- * Example:
108
- * Collection.intersects([1, 2, 3], [3, 4, 5]) // returns true
109
- * Collection.intersects(["a", "b"], ["c", "d"]) // returns false
110
- *
111
- * @param {Array<unknown>} arr1 - The first array to check for intersection.
112
- * @param {Array<unknown>} arr2 - The second array to check for intersection.
113
- * @returns {boolean} True if any element is shared between the arrays, false otherwise.
114
- */
115
- static intersects(arr1: Array<unknown>, arr2: Array<unknown>): boolean;
116
- /**
117
- * Pads an array to a specified length with a value. This operation
118
- * occurs in-place.
119
- *
120
- * @param {Array<unknown>} arr - The array to pad.
121
- * @param {number} length - The length to pad the array to.
122
- * @param {unknown} value - The value to pad the array with.
123
- * @param {number} [position] - The position to pad the array at. Defaults to 0
124
- * @returns {Array<unknown>} The padded array.
125
- */
126
- static arrayPad(arr: Array<unknown>, length: number, value: unknown, position?: number): Array<unknown>;
127
- /**
128
- * Filters an array asynchronously using a predicate function.
129
- * Applies the predicate to all items in parallel and returns filtered results.
130
- *
131
- * @param {Array<unknown>} arr - The array to filter
132
- * @param {(value: unknown, index: number, array: Array<unknown>) => Promise<boolean>} predicate - Async predicate function that returns a promise resolving to boolean
133
- * @returns {Promise<Array<unknown>>} Promise resolving to the filtered array
134
- */
135
- static asyncFilter(arr: Array<unknown>, predicate: (value: unknown, index: number, array: Array<unknown>) => Promise<boolean>): Promise<Array<unknown>>;
136
- /**
137
- * Clones an object
138
- *
139
- * @param {object} obj - The object to clone
140
- * @param {boolean} freeze - Whether to freeze the cloned object
141
- * @returns {object} The cloned object
142
- */
143
- static cloneObject(obj: object, freeze?: boolean): object;
144
- /**
145
- * Checks if an object is empty
146
- *
147
- * @param {object} obj - The object to check
148
- * @returns {boolean} Whether the object is empty
149
- */
150
- static isObjectEmpty(obj: object): boolean;
151
- /**
152
- * Ensures that a nested path of objects exists within the given object.
153
- * Creates empty objects along the path if they don't exist.
154
- *
155
- * @param {object} obj - The object to check/modify
156
- * @param {Array<string>} keys - Array of keys representing the path to ensure
157
- * @returns {object} Reference to the deepest nested object in the path
158
- */
159
- static assureObjectPath(obj: object, keys: Array<string>): object;
160
- /**
161
- * Sets a value in a nested object structure using an array of keys; creating
162
- * the structure if it does not exist.
163
- *
164
- * @param {object} obj - The target object to set the value in
165
- * @param {Array<string>} keys - Array of keys representing the path to the target property
166
- * @param {unknown} value - The value to set at the target location
167
- */
168
- static setNestedValue(obj: object, keys: Array<string>, value: unknown): void;
169
- /**
170
- * Deeply merges two or more objects. Arrays are replaced, not merged.
171
- *
172
- * @param {...object} sources - Objects to merge (left to right)
173
- * @returns {object} The merged object
174
- */
175
- static mergeObject(...sources: object[]): object;
176
- /**
177
- * Freezes an object and all of its properties recursively.
178
- *
179
- * @param {object} obj The object to freeze.
180
- * @returns {object} The frozen object.
181
- */
182
- static deepFreezeObject(obj: object): object;
183
- /**
184
- * Maps an object using a transformer function
185
- *
186
- * @param {object} original The original object
187
- * @param {function(unknown): unknown} transformer The transformer function
188
- * @param {boolean} mutate Whether to mutate the original object
189
- * @returns {Promise<object>} The mapped object
190
- */
191
- static mapObject(original: object, transformer: (arg0: unknown) => unknown, mutate?: boolean): Promise<object>;
192
- /**
193
- * Allocates an object from a source array and a spec array or function.
194
- *
195
- * @param {Array<unknown>} source The source array
196
- * @param {Array<unknown>|function(Array<unknown>): Promise<Array<unknown>>|Array<unknown>} spec The spec array or function
197
- * @returns {Promise<object>} The allocated object
198
- */
199
- static allocateObject(source: Array<unknown>, spec: Array<unknown> | ((arg0: Array<unknown>) => Promise<Array<unknown>> | Array<unknown>)): Promise<object>;
200
- /**
201
- * Trims falsy values from both ends of an array (in-place).
202
- * Optionally preserves specific falsy values.
203
- *
204
- * @param {Array<unknown>} arr - The array to trim
205
- * @param {Array<unknown>} [except] - Values to preserve even if falsy. Defaults to empty array
206
- * @returns {Array<unknown>} The trimmed array (same reference, modified in-place)
207
- * @throws {Sass} If arr is not an Array or except is not an Array
208
- */
209
- static trimArray(arr: Array<unknown>, except?: Array<unknown>): Array<unknown>;
210
- /**
211
- * Trims falsy values from the right end of an array (in-place).
212
- * Optionally preserves specific falsy values.
213
- *
214
- * @param {Array<unknown>} arr - The array to trim
215
- * @param {Array<unknown>} [except] - Values to preserve even if falsy. Defaults to empty array
216
- * @returns {Array<unknown>} The trimmed array (same reference, modified in-place)
217
- * @throws {Sass} If arr is not an Array or except is not an Array
218
- */
219
- static trimArrayRight(arr: Array<unknown>, except?: Array<unknown>): Array<unknown>;
220
- /**
221
- * Trims falsy values from the left end of an array (in-place).
222
- * Optionally preserves specific falsy values.
223
- *
224
- * @param {Array<unknown>} arr - The array to trim
225
- * @param {Array<unknown>} [except] - Values to preserve even if falsy. Defaults to empty array
226
- * @returns {Array<unknown>} The trimmed array (same reference, modified in-place)
227
- * @throws {Sass} If arr is not an Array or except is not an Array
228
- */
229
- static trimArrayLeft(arr: Array<unknown>, except?: Array<unknown>): Array<unknown>;
230
- /**
231
- * Transposes an array of objects into an object of arrays.
232
- * Collects values for each key across all objects into arrays.
233
- *
234
- * @param {Array<object>} objects - Array of plain objects to transpose
235
- * @returns {object} Object with keys from input objects, values as arrays
236
- * @throws {Sass} If objects is not an Array or contains non-plain objects
237
- */
238
- static transposeObjects(objects: Array<object>): object;
239
- /**
240
- * Flattens an array (or nested array) of objects and transposes them.
241
- * Combines flat() and transposeObjects() operations.
242
- *
243
- * @param {Array<object>|Array<Array<object>>} input - Array or nested array of objects
244
- * @returns {object} Transposed object with arrays of values
245
- */
246
- static flattenObjectArray(input: Array<object> | Array<Array<object>>): object;
247
- }
248
- //# sourceMappingURL=Collection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../browser/lib/Collection.js"],"names":[],"mappings":"AAcA;;;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,SAAS,CAqB7B;IAED;;;;;;;;OAQG;IACH,8BALW,MAAM,aACN,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,GACtD,OAAO,GAAC,SAAS,CAmB7B;IAED;;;;;;;;OAQG;IACH,2BALW,GAAG,CAAC,OAA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