path-treeify 1.1.0-beta.94a5d17 → 1.2.0-beta.67126e2

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
@@ -38,9 +38,9 @@
38
38
  - 🌲 Builds a recursive tree from one or more directory paths
39
39
  - 🔗 Each node carries a `parent` circular reference for upward traversal
40
40
  - 📍 Each node exposes a `getPath()` method to retrieve its own paths directly
41
- - 🔍 Optional `filter` callback to include/exclude directories during scanning
41
+ - 🔍 Optional `filter` callback applied at **every depth**, including top-level directories
42
42
  - ⚡ `build()` scans the entire `base` directory with zero configuration
43
- - 🎛️ `buildBy()` accepts either a directory name array or a filter function
43
+ - 🎛️ `buildBy()` accepts either a directory name array or a top-level filter function
44
44
  - 📦 Ships as both ESM (`index.mjs`) and CJS (`index.cjs`) with full TypeScript types
45
45
  - 🚫 Zero runtime dependencies
46
46
 
@@ -74,8 +74,8 @@ const treeify = new PathTreeify({ base: '/your/project/root' });
74
74
  // Scan specific directories by name
75
75
  const tree = treeify.buildBy(['src', 'tests']);
76
76
 
77
- // Scan with a filter function over all top-level directories
78
- const filtered = treeify.buildBy(name => !name.startsWith('.') && name !== 'node_modules');
77
+ // Scan with a top-level filter function
78
+ const filtered = treeify.buildBy(name => name !== 'node_modules' && !name.startsWith('.'));
79
79
 
80
80
  // Or scan everything under base at once
81
81
  const fullTree = treeify.build();
@@ -89,10 +89,10 @@ const fullTree = treeify.build();
89
89
 
90
90
  Creates a new instance.
91
91
 
92
- | Option | Type | Required | Description |
93
- |----------|-------------------------------|----------|----------------------------------------------------|
94
- | `base` | `string` | ✅ | Absolute path to the root directory to scan from |
95
- | `filter` | `FilterFunction` (see below) | ❌ | Called for every directory found during deep traversal |
92
+ | Option | Type | Required | Description |
93
+ |----------|-------------------------------|----------|-----------------------------------------------------------------------------|
94
+ | `base` | `string` | ✅ | Absolute path to the root directory to scan from |
95
+ | `filter` | `FilterFunction` (see below) | ❌ | Applied at **every depth** top-level directories included |
96
96
 
97
97
  `base` must exist and be a directory, otherwise the constructor throws.
98
98
 
@@ -100,7 +100,7 @@ Creates a new instance.
100
100
 
101
101
  ### `FilterFunction`
102
102
 
103
- Used as the `filter` option in the constructor. Applied recursively during deep traversal of the tree.
103
+ Used as the `filter` option in the constructor. Applied at every level of the tree, including the immediate children of `base`.
104
104
 
105
105
  ```ts
106
106
  type FilterFunction = (params: {
@@ -109,14 +109,14 @@ type FilterFunction = (params: {
109
109
  }) => boolean;
110
110
  ```
111
111
 
112
- Return `true` to **include** the directory and recurse into it; `false` to **skip** it.
112
+ Return `true` to **include** the directory and recurse into it; `false` to **skip** it entirely.
113
113
 
114
- **Example — skip hidden directories and `node_modules` at every level:**
114
+ **Example — exclude `node_modules` and hidden directories at every depth:**
115
115
 
116
116
  ```ts
117
117
  const treeify = new PathTreeify({
118
118
  base: '/your/project',
119
- filter: ({ name }) => !name.startsWith('.') && name !== 'node_modules',
119
+ filter: ({ name }) => name !== 'node_modules' && !name.startsWith('.'),
120
120
  });
121
121
  ```
122
122
 
