@hardlydifficult/collections 1.0.16 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @hardlydifficult/collections
2
2
 
3
- A TypeScript utility library for array chunking and path depth grouping.
3
+ Opinionated collection helpers for the patterns we actually use: batching work and walking paths bottom-up.
4
4
 
5
5
  ## Installation
6
6
 
@@ -11,83 +11,73 @@ npm install @hardlydifficult/collections
11
11
  ## Quick Start
12
12
 
13
13
  ```typescript
14
- import { chunk, groupByDepth } from "@hardlydifficult/collections";
15
-
16
- // Split an array into chunks of fixed size
17
- const numbers = [1, 2, 3, 4, 5, 6, 7];
18
- console.log(chunk(numbers, 3));
19
- // Output: [[1, 2, 3], [4, 5, 6], [7]]
20
-
21
- // Group file paths by directory depth (deepest-first)
22
- const paths = ["src/components", "src", "src/components/Button"];
23
- console.log(groupByDepth(paths));
24
- // Output: [
25
- // { depth: 2, paths: ["src/components", "src/components/Button"] },
26
- // { depth: 1, paths: ["src"] }
27
- // ]
14
+ import { inBatches, bottomUp } from "@hardlydifficult/collections";
15
+
16
+ for (const batch of inBatches([1, 2, 3, 4, 5, 6, 7], 3)) {
17
+ console.log(batch);
18
+ }
19
+ // [1, 2, 3]
20
+ // [4, 5, 6]
21
+ // [7]
22
+
23
+ for (const dirsAtDepth of bottomUp([
24
+ "src/components/Button",
25
+ "src/components",
26
+ "src",
27
+ ])) {
28
+ console.log(dirsAtDepth);
29
+ }
30
+ // ["src/components/Button"]
31
+ // ["src/components"]
32
+ // ["src"]
28
33
  ```
29
34
 
30
- ## Array Chunking
35
+ ## Work Batching
31
36
 
32
- The `chunk` function splits an array into subarrays of a specified maximum size.
37
+ ### `inBatches`
33
38
 
34
- ### `chunk`
39
+ Split a readonly array into sequential batches.
35
40
 
36
- Splits a readonly array into chunks of the given size.
37
-
38
- **Signature:**
39
41
  ```typescript
40
- function chunk<T>(arr: readonly T[], size: number): T[][]
42
+ function inBatches<T>(items: readonly T[], size: number): T[][]
41
43
  ```
42
44
 
43
- | Parameter | Type | Description |
44
- |-----------|-------------------|-------------------------------|
45
- | `arr` | `readonly T[]` | The array to split |
46
- | `size` | `number` | Maximum size of each chunk |
45
+ Use this when the caller is processing work, not thinking in terms of array chunking.
47
46
 
48
- **Example:**
49
47
  ```typescript
50
- import { chunk } from "@hardlydifficult/collections";
51
-
52
- const items = ["a", "b", "c", "d", "e"];
53
- console.log(chunk(items, 2));
54
- // Output: [["a", "b"], ["c", "d"], ["e"]]
48
+ import { inBatches } from "@hardlydifficult/collections";
55
49
 
56
- console.log(chunk([1, 2, 3], 5));
57
- // Output: [[1, 2, 3]]
50
+ for (const batch of inBatches(files, 5)) {
51
+ await Promise.all(batch.map(processFile));
52
+ }
58
53
  ```
59
54
 
60
- ## Path Depth Grouping
55
+ ## Bottom-Up Path Processing
56
+
57
+ ### `bottomUp`
61
58
 
62
- The `groupByDepth` function groups filesystem paths by their slash-delimited depth, returning groups sorted deepest-first for bottom-up directory processing.
59
+ Group paths deepest-first for bottom-up processing.
63
60
 
64
- ### `groupByDepth`
61
+ ```typescript
62
+ function bottomUp(paths: readonly string[]): string[][]
63
+ ```
65
64
 
66
- Groups path strings by `/`-separated depth, sorted deepest-first.
65
+ Depth is computed from normalized slash-separated segments, so repeated or trailing slashes do not change grouping depth.
67
66
 
