@baseplate-dev/utils 0.1.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.
Files changed (195) hide show
  1. package/LICENSE +390 -0
  2. package/README.md +3 -0
  3. package/dist/crypto/hash.d.ts +2 -0
  4. package/dist/crypto/hash.d.ts.map +1 -0
  5. package/dist/crypto/hash.js +14 -0
  6. package/dist/crypto/hash.js.map +1 -0
  7. package/dist/crypto/index.d.ts +2 -0
  8. package/dist/crypto/index.d.ts.map +1 -0
  9. package/dist/crypto/index.js +2 -0
  10. package/dist/crypto/index.js.map +1 -0
  11. package/dist/errors/enhance-error-with-context.d.ts +9 -0
  12. package/dist/errors/enhance-error-with-context.d.ts.map +1 -0
  13. package/dist/errors/enhance-error-with-context.js +19 -0
  14. package/dist/errors/enhance-error-with-context.js.map +1 -0
  15. package/dist/errors/index.d.ts +2 -0
  16. package/dist/errors/index.d.ts.map +1 -0
  17. package/dist/errors/index.js +2 -0
  18. package/dist/errors/index.js.map +1 -0
  19. package/dist/events/index.d.ts +2 -0
  20. package/dist/events/index.d.ts.map +1 -0
  21. package/dist/events/index.js +2 -0
  22. package/dist/events/index.js.map +1 -0
  23. package/dist/events/typed-event-emitter.d.ts +64 -0
  24. package/dist/events/typed-event-emitter.d.ts.map +1 -0
  25. package/dist/events/typed-event-emitter.js +128 -0
  26. package/dist/events/typed-event-emitter.js.map +1 -0
  27. package/dist/field-map/field-map.d.ts +118 -0
  28. package/dist/field-map/field-map.d.ts.map +1 -0
  29. package/dist/field-map/field-map.js +287 -0
  30. package/dist/field-map/field-map.js.map +1 -0
  31. package/dist/field-map/index.d.ts +2 -0
  32. package/dist/field-map/index.d.ts.map +1 -0
  33. package/dist/field-map/index.js +2 -0
  34. package/dist/field-map/index.js.map +1 -0
  35. package/dist/fs/dir-exists.d.ts +7 -0
  36. package/dist/fs/dir-exists.d.ts.map +1 -0
  37. package/dist/fs/dir-exists.js +12 -0
  38. package/dist/fs/dir-exists.js.map +1 -0
  39. package/dist/fs/ensure-dir.d.ts +6 -0
  40. package/dist/fs/ensure-dir.d.ts.map +1 -0
  41. package/dist/fs/ensure-dir.js +9 -0
  42. package/dist/fs/ensure-dir.js.map +1 -0
  43. package/dist/fs/file-exists.d.ts +7 -0
  44. package/dist/fs/file-exists.d.ts.map +1 -0
  45. package/dist/fs/file-exists.js +12 -0
  46. package/dist/fs/file-exists.js.map +1 -0
  47. package/dist/fs/find-nearest-package-json.d.ts +22 -0
  48. package/dist/fs/find-nearest-package-json.d.ts.map +1 -0
  49. package/dist/fs/find-nearest-package-json.js +34 -0
  50. package/dist/fs/find-nearest-package-json.js.map +1 -0
  51. package/dist/fs/handle-not-found-error.d.ts +9 -0
  52. package/dist/fs/handle-not-found-error.d.ts.map +1 -0
  53. package/dist/fs/handle-not-found-error.js +15 -0
  54. package/dist/fs/handle-not-found-error.js.map +1 -0
  55. package/dist/fs/index.d.ts +9 -0
  56. package/dist/fs/index.d.ts.map +1 -0
  57. package/dist/fs/index.js +9 -0
  58. package/dist/fs/index.js.map +1 -0
  59. package/dist/fs/read-json-with-schema.d.ts +10 -0
  60. package/dist/fs/read-json-with-schema.d.ts.map +1 -0
  61. package/dist/fs/read-json-with-schema.js +29 -0
  62. package/dist/fs/read-json-with-schema.js.map +1 -0
  63. package/dist/fs/write-json.d.ts +7 -0
  64. package/dist/fs/write-json.d.ts.map +1 -0
  65. package/dist/fs/write-json.js +10 -0
  66. package/dist/fs/write-json.js.map +1 -0
  67. package/dist/fs/write-stable-pretty-json.d.ts +10 -0
  68. package/dist/fs/write-stable-pretty-json.d.ts.map +1 -0
  69. package/dist/fs/write-stable-pretty-json.js +15 -0
  70. package/dist/fs/write-stable-pretty-json.js.map +1 -0
  71. package/dist/index.d.ts +13 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +13 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/json/index.d.ts +3 -0
  76. package/dist/json/index.d.ts.map +1 -0
  77. package/dist/json/index.js +3 -0
  78. package/dist/json/index.js.map +1 -0
  79. package/dist/json/stringify-pretty-compact.d.ts +11 -0
  80. package/dist/json/stringify-pretty-compact.d.ts.map +1 -0
  81. package/dist/json/stringify-pretty-compact.js +127 -0
  82. package/dist/json/stringify-pretty-compact.js.map +1 -0
  83. package/dist/json/stringify-pretty-stable.d.ts +10 -0
  84. package/dist/json/stringify-pretty-stable.d.ts.map +1 -0
  85. package/dist/json/stringify-pretty-stable.js +17 -0
  86. package/dist/json/stringify-pretty-stable.js.map +1 -0
  87. package/dist/maps/group-by.d.ts +13 -0
  88. package/dist/maps/group-by.d.ts.map +1 -0
  89. package/dist/maps/group-by.js +26 -0
  90. package/dist/maps/group-by.js.map +1 -0
  91. package/dist/maps/index.d.ts +5 -0
  92. package/dist/maps/index.d.ts.map +1 -0
  93. package/dist/maps/index.js +5 -0
  94. package/dist/maps/index.js.map +1 -0
  95. package/dist/maps/key-by.d.ts +14 -0
  96. package/dist/maps/key-by.d.ts.map +1 -0
  97. package/dist/maps/key-by.js +21 -0
  98. package/dist/maps/key-by.js.map +1 -0
  99. package/dist/maps/map-values-of-map.d.ts +12 -0
  100. package/dist/maps/map-values-of-map.d.ts.map +1 -0
  101. package/dist/maps/map-values-of-map.js +18 -0
  102. package/dist/maps/map-values-of-map.js.map +1 -0
  103. package/dist/maps/safe-merge-map.d.ts +33 -0
  104. package/dist/maps/safe-merge-map.d.ts.map +1 -0
  105. package/dist/maps/safe-merge-map.js +45 -0
  106. package/dist/maps/safe-merge-map.js.map +1 -0
  107. package/dist/node.d.ts +3 -0
  108. package/dist/node.d.ts.map +1 -0
  109. package/dist/node.js +4 -0
  110. package/dist/node.js.map +1 -0
  111. package/dist/objects/index.d.ts +3 -0
  112. package/dist/objects/index.d.ts.map +1 -0
  113. package/dist/objects/index.js +3 -0
  114. package/dist/objects/index.js.map +1 -0
  115. package/dist/objects/safe-merge.d.ts +32 -0
  116. package/dist/objects/safe-merge.d.ts.map +1 -0
  117. package/dist/objects/safe-merge.js +46 -0
  118. package/dist/objects/safe-merge.js.map +1 -0
  119. package/dist/objects/sort-object-keys.d.ts +8 -0
  120. package/dist/objects/sort-object-keys.d.ts.map +1 -0
  121. package/dist/objects/sort-object-keys.js +10 -0
  122. package/dist/objects/sort-object-keys.js.map +1 -0
  123. package/dist/paths/get-common-path-prefix.d.ts +10 -0
  124. package/dist/paths/get-common-path-prefix.d.ts.map +1 -0
  125. package/dist/paths/get-common-path-prefix.js +34 -0
  126. package/dist/paths/get-common-path-prefix.js.map +1 -0
  127. package/dist/paths/index.d.ts +3 -0
  128. package/dist/paths/index.d.ts.map +1 -0
  129. package/dist/paths/index.js +3 -0
  130. package/dist/paths/index.js.map +1 -0
  131. package/dist/paths/posix-join.d.ts +9 -0
  132. package/dist/paths/posix-join.d.ts.map +1 -0
  133. package/dist/paths/posix-join.js +12 -0
  134. package/dist/paths/posix-join.js.map +1 -0
  135. package/dist/sets/difference.d.ts +9 -0
  136. package/dist/sets/difference.d.ts.map +1 -0
  137. package/dist/sets/difference.js +17 -0
  138. package/dist/sets/difference.js.map +1 -0
  139. package/dist/sets/index.d.ts +2 -0
  140. package/dist/sets/index.d.ts.map +1 -0
  141. package/dist/sets/index.js +2 -0
  142. package/dist/sets/index.js.map +1 -0
  143. package/dist/string/index.d.ts +3 -0
  144. package/dist/string/index.d.ts.map +1 -0
  145. package/dist/string/index.js +3 -0
  146. package/dist/string/index.js.map +1 -0
  147. package/dist/string/quot.d.ts +13 -0
  148. package/dist/string/quot.d.ts.map +1 -0
  149. package/dist/string/quot.js +17 -0
  150. package/dist/string/quot.js.map +1 -0
  151. package/dist/string/random-uid.d.ts +6 -0
  152. package/dist/string/random-uid.d.ts.map +1 -0
  153. package/dist/string/random-uid.js +16 -0
  154. package/dist/string/random-uid.js.map +1 -0
  155. package/dist/toposort/errors.d.ts +9 -0
  156. package/dist/toposort/errors.d.ts.map +1 -0
  157. package/dist/toposort/errors.js +17 -0
  158. package/dist/toposort/errors.js.map +1 -0
  159. package/dist/toposort/index.d.ts +4 -0
  160. package/dist/toposort/index.d.ts.map +1 -0
  161. package/dist/toposort/index.js +4 -0
  162. package/dist/toposort/index.js.map +1 -0
  163. package/dist/toposort/toposort-local.d.ts +25 -0
  164. package/dist/toposort/toposort-local.d.ts.map +1 -0
  165. package/dist/toposort/toposort-local.js +152 -0
  166. package/dist/toposort/toposort-local.js.map +1 -0
  167. package/dist/toposort/toposort.d.ts +30 -0
  168. package/dist/toposort/toposort.d.ts.map +1 -0
  169. package/dist/toposort/toposort.js +156 -0
  170. package/dist/toposort/toposort.js.map +1 -0
  171. package/dist/type-guards/index.d.ts +2 -0
  172. package/dist/type-guards/index.d.ts.map +1 -0
  173. package/dist/type-guards/index.js +2 -0
  174. package/dist/type-guards/index.js.map +1 -0
  175. package/dist/type-guards/not-empty.d.ts +5 -0
  176. package/dist/type-guards/not-empty.d.ts.map +1 -0
  177. package/dist/type-guards/not-empty.js +7 -0
  178. package/dist/type-guards/not-empty.js.map +1 -0
  179. package/dist/validators/case-validators.d.ts +36 -0
  180. package/dist/validators/case-validators.d.ts.map +1 -0
  181. package/dist/validators/case-validators.js +36 -0
  182. package/dist/validators/case-validators.js.map +1 -0
  183. package/dist/validators/index.d.ts +4 -0
  184. package/dist/validators/index.d.ts.map +1 -0
  185. package/dist/validators/index.js +4 -0
  186. package/dist/validators/index.js.map +1 -0
  187. package/dist/validators/number-validators.d.ts +8 -0
  188. package/dist/validators/number-validators.d.ts.map +1 -0
  189. package/dist/validators/number-validators.js +12 -0
  190. package/dist/validators/number-validators.js.map +1 -0
  191. package/dist/validators/transform-with-dynamic-schema.d.ts +10 -0
  192. package/dist/validators/transform-with-dynamic-schema.d.ts.map +1 -0
  193. package/dist/validators/transform-with-dynamic-schema.js +33 -0
  194. package/dist/validators/transform-with-dynamic-schema.js.map +1 -0
  195. package/package.json +64 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-by.js","sourceRoot":"","sources":["../../src/maps/key-by.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CACtB,QAAqB,EACrB,KAAqB;IAErB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAQ,CAAC;IAC/B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Maps the values of a Map to a new Map with the same keys.