@@ -124,7 +124,7 @@ const treeify = new PathTreeify({
124
124
 
125
125
  ### `build(): PathTreeNode`
126
126
 
127
- Scans **all** subdirectories directly under `base` and returns a synthetic root `PathTreeNode`. This is the zero-configuration shorthand.
127
+ Scans all subdirectories directly under `base` (applying the instance-level `filter` if set) and returns a synthetic root `PathTreeNode`.
128
128
 
129
129
  ```ts
130
130
  const tree = treeify.build();
@@ -145,13 +145,13 @@ const tree = treeify.buildBy(['src', 'docs', 'tests']);
145
145
 
146
146
  ### `buildBy(filter: (dirName: string) => boolean): PathTreeNode`
147
147
 
148
- Collects all top-level subdirectories under `base`, applies the given filter function, then builds a tree from the matching names.
148
+ Collects all top-level subdirectories under `base`, applies the given predicate to select which ones to include, then builds a tree from the matching names. The instance-level `filter` still applies during deep traversal.
149
149
 
150
150
  ```ts
151
151
  const tree = treeify.buildBy(name => name !== 'node_modules' && !name.startsWith('.'));
152
152
  ```
153
153
 
154
- > Note: this `filter` operates only on the **top-level** directory names under `base`. For filtering at every depth, pass a `filter` to the constructor instead.
154
+ > **Note:** the predicate passed to `buildBy(fn)` only selects which **top-level** directories to include. To filter directories at every depth, pass a `filter` to the constructor.
155
155
 
156
156
  ---
157
157
 
@@ -161,6 +161,8 @@ Walks a node's `parent` chain to reconstruct its full path. Equivalent to callin
161
161
 
162
162
  ```ts
163
163
  const { relative, absolute } = treeify.getPathBy(node);
164
+ // relative → e.g. 'src/components'
165
+ // absolute → e.g. '/your/project/src/components'
164
166
  ```
165
167
 
166
168
  ---
@@ -179,7 +181,7 @@ class PathTreeNode {
179
181
  }
180
182
  ```
181
183
 
182
- **`node.getPath()`** returns the same result as `treeify.getPathBy(node)` — both are available for convenience.
184
+ `node.getPath()` returns the same result as `treeify.getPathBy(node)` — both are available for convenience.
183
185
 
184
186
  > ⚠️ **Circular references** — `parent` points back up the tree. Use `JSON.stringify` replacers or a library like `flatted` if you need to serialize the result.
185
187
 
@@ -196,26 +198,26 @@ const treeify = new PathTreeify({ base: '/your/project' });
196
198
  const tree = treeify.build();
197
199
  ```
198
200
 
199
- ### Scan specific directories
201
+ ### Exclude directories at every depth via constructor filter
200
202
 
201
203
  ```ts
202
- const tree = treeify.buildBy(['src', 'tests', 'docs']);
204
+ const treeify = new PathTreeify({
205
+ base: '/your/project',
206
+ filter: ({ name }) => name !== 'node_modules' && !name.startsWith('.'),
207
+ });
208
+ const tree = treeify.build();
203
209
  ```
204
210
 
205
- ### Filter top-level directories
211
+ ### Scan specific directories
206
212
 
207
213
  ```ts
208
- const tree = treeify.buildBy(name => name !== 'node_modules' && !name.startsWith('.'));
214
+ const tree = treeify.buildBy(['src', 'tests', 'docs']);
209
215
  ```
210
216
 
211
- ### Filter at every depth via constructor
217
+ ### Select top-level directories with a predicate
212
218
 
213
219
  ```ts
214
- const treeify = new PathTreeify({
215
- base: '/your/project',
216
- filter: ({ name }) => name !== 'node_modules' && !name.startsWith('.'),
217
- });
218
- const tree = treeify.build();
220
+ const tree = treeify.buildBy(name => name !== 'node_modules' && !name.startsWith('.'));
219
221
  ```
220
222
 
221
223
  ### Retrieve paths via `node.getPath()`
@@ -245,4 +247,4 @@ const tree = treeify.build();
245
247
 
246
248
  ## License
247
249
 
248
- [MIT](https://github.com/isaaxite/path-treeify/blob/main/LICENSE) © [isaaxite](https://github.com/isaaxite)
250
+ [MIT](https://github.com/isaaxite/path-treeify/blob/main/LICENSE) © [isaaxite](https://github.com/isaaxite)
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("fs"),r=require("path");class e{static isValid(r){try{return t.accessSync(r,t.constants.F_OK),!0}catch{return!1}}static isDirectory(r){try{return t.statSync(r).isDirectory()}catch{return!1}}}class i{constructor(t){this.parent=null,this.value="",this.children=[],this.base=t}getPath(){let t="",e=this;for(;e.parent;)t=t?`${e.value}${r.sep}${t}`:e.value,e=e.parent;return{relative:t,absolute:r.resolve(this.base,t)}}}exports.PathTreeify=class{constructor({filter:t,base:r}){if(void 0!==t&&(this.validateFilter(t),this.filter=t),!r||!e.isValid(r))throw new Error(`${r} is not a valid path!`);if(!e.isDirectory(r))throw new Error(`${r} is not a dirPath!`);this.base=r}validateFilter(t){if("function"!=typeof t)throw new TypeError("filter must be a function");if(1!==t.length)throw new TypeError("filter must accept exactly one parameter");try{if("boolean"!=typeof t({name:"test",postPath:"/test"}))throw new TypeError("filter must return a boolean")}catch(t){throw new TypeError("filter function threw an error during test: "+t)}}initNode(t=null){const r=new i(this.base);return t&&(r.parent=t),r}buildChildren(e,i){const s=t.readdirSync(e),a=[];for(const n of s){const s=r.join(e,n);if(!t.statSync(s).isDirectory())continue;if(this.filter&&!this.filter({dirPath:e,name:n}))continue;const o=this.initNode();o.value=n,o.parent=i,o.children=this.buildChildren(s,o),a.push(o)}return a}checkRelativePaths(t){if(!Array.isArray(t))throw new Error("Expected array, got "+typeof t);for(let i=0;i<t.length;i++){const s=t[i];if("string"!=typeof s)throw new Error(`Item at index ${i} is not a string, got ${typeof s}`);const a=r.resolve(this.base,s);if(!e.isValid(a))throw new Error(`Path does not exist or is not accessible: ${a} (from relative path: ${s})`);if(!e.isDirectory(a))throw new Error(`Path is not a directory: ${a} (from relative path: ${s})`)}}formatDirnames(t){return t.map(t=>t.replace(/^\/+|\/+$/g,"")).filter(t=>""!==t)}getAllDirNamesUnderBase(){return t.readdirSync(this.base).filter(t=>{const i=r.resolve(this.base,t);return e.isDirectory(i)})}buildByDirNames(t){const e=this.initNode();this.checkRelativePaths(t);const i=this.formatDirnames(t);for(const t of i){const i=this.initNode();i.value=t,i.parent=e,i.children=this.buildChildren(r.resolve(this.base,t),i),e.children.push(i)}return e}buildByFilter(t){const r=this.getAllDirNamesUnderBase();return this.buildByDirNames(r.filter(t))}getPathBy(t){let e="",i=t;for(;i.parent;)e=e?`${i.value}${r.sep}${e}`:i.value,i=i.parent;return{relative:e,absolute:r.resolve(this.base,e)}}buildBy(t){if(Array.isArray(t))return this.buildByDirNames(t);if("function"==typeof t)return this.buildByFilter(t);throw new TypeError("buildBy: expected an array of strings or a filter function, but received "+typeof t)}build(){const t=this.getAllDirNamesUnderBase();return this.buildByDirNames(t)}};
1
+ "use strict";var t=require("fs"),e=require("path");class r{static isValid(e){try{return t.accessSync(e,t.constants.F_OK),!0}catch{return!1}}static isDirectory(e){try{return t.statSync(e).isDirectory()}catch{return!1}}}class i{constructor(t){this.parent=null,this.value="",this.children=[],this.base=t}getPath(){let t="",r=this;for(;r.parent;)t=t?`${r.value}${e.sep}${t}`:r.value,r=r.parent;return{relative:t,absolute:e.resolve(this.base,t)}}}exports.PathTreeify=class{constructor({filter:t,base:e}){if(void 0!==t&&(this.validateFilter(t),this.filter=t),!e||!r.isValid(e))throw new Error(`${e} is not a valid path!`);if(!r.isDirectory(e))throw new Error(`${e} is not a dirPath!`);this.base=e}validateFilter(t){if("function"!=typeof t)throw new TypeError("filter must be a function");if(1!==t.length)throw new TypeError("filter must accept exactly one parameter");try{if("boolean"!=typeof t({name:"test",postPath:"/test"}))throw new TypeError("filter must return a boolean")}catch(t){throw new TypeError("filter function threw an error during test: "+t)}}initNode(t=null){const e=new i(this.base);return t&&(e.parent=t),e}buildChildren(r,i){const s=t.readdirSync(r),a=[];for(const n of s){const s=e.join(r,n);if(!t.statSync(s).isDirectory())continue;if(this.filter&&!this.filter({dirPath:r,name:n}))continue;const o=this.initNode();o.value=n,o.parent=i,o.children=this.buildChildren(s,o),a.push(o)}return a}checkRelativePaths(t){if(!Array.isArray(t))throw new Error("Expected array, got "+typeof t);for(let i=0;i<t.length;i++){const s=t[i];if("string"!=typeof s)throw new Error(`Item at index ${i} is not a string, got ${typeof s}`);const a=e.resolve(this.base,s);if(!r.isValid(a))throw new Error(`Path does not exist or is not accessible: ${a} (from relative path: ${s})`);if(!r.isDirectory(a))throw new Error(`Path is not a directory: ${a} (from relative path: ${s})`)}}formatDirnames(t){return t.map(t=>t.replace(/^\/+|\/+$/g,"")).filter(t=>""!==t)}getAllDirNamesUnderBase(){return t.readdirSync(this.base).filter(t=>{const i=e.resolve(this.base,t);return!!r.isDirectory(i)&&!(this.filter&&!this.filter({name:t,dirPath:this.base}))})}buildByDirNames(t){const r=this.initNode(),i=this.formatDirnames(t);this.checkRelativePaths(i);for(const t of i){const i=this.initNode();i.value=t,i.parent=r,i.children=this.buildChildren(e.resolve(this.base,t),i),r.children.push(i)}return r}buildByFilter(t){const e=this.getAllDirNamesUnderBase();return this.buildByDirNames(e.filter(t))}getPathBy(t){let r="",i=t;for(;i.parent;)r=r?`${i.value}${e.sep}${r}`:i.value,i=i.parent;return{relative:r,absolute:e.resolve(this.base,r)}}buildBy(t){if(Array.isArray(t))return this.buildByDirNames(t);if("function"==typeof t)return this.buildByFilter(t);throw new TypeError("buildBy: expected an array of strings or a filter function, but received "+typeof t)}build(){const t=this.getAllDirNamesUnderBase();return this.buildByDirNames(t)}};
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{readdirSync as t,statSync as r,accessSync as e,constants as i}from"fs";import{join as s,resolve as a,sep as n}from"path";class o{static isValid(t){try{return e(t,i.F_OK),!0}catch{return!1}}static isDirectory(t){try{return r(t).isDirectory()}catch{return!1}}}class l{constructor(t){this.parent=null,this.value="",this.children=[],this.base=t}getPath(){let t="",r=this;for(;r.parent;)t=t?`${r.value}${n}${t}`:r.value,r=r.parent;return{relative:t,absolute:a(this.base,t)}}}class h{constructor({filter:t,base:r}){if(void 0!==t&&(this.validateFilter(t),this.filter=t),!r||!o.isValid(r))throw new Error(`${r} is not a valid path!`);if(!o.isDirectory(r))throw new Error(`${r} is not a dirPath!`);this.base=r}validateFilter(t){if("function"!=typeof t)throw new TypeError("filter must be a function");if(1!==t.length)throw new TypeError("filter must accept exactly one parameter");try{if("boolean"!=typeof t({name:"test",postPath:"/test"}))throw new TypeError("filter must return a boolean")}catch(t){throw new TypeError("filter function threw an error during test: "+t)}}initNode(t=null){const r=new l(this.base);return t&&(r.parent=t),r}buildChildren(e,i){const a=t(e),n=[];for(const t of a){const a=s(e,t);if(!r(a).isDirectory())continue;if(this.filter&&!this.filter({dirPath:e,name:t}))continue;const o=this.initNode();o.value=t,o.parent=i,o.children=this.buildChildren(a,o),n.push(o)}return n}checkRelativePaths(t){if(!Array.isArray(t))throw new Error("Expected array, got "+typeof t);for(let r=0;r<t.length;r++){const e=t[r];if("string"!=typeof e)throw new Error(`Item at index ${r} is not a string, got ${typeof e}`);const i=a(this.base,e);if(!o.isValid(i))throw new Error(`Path does not exist or is not accessible: ${i} (from relative path: ${e})`);if(!o.isDirectory(i))throw new Error(`Path is not a directory: ${i} (from relative path: ${e})`)}}formatDirnames(t){return t.map(t=>t.replace(/^\/+|\/+$/g,"")).filter(t=>""!==t)}getAllDirNamesUnderBase(){return t(this.base).filter(t=>{const r=a(this.base,t);return o.isDirectory(r)})}buildByDirNames(t){const r=this.initNode();this.checkRelativePaths(t);const e=this.formatDirnames(t);for(const t of e){const e=this.initNode();e.value=t,e.parent=r,e.children=this.buildChildren(a(this.base,t),e),r.children.push(e)}return r}buildByFilter(t){const r=this.getAllDirNamesUnderBase();return this.buildByDirNames(r.filter(t))}getPathBy(t){let r="",e=t;for(;e.parent;)r=r?`${e.value}${n}${r}`:e.value,e=e.parent;return{relative:r,absolute:a(this.base,r)}}buildBy(t){if(Array.isArray(t))return this.buildByDirNames(t);if("function"==typeof t)return this.buildByFilter(t);throw new TypeError("buildBy: expected an array of strings or a filter function, but received "+typeof t)}build(){const t=this.getAllDirNamesUnderBase();return this.buildByDirNames(t)}}export{h as PathTreeify};
1
+ import{readdirSync as t,statSync as r,accessSync as e,constants as i}from"fs";import{join as s,resolve as a,sep as n}from"path";class o{static isValid(t){try{return e(t,i.F_OK),!0}catch{return!1}}static isDirectory(t){try{return r(t).isDirectory()}catch{return!1}}}class l{constructor(t){this.parent=null,this.value="",this.children=[],this.base=t}getPath(){let t="",r=this;for(;r.parent;)t=t?`${r.value}${n}${t}`:r.value,r=r.parent;return{relative:t,absolute:a(this.base,t)}}}class h{constructor({filter:t,base:r}){if(void 0!==t&&(this.validateFilter(t),this.filter=t),!r||!o.isValid(r))throw new Error(`${r} is not a valid path!`);if(!o.isDirectory(r))throw new Error(`${r} is not a dirPath!`);this.base=r}validateFilter(t){if("function"!=typeof t)throw new TypeError("filter must be a function");if(1!==t.length)throw new TypeError("filter must accept exactly one parameter");try{if("boolean"!=typeof t({name:"test",postPath:"/test"}))throw new TypeError("filter must return a boolean")}catch(t){throw new TypeError("filter function threw an error during test: "+t)}}initNode(t=null){const r=new l(this.base);return t&&(r.parent=t),r}buildChildren(e,i){const a=t(e),n=[];for(const t of a){const a=s(e,t);if(!r(a).isDirectory())continue;if(this.filter&&!this.filter({dirPath:e,name:t}))continue;const o=this.initNode();o.value=t,o.parent=i,o.children=this.buildChildren(a,o),n.push(o)}return n}checkRelativePaths(t){if(!Array.isArray(t))throw new Error("Expected array, got "+typeof t);for(let r=0;r<t.length;r++){const e=t[r];if("string"!=typeof e)throw new Error(`Item at index ${r} is not a string, got ${typeof e}`);const i=a(this.base,e);if(!o.isValid(i))throw new Error(`Path does not exist or is not accessible: ${i} (from relative path: ${e})`);if(!o.isDirectory(i))throw new Error(`Path is not a directory: ${i} (from relative path: ${e})`)}}formatDirnames(t){return t.map(t=>t.replace(/^\/+|\/+$/g,"")).filter(t=>""!==t)}getAllDirNamesUnderBase(){return t(this.base).filter(t=>{const r=a(this.base,t);return!!o.isDirectory(r)&&!(this.filter&&!this.filter({name:t,dirPath:this.base}))})}buildByDirNames(t){const r=this.initNode(),e=this.formatDirnames(t);this.checkRelativePaths(e);for(const t of e){const e=this.initNode();e.value=t,e.parent=r,e.children=this.buildChildren(a(this.base,t),e),r.children.push(e)}return r}buildByFilter(t){const r=this.getAllDirNamesUnderBase();return this.buildByDirNames(r.filter(t))}getPathBy(t){let r="",e=t;for(;e.parent;)r=r?`${e.value}${n}${r}`:e.value,e=e.parent;return{relative:r,absolute:a(this.base,r)}}buildBy(t){if(Array.isArray(t))return this.buildByDirNames(t);if("function"==typeof t)return this.buildByFilter(t);throw new TypeError("buildBy: expected an array of strings or a filter function, but received "+typeof t)}build(){const t=this.getAllDirNamesUnderBase();return this.buildByDirNames(t)}}export{h as PathTreeify};
@@ -1,40 +1,93 @@
1
+ /** A filter function that determines whether a directory should be included in the tree */
1
2
  type FilterFunction = (params: {
2
3
  name: string;
3
4
  dirPath: string;
4
5
  }) => boolean;
6
+ /** Constructor options for PathTreeify */
5
7
  interface PathTreeifyProps {
6
8
  base: string;
7
9
  filter?: FilterFunction;
8
10
  }
11
+ /** Represents a single node (directory) in the path tree */
9
12
  declare class PathTreeNode {
13
+ /** The root base path used to resolve absolute paths */
10
14
  private base;
15
+ /** Reference to the parent node; null for the root node */
11
16
  parent: PathTreeNode | null;
17
+ /** The directory name of this node (not a full path) */
12
18
  value: string;
19
+ /** Child nodes representing subdirectories */
13
20
  children: PathTreeNode[];
14
21
  constructor(base: string);
22
+ /**
23
+ * Walks up the parent chain to compute this node's relative and absolute paths.
24
+ * @returns An object containing the relative path from base and the absolute path
25
+ */
15
26
  getPath(): {
16
27
  relative: string;
17
28
  absolute: string;
18
29
  };
19
30
  }
31
+ /** Builds a tree of directory nodes rooted at a given base path */
20
32
  export declare class PathTreeify {
33
+ /** The root directory to scan */
21
34
  private base;
35
+ /** Optional filter applied to each directory during traversal */
22
36
  private filter?;
23
37
  constructor({ filter, base }: Partial<PathTreeifyProps>);
38
+ /**
39
+ * Validates that the provided filter is a function, accepts one parameter,
40
+ * and returns a boolean. Throws a TypeError if any condition is violated.
41
+ */
24
42
  private validateFilter;
43
+ /**
44
+ * Creates and optionally attaches a new PathTreeNode to a parent.
45
+ * @param parent - The parent node to attach to, or null for the root
46
+ */
25
47
  private initNode;
48
+ /**
49
+ * Recursively reads a directory and builds child nodes for each subdirectory.
50
+ * Applies the instance-level filter if one is set.
51
+ * @param dirPath - Absolute path of the directory to read
52
+ * @param parent - The parent node to attach children to
53
+ */
26
54
  private buildChildren;
55
+ /**
56
+ * Validates that each entry in the array is a string pointing to
57
+ * an accessible directory relative to the base path.
58
+ * @param relativeDirNames - Array of relative directory path strings to validate
59
+ */
27
60
  private checkRelativePaths;
61
+ /**
62
+ * Strips leading and trailing slashes from each directory name
63
+ * and removes any resulting empty strings.
64
+ */
28
65
  private formatDirnames;
66
+ /** Returns the names of all immediate subdirectories under the base path */
29
67
  private getAllDirNamesUnderBase;
68
+ /**
69
+ * Builds a tree rooted at base, containing only the specified subdirectories.
70
+ * @param dirNames - Relative directory names to include as top-level nodes
71
+ */
30
72
  private buildByDirNames;
73
+ /**
74
+ * Builds a tree using only the subdirectories under base that pass the given filter.
75
+ * @param filter - A predicate applied to each top-level directory name
76
+ */
31
77
  private buildByFilter;
78
+ /**
79
+ * Computes the relative and absolute paths for a given node
80
+ * by walking up the parent chain.
81
+ */
32
82
  getPathBy(node: PathTreeNode): {
33
83
  relative: string;
34
84
  absolute: string;
35
85
  };
86
+ /** Overload: build the tree from an explicit list of relative directory names */
36
87
  buildBy(dirNames: string[]): PathTreeNode;
88
+ /** Overload: build the tree from a predicate applied to top-level directory names */
37
89
  buildBy(filter: (dirName: string) => boolean): PathTreeNode;
90
+ /** Builds a full tree from all immediate subdirectories under the base path */
38
91
  build(): PathTreeNode;
39
92
  }
40
93
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "path-treeify",
3
- "version": "1.1.0-beta.94a5d17",
3
+ "version": "1.2.0-beta.67126e2",
4
4
  "description": "Convert a path or an array of paths into a tree-structured JavaScript object, where each node has a `parent` property that holds a circular reference to its parent node.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -24,7 +24,8 @@
24
24
  "dist/**/*.d.ts"
25
25
  ],
26
26
  "scripts": {
27
- "test": "echo \"Error: no test specified\" && exit 1",
27
+ "test": "ava",
28
+ "test:watch": "ava --watch",
28
29
  "clean": "rimraf ./dist",
29
30
  "build": "npm run clean && rollup -c",
30
31
  "build:dev": "NODE_ENV=development npm run build",
@@ -34,6 +35,14 @@
34
35
  "publish:beta": "npm publish --tag beta --access public",
35
36
  "publish:latest": "npm publish --tag latest --access public"
36
37
  },
38
+ "ava": {
39
+ "files": [
40
+ "tests/**/*.mjs"
41
+ ],
42
+ "nodeArguments": [
43
+ "--experimental-vm-modules"
44
+ ]
45
+ },
37
46
  "repository": {
38
47
  "type": "git",
39
48
  "url": "git+https://github.com/isaaxite/path-treeify.git"
@@ -62,6 +71,7 @@
62
71
  "@rollup/plugin-terser": "^1.0.0",
63
72
  "@rollup/plugin-typescript": "^12.3.0",
64
73
  "@types/node": "^25.5.0",
74
+ "ava": "^7.0.0",
65
75
  "nodemon": "^3.1.14",
66
76
  "rimraf": "^6.1.3",
67
77
  "rollup": "^4.59.0",