68
- **Signature:**
69
67
  ```typescript
70
- function groupByDepth(paths: readonly string[]): { depth: number; paths: string[] }[]
68
+ import { bottomUp } from "@hardlydifficult/collections";
69
+
70
+ for (const dirsAtDepth of bottomUp(["a/b/c", "a/b", "a", "x/y"])) {
71
+ console.log(dirsAtDepth);
72
+ }
73
+ // ["a/b/c"]
74
+ // ["a/b", "x/y"]
75
+ // ["a"]
71
76
  ```
72
77
 
73
- | Parameter | Type | Description |
74
- |-----------|--------------------|--------------------------------------|
75
- | `paths` | `readonly string[]`| Array of path strings to group |
78
+ ## Compatibility Exports
76
79
 
77
- Returns an array of objects with:
78
- - `depth`: number of slash-separated segments (empty string has depth 0)
79
- - `paths`: array of paths at that depth, in original order
80
+ The lower-level names are still available when they read better in a given call site:
80
81
 
81
- **Example:**
82
- ```typescript
83
- import { groupByDepth } from "@hardlydifficult/collections";
84
-
85
- const paths = ["a/b/c", "a/b", "a", "", "x/y"];
86
- console.log(groupByDepth(paths));
87
- // Output: [
88
- // { depth: 3, paths: ["a/b/c"] },
89
- // { depth: 2, paths: ["a/b", "x/y"] },
90
- // { depth: 1, paths: ["a"] },
91
- // { depth: 0, paths: [""] }
92
- // ]
93
- ```
82
+ - `chunk(items, size)` is the same behavior as `inBatches(items, size)`.
83
+ - `groupByDepth(paths)` returns `{ depth, paths }[]` when you need the numeric depth.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Group paths deepest-first for bottom-up processing.
3
+ */
4
+ export declare function bottomUp(paths: readonly string[]): string[][];
5
+ //# sourceMappingURL=bottomUp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bottomUp.d.ts","sourceRoot":"","sources":["../src/bottomUp.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAI7D"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bottomUp = bottomUp;
4
+ const pathDepth_js_1 = require("./pathDepth.js");
5
+ /**
6
+ * Group paths deepest-first for bottom-up processing.
7
+ */
8
+ function bottomUp(paths) {
9
+ return (0, pathDepth_js_1.collectPathDepthGroups)(paths).map(({ paths: pathsAtDepth }) => {
10
+ return pathsAtDepth;
11
+ });
12
+ }
13
+ //# sourceMappingURL=bottomUp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bottomUp.js","sourceRoot":"","sources":["../src/bottomUp.ts"],"names":[],"mappings":";;AAKA,4BAIC;AATD,iDAAwD;AAExD;;GAEG;AACH,SAAgB,QAAQ,CAAC,KAAwB;IAC/C,OAAO,IAAA,qCAAsB,EAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE;QACnE,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/chunk.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Split an array into chunks of a given size.
3
3
  */
4
- export declare function chunk<T>(arr: readonly T[], size: number): T[][];
4
+ export declare function chunk<T>(items: readonly T[], size: number): T[][];
5
5
  //# sourceMappingURL=chunk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../src/chunk.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAU/D"}