3
+ *
4
+ * @template K - Type of keys in the map.
5
+ * @template V - Original value type.
6
+ * @template R - Resulting value type.
7
+ * @param map - The input Map to transform.
8
+ * @param fn - A function to transform each value, receiving the value, key, and original map.
9
+ * @returns A new Map with the same keys and transformed values.
10
+ */
11
+ export declare function mapValuesOfMap<K, V, R>(map: Map<K, V>, fn: (value: V, key: K, map: Map<K, V>) => R): Map<K, R>;
12
+ //# sourceMappingURL=map-values-of-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-values-of-map.d.ts","sourceRoot":"","sources":["../../src/maps/map-values-of-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACpC,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EACd,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAC1C,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAMX"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Maps the values of a Map to a new Map with the same keys.
3
+ *
4
+ * @template K - Type of keys in the map.
5
+ * @template V - Original value type.
6
+ * @template R - Resulting value type.
7
+ * @param map - The input Map to transform.
8
+ * @param fn - A function to transform each value, receiving the value, key, and original map.
9
+ * @returns A new Map with the same keys and transformed values.
10
+ */
11
+ export function mapValuesOfMap(map, fn) {
12
+ const result = new Map();
13
+ for (const [key, value] of map.entries()) {
14
+ result.set(key, fn(value, key, map));
15
+ }
16
+ return result;
17
+ }
18
+ //# sourceMappingURL=map-values-of-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-values-of-map.js","sourceRoot":"","sources":["../../src/maps/map-values-of-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAc,EACd,EAA2C;IAE3C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAQ,CAAC;IAC/B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;QACzC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,33 @@
1
+ interface MergeMapOptions {
2
+ /**
3
+ * If true, allows merging values that are deeply equal
4
+ */
5
+ allowEqualValues?: boolean;
6
+ }
7
+ /**
8
+ * Merges an array of maps, throwing an error if any keys overlap (unless the values are deeply equal and allowed).
9
+ *
10
+ * @param maps - The array of maps to merge.
11
+ * @param options - Options to control merge behavior.
12
+ * @returns The merged map.
13
+ */
14
+ export declare function safeMergeMapsWithOptions<K, V>(maps: Map<K, V>[], options?: MergeMapOptions): Map<K, V>;
15
+ /**
16
+ * Merges two maps, throwing an error if any keys overlap.
17
+ *
18
+ * @param mapOne - The first map to merge.
19
+ * @param mapTwo - The second map to merge.
20
+ * @param options - Options to control merge behavior
21
+ * @returns The merged map.
22
+ */
23
+ export declare function safeMergeMap<K, V>(mapOne: Map<K, V>, mapTwo: Map<K, V>, options?: MergeMapOptions): Map<K, V>;
24
+ /**
25
+ * Merges an array of maps, throwing an error if any keys overlap (unless the values are deeply equal and allowed).
26
+ * This function delegates to safeMergeMapsWithOptions.
27
+ *
28
+ * @param maps - The array of maps to merge.
29
+ * @returns The merged map.
30
+ */
31
+ export declare function safeMergeMaps<K, V>(...maps: Map<K, V>[]): Map<K, V>;
32
+ export {};
33
+ //# sourceMappingURL=safe-merge-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-merge-map.d.ts","sourceRoot":"","sources":["../../src/maps/safe-merge-map.ts"],"names":[],"mappings":"AAEA,UAAU,eAAe;IACvB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAC3C,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EACjB,OAAO,GAAE,eAAoB,GAC5B,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAkBX;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAC/B,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EACjB,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EACjB,OAAO,GAAE,eAAoB,GAC5B,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAEX;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAEnE"}
@@ -0,0 +1,45 @@
1
+ import { isEqual } from 'es-toolkit';
2
+ /**
3
+ * Merges an array of maps, throwing an error if any keys overlap (unless the values are deeply equal and allowed).
4
+ *
5
+ * @param maps - The array of maps to merge.
6
+ * @param options - Options to control merge behavior.
7
+ * @returns The merged map.
8
+ */
9
+ export function safeMergeMapsWithOptions(maps, options = {}) {
10
+ const result = new Map();
11
+ for (const map of maps) {
12
+ for (const [key, value] of map) {
13
+ if (result.has(key)) {
14
+ const existing = result.get(key);
15
+ if (!options.allowEqualValues || !isEqual(existing, value)) {
16
+ throw new Error(`Cannot merge key ${String(key)} because it already exists.`);
17
+ }
18
+ }
19
+ result.set(key, value);
20
+ }
21
+ }
22
+ return result;
23
+ }
24
+ /**
25
+ * Merges two maps, throwing an error if any keys overlap.
26
+ *
27
+ * @param mapOne - The first map to merge.
28
+ * @param mapTwo - The second map to merge.
29
+ * @param options - Options to control merge behavior
30
+ * @returns The merged map.
31
+ */
32
+ export function safeMergeMap(mapOne, mapTwo, options = {}) {
33
+ return safeMergeMapsWithOptions([mapOne, mapTwo], options);
34
+ }
35
+ /**
36
+ * Merges an array of maps, throwing an error if any keys overlap (unless the values are deeply equal and allowed).
37
+ * This function delegates to safeMergeMapsWithOptions.
38
+ *
39
+ * @param maps - The array of maps to merge.
40
+ * @returns The merged map.
41
+ */
42
+ export function safeMergeMaps(...maps) {
43
+ return safeMergeMapsWithOptions(maps);
44
+ }
45
+ //# sourceMappingURL=safe-merge-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-merge-map.js","sourceRoot":"","sources":["../../src/maps/safe-merge-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AASrC;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAiB,EACjB,UAA2B,EAAE;IAE7B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAQ,CAAC;IAE/B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;YAC/B,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACpB,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACjC,IAAI,CAAC,OAAO,CAAC,gBAAgB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;oBAC3D,MAAM,IAAI,KAAK,CACb,oBAAoB,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAC7D,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAiB,EACjB,MAAiB,EACjB,UAA2B,EAAE;IAE7B,OAAO,wBAAwB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAO,GAAG,IAAiB;IACtD,OAAO,wBAAwB,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC"}
package/dist/node.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './fs/index.js';
2
+ export * from './paths/index.js';
3
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAEA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
package/dist/node.js ADDED
@@ -0,0 +1,4 @@
1
+ // Export node-specific utilities
2
+ export * from './fs/index.js';
3
+ export * from './paths/index.js';
4
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './safe-merge.js';
2
+ export * from './sort-object-keys.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './safe-merge.js';
2
+ export * from './sort-object-keys.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,32 @@
1
+ interface MergeOptions {
2
+ /**
3
+ * If true, allows merging values that are deeply equal
4
+ */
5
+ allowEqualValues?: boolean;
6
+ }
7
+ /**
8
+ * Merges two objects, throwing an error if any keys overlap.
9
+ *
10
+ * @param itemOne - The first object to merge.
11
+ * @param itemTwo - The second object to merge.
12
+ * @param options - Options to control merge behavior
13
+ * @returns The merged object.
14
+ */
15
+ export declare function safeMerge<T extends Record<PropertyKey, any>, S extends Record<PropertyKey, any>>(itemOne: T, itemTwo: S, options?: MergeOptions): T & S;
16
+ /**
17
+ * Merges an array of objects, throwing an error if any keys overlap.
18
+ *
19
+ * @param items - The array of objects to merge.
20
+ * @param options - Options to control merge behavior
21
+ * @returns The merged object.
22
+ */
23
+ export declare function safeMergeAllWithOptions<T extends Record<PropertyKey, any>>(items: T[], options?: MergeOptions): T;
24
+ /**
25
+ * Merges an array of objects, throwing an error if any keys overlap.
26
+ *
27
+ * @param items - The array of objects to merge.
28
+ * @returns The merged object.
29
+ */
30
+ export declare function safeMergeAll<T extends Record<PropertyKey, any>>(...items: T[]): T;
31
+ export {};
32
+ //# sourceMappingURL=safe-merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-merge.d.ts","sourceRoot":"","sources":["../../src/objects/safe-merge.ts"],"names":[],"mappings":"AAEA,UAAU,YAAY;IACpB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAEvB,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAElC,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAClC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAE,YAAiB,GAAG,CAAC,GAAG,CAAC,CAY3D;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAErC,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAClC,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,GAAE,YAAiB,GAAG,CAAC,CAM3C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAE1B,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAClC,GAAG,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,CAElB"}
@@ -0,0 +1,46 @@
1
+ import { isEqual, mergeWith } from 'es-toolkit';
2
+ /**
3
+ * Merges two objects, throwing an error if any keys overlap.
4
+ *
5
+ * @param itemOne - The first object to merge.
6
+ * @param itemTwo - The second object to merge.
7
+ * @param options - Options to control merge behavior
8
+ * @returns The merged object.
9
+ */
10
+ export function safeMerge(itemOne, itemTwo, options = {}) {
11
+ return mergeWith(itemOne, itemTwo, (targetValue, sourceValue, key) => {
12
+ if (key in itemOne && key in itemTwo) {
13
+ if (options.allowEqualValues && isEqual(targetValue, sourceValue)) {
14
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- we're just using the sourceValue
15
+ return sourceValue;
16
+ }
17
+ throw new Error(`Cannot merge key ${key} because it already exists.`);
18
+ }
19
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- we're just using the sourceValue
20
+ return sourceValue;
21
+ });
22
+ }
23
+ /**
24
+ * Merges an array of objects, throwing an error if any keys overlap.
25
+ *
26
+ * @param items - The array of objects to merge.
27
+ * @param options - Options to control merge behavior
28
+ * @returns The merged object.
29
+ */
30
+ export function safeMergeAllWithOptions(items, options = {}) {
31
+ const targetValue = {};
32
+ for (const item of items.flat()) {
33
+ safeMerge(targetValue, item, options);
34
+ }
35
+ return targetValue;
36
+ }
37
+ /**
38
+ * Merges an array of objects, throwing an error if any keys overlap.
39
+ *
40
+ * @param items - The array of objects to merge.
41
+ * @returns The merged object.
42
+ */
43
+ export function safeMergeAll(...items) {
44
+ return safeMergeAllWithOptions(items);
45
+ }
46
+ //# sourceMappingURL=safe-merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-merge.js","sourceRoot":"","sources":["../../src/objects/safe-merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAShD;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAKvB,OAAU,EAAE,OAAU,EAAE,UAAwB,EAAE;IAClD,OAAO,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE;QACnE,IAAI,GAAG,IAAI,OAAO,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;YACrC,IAAI,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,CAAC;gBAClE,mGAAmG;gBACnG,OAAO,WAAW,CAAC;YACrB,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,6BAA6B,CAAC,CAAC;QACxE,CAAC;QACD,mGAAmG;QACnG,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAGrC,KAAU,EAAE,UAAwB,EAAE;IACtC,MAAM,WAAW,GAAG,EAAO,CAAC;IAC5B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAChC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAG1B,GAAG,KAAU;IACb,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Sorts the keys of an object.
3
+ *
4
+ * @param obj - The object to sort.
5
+ * @returns The sorted object.
6
+ */
7
+ export declare function sortObjectKeys<T extends Record<string, unknown>>(obj: T): T;
8
+ //# sourceMappingURL=sort-object-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-object-keys.d.ts","sourceRoot":"","sources":["../../src/objects/sort-object-keys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAI3E"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Sorts the keys of an object.
3
+ *
4
+ * @param obj - The object to sort.
5
+ * @returns The sorted object.
6
+ */
7
+ export function sortObjectKeys(obj) {
8
+ return Object.fromEntries(Object.entries(obj).sort(([a], [b]) => a.localeCompare(b)));
9
+ }
10
+ //# sourceMappingURL=sort-object-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-object-keys.js","sourceRoot":"","sources":["../../src/objects/sort-object-keys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAoC,GAAM;IACtE,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CACtD,CAAC;AACT,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns the highest common ancestor path from a list of absolute paths.
3
+ *
4
+ * Only works for POSIX-style paths.
5
+ *
6
+ * @param paths - Array of absolute paths
7
+ * @returns Common ancestor path
8
+ */
9
+ export declare function getCommonPathPrefix(paths: string[]): string;
10
+ //# sourceMappingURL=get-common-path-prefix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-common-path-prefix.d.ts","sourceRoot":"","sources":["../../src/paths/get-common-path-prefix.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAyB3D"}
@@ -0,0 +1,34 @@
1
+ import path from 'node:path/posix';
2
+ /**
3
+ * Returns the highest common ancestor path from a list of absolute paths.
4
+ *
5
+ * Only works for POSIX-style paths.
6
+ *
7
+ * @param paths - Array of absolute paths
8
+ * @returns Common ancestor path
9
+ */
10
+ export function getCommonPathPrefix(paths) {
11
+ if (paths.length === 0)
12
+ return '';
13
+ if (paths.length === 1)
14
+ return path.dirname(paths[0]);
15
+ const [first, ...rest] = paths;
16
+ const firstParts = path.dirname(first).split(path.sep);
17
+ let commonParts = [...firstParts];
18
+ for (const current of rest) {
19
+ const currentParts = current.split(path.sep);
20
+ const pathLength = Math.min(firstParts.length, currentParts.length);
21
+ let i = 0;
22
+ while (i < pathLength && commonParts[i] === currentParts[i]) {
23
+ i++;
24
+ }
25
+ commonParts = commonParts.slice(0, i);
26
+ if (commonParts.length === 0)
27
+ break;
28
+ }
29
+ return commonParts.length > 0 &&
30
+ !(commonParts.length === 1 && commonParts[0] === '')
31
+ ? commonParts.join(path.sep)
32
+ : path.parse(first).root;
33
+ }
34
+ //# sourceMappingURL=get-common-path-prefix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-common-path-prefix.js","sourceRoot":"","sources":["../../src/paths/get-common-path-prefix.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAe;IACjD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtD,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;IAE/B,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,IAAI,WAAW,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC;IAElC,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;QAC3B,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;QACpE,IAAI,CAAC,GAAG,CAAC,CAAC;QAEV,OAAO,CAAC,GAAG,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,CAAC,EAAE,CAAC;QACN,CAAC;QACD,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACtC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM;IACtC,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC;QAC3B,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QACpD,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QAC5B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './get-common-path-prefix.js';
2
+ export * from './posix-join.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/paths/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './get-common-path-prefix.js';
2
+ export * from './posix-join.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/paths/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Join paths using POSIX path separators. Use this function to join paths
3
+ * inside generators where we always want to use POSIX path separators.
4
+ *
5
+ * @param paths - The paths to join
6
+ * @returns The joined path
7
+ */
8
+ export declare function posixJoin(...paths: string[]): string;
9
+ //# sourceMappingURL=posix-join.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"posix-join.d.ts","sourceRoot":"","sources":["../../src/paths/posix-join.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,12 @@
1
+ import path from 'node:path';
2
+ /**
3
+ * Join paths using POSIX path separators. Use this function to join paths
4
+ * inside generators where we always want to use POSIX path separators.
5
+ *
6
+ * @param paths - The paths to join
7
+ * @returns The joined path
8
+ */
9
+ export function posixJoin(...paths) {
10
+ return path.posix.join(...paths);
11
+ }
12
+ //# sourceMappingURL=posix-join.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"posix-join.js","sourceRoot":"","sources":["../../src/paths/posix-join.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,KAAe;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns a new Set containing values in `setA` that are not in `setB`.
3
+ *
4
+ * @param setA - The original set
5
+ * @param setB - The set of values to exclude
6
+ * @returns A new Set with the difference
7
+ */
8
+ export declare function differenceSet<T>(setA: Set<T>, setB: Set<T>): Set<T>;
9
+ //# sourceMappingURL=difference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"difference.d.ts","sourceRoot":"","sources":["../../src/sets/difference.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAQnE"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Returns a new Set containing values in `setA` that are not in `setB`.
3
+ *
4
+ * @param setA - The original set
5
+ * @param setB - The set of values to exclude
6
+ * @returns A new Set with the difference
7
+ */
8
+ export function differenceSet(setA, setB) {
9
+ const result = new Set();
10
+ for (const value of setA) {
11
+ if (!setB.has(value)) {
12
+ result.add(value);
13
+ }
14
+ }
15
+ return result;
16
+ }
17
+ //# sourceMappingURL=difference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"difference.js","sourceRoot":"","sources":["../../src/sets/difference.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAI,IAAY,EAAE,IAAY;IACzD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAK,CAAC;IAC5B,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './difference.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sets/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './difference.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sets/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './quot.js';
2
+ export * from './random-uid.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './quot.js';
2
+ export * from './random-uid.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Quotes a string with single quotes and escapes single quotes.
3
+ * @param value - The string to quote.
4
+ * @returns The quoted string.
5
+ */
6
+ export declare function quot(value: string): string;
7
+ /**
8
+ * Quotes a string with double quotes and escapes double quotes.
9
+ * @param value - The string to quote.
10
+ * @returns The quoted string.
11
+ */
12
+ export declare function doubleQuot(value: string): string;
13
+ //# sourceMappingURL=quot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quot.d.ts","sourceRoot":"","sources":["../../src/string/quot.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Quotes a string with single quotes and escapes single quotes.
3
+ * @param value - The string to quote.
4
+ * @returns The quoted string.
5
+ */
6
+ export function quot(value) {
7
+ return `'${value.replaceAll("'", String.raw `\'`)}'`;
8
+ }
9
+ /**
10
+ * Quotes a string with double quotes and escapes double quotes.
11
+ * @param value - The string to quote.
12
+ * @returns The quoted string.
13
+ */
14
+ export function doubleQuot(value) {
15
+ return `"${value.replaceAll('"', String.raw `\"`)}"`;
16
+ }
17
+ //# sourceMappingURL=quot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quot.js","sourceRoot":"","sources":["../../src/string/quot.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,KAAa;IAChC,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAA,IAAI,CAAC,GAAG,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAA,IAAI,CAAC,GAAG,CAAC;AACtD,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generate a random ID string made up of numbers, lowercase, and uppercase letters
3
+ * @returns A random ID string
4
+ */
5
+ export declare function randomUid(length?: number): string;
6
+ //# sourceMappingURL=random-uid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random-uid.d.ts","sourceRoot":"","sources":["../../src/string/random-uid.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,SAAK,GAAG,MAAM,CAE7C"}
@@ -0,0 +1,16 @@
1
+ import { customAlphabet } from 'nanoid';
2
+ const NUMBERS = '0123456789';
3
+ const LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';
4
+ const UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
5
+ /**
6
+ * Use custom ID generator for characters that be easily selected
7
+ */
8
+ const customNanoid = customAlphabet(`${NUMBERS}${LOWERCASE}${UPPERCASE}_`, 12);
9
+ /**
10
+ * Generate a random ID string made up of numbers, lowercase, and uppercase letters
11
+ * @returns A random ID string
12
+ */
13
+ export function randomUid(length = 12) {
14
+ return customNanoid(length);
15
+ }
16
+ //# sourceMappingURL=random-uid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random-uid.js","sourceRoot":"","sources":["../../src/string/random-uid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,OAAO,GAAG,YAAY,CAAC;AAC7B,MAAM,SAAS,GAAG,4BAA4B,CAAC;AAC/C,MAAM,SAAS,GAAG,4BAA4B,CAAC;AAE/C;;GAEG;AACH,MAAM,YAAY,GAAG,cAAc,CAAC,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,EAAE,EAAE,CAAC,CAAC;AAE/E;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAAM,GAAG,EAAE;IACnC,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare class ToposortCyclicalDependencyError extends Error {
2
+ cyclePath: unknown[];
3
+ constructor(nodes: unknown[]);
4
+ }
5
+ export declare class ToposortUnknownNodeError extends Error {
6
+ unknownNode: unknown;
7
+ constructor(node: unknown);
8
+ }
9
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/toposort/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,+BAAgC,SAAQ,KAAK;IACjD,SAAS,EAAE,OAAO,EAAE,CAAC;gBAChB,KAAK,EAAE,OAAO,EAAE;CAO7B;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IAC1C,WAAW,EAAE,OAAO,CAAC;gBAChB,IAAI,EAAE,OAAO;CAK1B"}
@@ -0,0 +1,17 @@
1
+ export class ToposortCyclicalDependencyError extends Error {
2
+ cyclePath;
3
+ constructor(nodes) {
4
+ super(`Cyclical dependency detected: ${nodes.map((n) => JSON.stringify(n)).join(' -> ')}`);
5
+ this.name = 'ToposortCyclicalDependencyError';
6
+ this.cyclePath = nodes; // Store the path for potential inspection
7
+ }
8
+ }
9
+ export class ToposortUnknownNodeError extends Error {
10
+ unknownNode;
11
+ constructor(node) {
12
+ super(`Unknown node referenced in edges: ${JSON.stringify(node)}`);
13
+ this.name = 'ToposortUnknownNodeError';
14
+ this.unknownNode = node; // Store the node for potential inspection
15
+ }
16
+ }
17
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/toposort/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,+BAAgC,SAAQ,KAAK;IACjD,SAAS,CAAY;IAC5B,YAAY,KAAgB;QAC1B,KAAK,CACH,iCAAiC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CACpF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,iCAAiC,CAAC;QAC9C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,0CAA0C;IACpE,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAC1C,WAAW,CAAU;IAC5B,YAAY,IAAa;QACvB,KAAK,CAAC,qCAAqC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnE,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,0CAA0C;IACrE,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export * from './errors.js';
2
+ export * from './toposort-local.js';
3
+ export * from './toposort.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/toposort/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './errors.js';
2
+ export * from './toposort-local.js';
3
+ export * from './toposort.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/toposort/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,25 @@
1
+ interface ToposortOptions<T> {
2
+ /**
3
+ * Optional custom comparison function to break ties between nodes with the same topological level
4
+ *
5
+ * This allows for a stable topological sort that is consistent with the input order of nodes with the same topological level.
6
+ */
7
+ compareFunc?: (a: T, b: T) => number;
8
+ }
9
+ /**
10
+ * Performs a locality-based topological sort on a directed acyclic graph.
11
+ *
12
+ * This is a variant of Kahn's algorithm that starts from nodes with no outbound edges first,
13
+ * and then works its way back.
14
+ *
15
+ * This is useful for tasks where we want to process nodes in a way that is consistent with their locality in the graph
16
+ * such as sorting fragments of a generated code file that depend on each other.
17
+ *
18
+ * @param nodes - The nodes to sort
19
+ * @param edges - The edges of the graph
20
+ * @param options - Optional options for the topological sort
21
+ * @returns The sorted nodes
22
+ */
23
+ export declare function toposortLocal<T>(nodes: T[], edges: [T, T][], options?: ToposortOptions<T>): T[];
24
+ export {};
25
+ //# sourceMappingURL=toposort-local.d.ts.map