1
+ {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../src/chunk.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAEjE"}
package/dist/chunk.js CHANGED
@@ -1,17 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.chunk = chunk;
4
+ const inBatches_js_1 = require("./inBatches.js");
4
5
  /**
5
6
  * Split an array into chunks of a given size.
6
7
  */
7
- function chunk(arr, size) {
8
- if (!Number.isInteger(size) || size <= 0) {
9
- throw new RangeError("size must be a positive integer");
10
- }
11
- const result = [];
12
- for (let i = 0; i < arr.length; i += size) {
13
- result.push(arr.slice(i, i + size));
14
- }
15
- return result;
8
+ function chunk(items, size) {
9
+ return (0, inBatches_js_1.inBatches)(items, size);
16
10
  }
17
11
  //# sourceMappingURL=chunk.js.map
package/dist/chunk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../src/chunk.ts"],"names":[],"mappings":";;AAGA,sBAUC;AAbD;;GAEG;AACH,SAAgB,KAAK,CAAI,GAAiB,EAAE,IAAY;IACtD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,UAAU,CAAC,iCAAiC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../src/chunk.ts"],"names":[],"mappings":";;AAKA,sBAEC;AAPD,iDAA2C;AAE3C;;GAEG;AACH,SAAgB,KAAK,CAAI,KAAmB,EAAE,IAAY;IACxD,OAAO,IAAA,wBAAS,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC"}
@@ -1,9 +1,8 @@
1
+ import { type PathDepthGroup } from "./pathDepth.js";
1
2
  /**
2
- * Group path strings by their `/`-separated depth, sorted deepest-first.
3
- * Useful for bottom-up directory processing where children must be handled before parents.
3
+ * Group path strings by their normalized `/`-separated depth, sorted deepest-first.
4
+ * Useful when callers still want explicit depth metadata.
4
5
  */
5
- export declare function groupByDepth(paths: readonly string[]): {
6
- depth: number;
7
- paths: string[];
8
- }[];
6
+ export declare function groupByDepth(paths: readonly string[]): PathDepthGroup[];
7
+ export type { PathDepthGroup };
9
8
  //# sourceMappingURL=groupByDepth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"groupByDepth.d.ts","sourceRoot":"","sources":["../src/groupByDepth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,CAgBtC"}
1
+ {"version":3,"file":"groupByDepth.d.ts","sourceRoot":"","sources":["../src/groupByDepth.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE7E;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,EAAE,CAEvE;AAED,YAAY,EAAE,cAAc,EAAE,CAAC"}
@@ -1,23 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.groupByDepth = groupByDepth;
4
+ const pathDepth_js_1 = require("./pathDepth.js");
4
5
  /**
5
- * Group path strings by their `/`-separated depth, sorted deepest-first.
6
- * Useful for bottom-up directory processing where children must be handled before parents.
6
+ * Group path strings by their normalized `/`-separated depth, sorted deepest-first.
7
+ * Useful when callers still want explicit depth metadata.
7
8
  */
8
9
  function groupByDepth(paths) {
9
- const depthMap = new Map();
10
- for (const p of paths) {
11
- const depth = p === "" ? 0 : p.split("/").length;
12
- let group = depthMap.get(depth);
13
- if (!group) {
14
- group = [];
15
- depthMap.set(depth, group);
16
- }
17
- group.push(p);
18
- }
19
- return [...depthMap.entries()]
20
- .sort(([a], [b]) => b - a)
21
- .map(([depth, paths]) => ({ depth, paths }));
10
+ return (0, pathDepth_js_1.collectPathDepthGroups)(paths);
22
11
  }
23
12
  //# sourceMappingURL=groupByDepth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"groupByDepth.js","sourceRoot":"","sources":["../src/groupByDepth.ts"],"names":[],"mappings":";;AAIA,oCAkBC;AAtBD;;;GAGG;AACH,SAAgB,YAAY,CAC1B,KAAwB;IAExB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE7C,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;QACjD,IAAI,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,EAAE,CAAC;YACX,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;SAC3B,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;SACzB,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC"}
1
+ {"version":3,"file":"groupByDepth.js","sourceRoot":"","sources":["../src/groupByDepth.ts"],"names":[],"mappings":";;AAMA,oCAEC;AARD,iDAA6E;AAE7E;;;GAGG;AACH,SAAgB,YAAY,CAAC,KAAwB;IACnD,OAAO,IAAA,qCAAsB,EAAC,KAAK,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Split work into sequential batches of a fixed size.
3
+ */
4
+ export declare function inBatches<T>(items: readonly T[], size: number): T[][];
5
+ //# sourceMappingURL=inBatches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inBatches.d.ts","sourceRoot":"","sources":["../src/inBatches.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAUrE"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inBatches = inBatches;
4
+ /**
5
+ * Split work into sequential batches of a fixed size.
6
+ */
7
+ function inBatches(items, size) {
8
+ if (!Number.isInteger(size) || size <= 0) {
9
+ throw new RangeError("size must be a positive integer");
10
+ }
11
+ const batches = [];
12
+ for (let index = 0; index < items.length; index += size) {
13
+ batches.push(items.slice(index, index + size));
14
+ }
15
+ return batches;
16
+ }
17
+ //# sourceMappingURL=inBatches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inBatches.js","sourceRoot":"","sources":["../src/inBatches.ts"],"names":[],"mappings":";;AAGA,8BAUC;AAbD;;GAEG;AACH,SAAgB,SAAS,CAAI,KAAmB,EAAE,IAAY;IAC5D,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,UAAU,CAAC,iCAAiC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,OAAO,GAAU,EAAE,CAAC;IAC1B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export { bottomUp } from "./bottomUp.js";
1
2
  export { chunk } from "./chunk.js";
2
- export { groupByDepth } from "./groupByDepth.js";
3
+ export { groupByDepth, type PathDepthGroup } from "./groupByDepth.js";
4
+ export { inBatches } from "./inBatches.js";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.groupByDepth = exports.chunk = void 0;
3
+ exports.inBatches = exports.groupByDepth = exports.chunk = exports.bottomUp = void 0;
4
+ var bottomUp_js_1 = require("./bottomUp.js");
5
+ Object.defineProperty(exports, "bottomUp", { enumerable: true, get: function () { return bottomUp_js_1.bottomUp; } });
4
6
  var chunk_js_1 = require("./chunk.js");
5
7
  Object.defineProperty(exports, "chunk", { enumerable: true, get: function () { return chunk_js_1.chunk; } });
6
8
  var groupByDepth_js_1 = require("./groupByDepth.js");
7
9
  Object.defineProperty(exports, "groupByDepth", { enumerable: true, get: function () { return groupByDepth_js_1.groupByDepth; } });
10
+ var inBatches_js_1 = require("./inBatches.js");
11
+ Object.defineProperty(exports, "inBatches", { enumerable: true, get: function () { return inBatches_js_1.inBatches; } });
8
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AAA1B,iGAAA,KAAK,OAAA;AACd,qDAAiD;AAAxC,+GAAA,YAAY,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AACjB,uCAAmC;AAA1B,iGAAA,KAAK,OAAA;AACd,qDAAsE;AAA7D,+GAAA,YAAY,OAAA;AACrB,+CAA2C;AAAlC,yGAAA,SAAS,OAAA"}
@@ -0,0 +1,7 @@
1
+ export interface PathDepthGroup {
2
+ depth: number;
3
+ paths: string[];
4
+ }
5
+ /** Group paths by depth, sorted from deepest to shallowest. */
6
+ export declare function collectPathDepthGroups(paths: readonly string[]): PathDepthGroup[];
7
+ //# sourceMappingURL=pathDepth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathDepth.d.ts","sourceRoot":"","sources":["../src/pathDepth.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAUD,+DAA+D;AAC/D,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,cAAc,EAAE,CAiBlB"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectPathDepthGroups = collectPathDepthGroups;
4
+ function getPathDepth(path) {
5
+ if (path === "") {
6
+ return 0;
7
+ }
8
+ return path.split("/").filter((segment) => segment.length > 0).length;
9
+ }
10
+ /** Group paths by depth, sorted from deepest to shallowest. */
11
+ function collectPathDepthGroups(paths) {
12
+ const depthMap = new Map();
13
+ for (const path of paths) {
14
+ const depth = getPathDepth(path);
15
+ const group = depthMap.get(depth);
16
+ if (group) {
17
+ group.push(path);
18
+ continue;
19
+ }
20
+ depthMap.set(depth, [path]);
21
+ }
22
+ return [...depthMap.entries()]
23
+ .sort(([a], [b]) => b - a)
24
+ .map(([depth, pathsAtDepth]) => ({ depth, paths: pathsAtDepth }));
25
+ }
26
+ //# sourceMappingURL=pathDepth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathDepth.js","sourceRoot":"","sources":["../src/pathDepth.ts"],"names":[],"mappings":";;AAcA,wDAmBC;AA5BD,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;AACxE,CAAC;AAED,+DAA+D;AAC/D,SAAgB,sBAAsB,CACpC,KAAwB;IAExB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE7C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,SAAS;QACX,CAAC;QAED,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;SAC3B,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;SACzB,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;AACtE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardlydifficult/collections",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -15,7 +15,7 @@
15
15
  "clean": "node --eval \"fs.rmSync('dist', { recursive: true, force: true })\""
16
16
  },
17
17
  "devDependencies": {
18
- "@types/node": "25.3.2",
18
+ "@types/node": "25.3.5",
19
19
  "typescript": "5.9.3",
20
20
  "vitest": "4.0.18",
21
21
  "@vitest/coverage-v8": "4.0.18"