@sapphire/node-utilities 1.1.0-pr-601.2f2c308a.0 → 1.1.0-pr-935.7da5c8bb

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/CHANGELOG.md CHANGED
@@ -2,6 +2,41 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ # [@sapphire/node-utilities@1.0.2](https://github.com/sapphiredev/utilities/compare/@sapphire/node-utilities@1.0.2...@sapphire/node-utilities@1.0.2) - (2024-01-19)
6
+
7
+ ## 🐛 Bug Fixes
8
+
9
+ - Fixed commonjs typings export mapping (#707) ([216ff02](https://github.com/sapphiredev/utilities/commit/216ff0260d63a9590357f9a5069f1ae2b34eaf5d))
10
+
11
+ # [@sapphire/node-utilities@1.0.1](https://github.com/sapphiredev/utilities/compare/@sapphire/node-utilities@1.0.1...@sapphire/node-utilities@1.0.1) - (2023-12-04)
12
+
13
+ ## 🐛 Bug Fixes
14
+
15
+ - **node-utilities:** Properly split CJS and ESM ([360fe19](https://github.com/sapphiredev/utilities/commit/360fe1983e7db6d6a61c5f79ac399f74f9993410))
16
+ - Update export mapping for proper ESM/CJS split ([dd0cff8](https://github.com/sapphiredev/utilities/commit/dd0cff8e9b03a15812f25f7a1180501a92422629))
17
+ - **deps:** Update all non-major dependencies (#607) ([9cc8bd0](https://github.com/sapphiredev/utilities/commit/9cc8bd0d4b5d650deab2c913e6c3d713861bae28))
18
+ - **deps:** Update all non-major dependencies (#577) ([291dd67](https://github.com/sapphiredev/utilities/commit/291dd6783e57d8f075ce566218ba076ef6c4bbbd))
19
+ - **deps:** Update all non-major dependencies (#545) ([40ca040](https://github.com/sapphiredev/utilities/commit/40ca040a21d8a0949682051a3a974538183a400e))
20
+ - **deps:** Update all non-major dependencies (#544) ([cc78f17](https://github.com/sapphiredev/utilities/commit/cc78f17390c7f3db08af92bf46a5a70a9c11dd5f))
21
+ - **deps:** Update all non-major dependencies (#532) ([8033d1f](https://github.com/sapphiredev/utilities/commit/8033d1ff7a5a1974134c61f424f171cccb2915e1))
22
+ - **deps:** Update all non-major dependencies (#514) ([21b07d5](https://github.com/sapphiredev/utilities/commit/21b07d5db529a0d982647a60de98e46f36f1ac93))
23
+ - **deps:** Update all non-major dependencies (#505) ([6178296](https://github.com/sapphiredev/utilities/commit/617829649e1e4deeee02b14533b5377cd5bc1fb3))
24
+
25
+ ## 📝 Documentation
26
+
27
+ - Fixed docs using incorrect reference format ([615d930](https://github.com/sapphiredev/utilities/commit/615d930570fdf8e0c743df1c91f30f280fdd2813))
28
+ - Add @06000208 as a contributor ([fa3349e](https://github.com/sapphiredev/utilities/commit/fa3349e55ce4ad008785211dec7bf8e2b5d933df))
29
+ - Add @didinele as a contributor ([42ef7b6](https://github.com/sapphiredev/utilities/commit/42ef7b656c48fd0e720119db1d622c8bba2791e9))
30
+ - Add @goestav as a contributor ([0e56a92](https://github.com/sapphiredev/utilities/commit/0e56a92a4e2d0942bfa207f81a8cb03b32312034))
31
+ - Add @CitTheDev as a contributor ([34169ea](https://github.com/sapphiredev/utilities/commit/34169eae1dc0476ccf5a6c4f36e28602a204829e))
32
+ - Add @legendhimslef as a contributor ([059b6f1](https://github.com/sapphiredev/utilities/commit/059b6f1ab5362d46d58624d06c1aa39192b0716f))
33
+ - **node-utilities:** Add usage (#500) ([6f1210d](https://github.com/sapphiredev/utilities/commit/6f1210d90f14422289e8493aeed9a2e1769241b2))
34
+ - Add @r-priyam as a contributor ([fb278ba](https://github.com/sapphiredev/utilities/commit/fb278bacf627ec6fc88752eafeb12df5f3177a2c))
35
+
36
+ ## 🧪 Testing
37
+
38
+ - Update vitest to coverage v8 ([a4bc6e4](https://github.com/sapphiredev/utilities/commit/a4bc6e4f24ea60143a150ecc76fda6484f172ab9))
39
+
5
40
  # [@sapphire/node-utilities@1.0.0](https://github.com/sapphiredev/utilities/tree/@sapphire/node-utilities@1.0.0) - (2022-10-02)
6
41
 
7
42
  ## 🚀 Features
package/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  **Common NodeJS utilities for the Sapphire Community.**
8
8
 
9
9
  [![GitHub](https://img.shields.io/github/license/sapphiredev/utilities)](https://github.com/sapphiredev/utilities/blob/main/LICENSE.md)
10
- [![codecov](https://codecov.io/gh/sapphiredev/utilities/branch/main/graph/badge.svg?token=OEGIV6RFDO)](https://codecov.io/gh/sapphiredev/utilities)
11
10
  [![npm bundle size](https://img.shields.io/bundlephobia/min/@sapphire/node-utilities?logo=webpack&style=flat-square)](https://bundlephobia.com/result?p=@sapphire/node-utilities)
12
11
  [![npm](https://img.shields.io/npm/v/@sapphire/node-utilities?color=crimson&logo=npm&style=flat-square)](https://www.npmjs.com/package/@sapphire/node-utilities)
13
12
 
@@ -20,7 +19,7 @@
20
19
  - [Usage](#usage)
21
20
  - [`findFilesRecursively`](#findfilesrecursively)
22
21
  - [Buy us some doughnuts](#buy-us-some-doughnuts)
23
- - [Contributors](#contributors-)
22
+ - [Contributors](#contributors)
24
23
 
25
24
  ## Features
26
25
 
@@ -38,5 +38,5 @@ exports.findFilesRecursivelyRegex = findFilesRecursivelyRegex;
38
38
  exports.findFilesRecursivelyStringEndsWith = findFilesRecursivelyStringEndsWith;
39
39
  exports.findFilesRecursivelyStringIncludes = findFilesRecursivelyStringIncludes;
40
40
  exports.findFilesRecursivelyStringStartsWith = findFilesRecursivelyStringStartsWith;
41
- //# sourceMappingURL=out.js.map
42
- //# sourceMappingURL=index.js.map
41
+ //# sourceMappingURL=index.cjs.map
42
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/findFilesRecursively.ts"],"names":["path","opendir","join"],"mappings":";;;;;;;AA6BA,gBAAuB,oBAAA,CAAqBA,MAAA,EAAgB,SAAA,GAA2C,MAAM,IAAA,EAAqC;AACjJ,EAAA,MAAM,GAAA,GAAM,MAAMC,gBAAA,CAAQD,MAAI,CAAA;AAE9B,EAAA,WAAA,MAAiB,QAAQ,GAAA,EAAK;AAC7B,IAAA,IAAI,KAAK,MAAA,EAAO,IAAK,SAAA,CAAU,IAAA,CAAK,IAAI,CAAA,EAAG;AAC1C,MAAA,MAAME,SAAA,CAAK,GAAA,CAAI,IAAA,EAAM,IAAA,CAAK,IAAI,CAAA;AAAA,IAC/B,CAAA,MAAA,IAAW,IAAA,CAAK,WAAA,EAAY,EAAG;AAC9B,MAAA,OAAO,qBAAqBA,SAAA,CAAK,GAAA,CAAI,MAAM,IAAA,CAAK,IAAI,GAAG,SAAS,CAAA;AAAA,IACjE;AAAA,EACD;AACD;AAVuB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA;AAqBhB,SAAS,oCAAA,CAAqC,MAAgB,cAAA,EAAwB;AAC5F,EAAA,OAAO,qBAAqB,IAAA,EAAM,CAAC,aAAa,QAAA,CAAS,UAAA,CAAW,cAAc,CAAC,CAAA;AACpF;AAFgB,MAAA,CAAA,oCAAA,EAAA,sCAAA,CAAA;AAcT,SAAS,kCAAA,CAAmC,MAAgB,YAAA,EAAsB;AACxF,EAAA,OAAO,qBAAqB,IAAA,EAAM,CAAC,aAAa,QAAA,CAAS,QAAA,CAAS,YAAY,CAAC,CAAA;AAChF;AAFgB,MAAA,CAAA,kCAAA,EAAA,oCAAA,CAAA;AAYT,SAAS,kCAAA,CAAmC,MAAgB,OAAA,EAAiB;AACnF,EAAA,OAAO,qBAAqB,IAAA,EAAM,CAAC,aAAa,QAAA,CAAS,QAAA,CAAS,OAAO,CAAC,CAAA;AAC3E;AAFgB,MAAA,CAAA,kCAAA,EAAA,oCAAA,CAAA;AAUT,SAAS,yBAAA,CAA0B,MAAgB,KAAA,EAAe;AACxE,EAAA,OAAO,qBAAqB,IAAA,EAAM,CAAC,aAAa,KAAA,CAAM,IAAA,CAAK,QAAQ,CAAC,CAAA;AACrE;AAFgB,MAAA,CAAA,yBAAA,EAAA,2BAAA,CAAA","file":"index.cjs","sourcesContent":["import type { PathLike } from 'node:fs';\nimport { opendir } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n *\n * @param path The path in which to find files.\n * @param predicate A predicate function receives the path as a parameter. Truthy values will have the path included, falsey values will have the file excluded.\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursively(path, predicate)) {}`\n *\n * @example\n * ```typescript\n * // With CommonJS: To find all files ending with `.ts` in the src directory:\n * const path = require('node:path');\n *\n * for await (const file of findFilesRecursively(path.join(__dirname, 'src'), (filePath) => filePath.endsWith('.ts'))) {\n * console.log(file);\n * }\n * ```\n *\n * @example\n * ```typescript\n * // With ESM: To find all files ending with `.ts` in the src directory:\n * for await (const file of findFilesRecursively(new URL('src', import.meta.url), (filePath) => filePath.endsWith('.ts'))) {\n * console.log(file);\n * }\n * ```\n */\nexport async function* findFilesRecursively(path: PathLike, predicate: (filePath: string) => boolean = () => true): AsyncIterableIterator<string> {\n\tconst dir = await opendir(path);\n\n\tfor await (const item of dir) {\n\t\tif (item.isFile() && predicate(item.name)) {\n\t\t\tyield join(dir.path, item.name);\n\t\t} else if (item.isDirectory()) {\n\t\t\tyield* findFilesRecursively(join(dir.path, item.name), predicate);\n\t\t}\n\t}\n}\n\n/**\n *\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param fileStartsWith The string pattern with which the file name must start.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.startsWith}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringStartsWith(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringStartsWith(path: PathLike, fileStartsWith: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.startsWith(fileStartsWith));\n}\n\n/**\n *\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param fileEndsWith The string pattern with which the file name must end.\n * Ideally this is a file extension, however you can also provide more parts of the end of the file.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.endsWith}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringEndsWith(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringEndsWith(path: PathLike, fileEndsWith: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.endsWith(fileEndsWith));\n}\n\n/**\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param include The string pattern which must be present in the file name.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.includes}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringIncludes(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringIncludes(path: PathLike, include: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.includes(include));\n}\n\n/**\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param regex The regex pattern that the file name must match.\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyRegex(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyRegex(path: PathLike, regex: RegExp) {\n\treturn findFilesRecursively(path, (filePath) => regex.test(filePath));\n}\n"]}
@@ -0,0 +1,67 @@
1
+ import { PathLike } from 'node:fs';
2
+
3
+ /**
4
+ *
5
+ * @param path The path in which to find files.
6
+ * @param predicate A predicate function receives the path as a parameter. Truthy values will have the path included, falsey values will have the file excluded.
7
+ *
8
+ * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursively(path, predicate)) {}`
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // With CommonJS: To find all files ending with `.ts` in the src directory:
13
+ * const path = require('node:path');
14
+ *
15
+ * for await (const file of findFilesRecursively(path.join(__dirname, 'src'), (filePath) => filePath.endsWith('.ts'))) {
16
+ * console.log(file);
17
+ * }
18
+ * ```
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // With ESM: To find all files ending with `.ts` in the src directory:
23
+ * for await (const file of findFilesRecursively(new URL('src', import.meta.url), (filePath) => filePath.endsWith('.ts'))) {
24
+ * console.log(file);
25
+ * }
26
+ * ```
27
+ */
28
+ declare function findFilesRecursively(path: PathLike, predicate?: (filePath: string) => boolean): AsyncIterableIterator<string>;
29
+ /**
30
+ *
31
+ * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.
32
+ * @param fileStartsWith The string pattern with which the file name must start.
33
+ *
34
+ * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.startsWith}
35
+ *
36
+ * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringStartsWith(path, fileNameEndsWith)) {}`
37
+ */
38
+ declare function findFilesRecursivelyStringStartsWith(path: PathLike, fileStartsWith: string): AsyncIterableIterator<string>;
39
+ /**
40
+ *
41
+ * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.
42
+ * @param fileEndsWith The string pattern with which the file name must end.
43
+ * Ideally this is a file extension, however you can also provide more parts of the end of the file.
44
+ *
45
+ * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.endsWith}
46
+ *
47
+ * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringEndsWith(path, fileNameEndsWith)) {}`
48
+ */
49
+ declare function findFilesRecursivelyStringEndsWith(path: PathLike, fileEndsWith: string): AsyncIterableIterator<string>;
50
+ /**
51
+ * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.
52
+ * @param include The string pattern which must be present in the file name.
53
+ *
54
+ * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.includes}
55
+ *
56
+ * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringIncludes(path, fileNameEndsWith)) {}`
57
+ */
58
+ declare function findFilesRecursivelyStringIncludes(path: PathLike, include: string): AsyncIterableIterator<string>;
59
+ /**
60
+ * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.
61
+ * @param regex The regex pattern that the file name must match.
62
+ *
63
+ * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyRegex(path, fileNameEndsWith)) {}`
64
+ */
65
+ declare function findFilesRecursivelyRegex(path: PathLike, regex: RegExp): AsyncIterableIterator<string>;
66
+
67
+ export { findFilesRecursively, findFilesRecursivelyRegex, findFilesRecursivelyStringEndsWith, findFilesRecursivelyStringIncludes, findFilesRecursivelyStringStartsWith };
@@ -1,5 +1,5 @@
1
- import { opendir } from 'node:fs/promises';
2
- import { join } from 'node:path';
1
+ import { opendir } from 'fs/promises';
2
+ import { join } from 'path';
3
3
 
4
4
  var __defProp = Object.defineProperty;
5
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -32,5 +32,5 @@ function findFilesRecursivelyRegex(path, regex) {
32
32
  __name(findFilesRecursivelyRegex, "findFilesRecursivelyRegex");
33
33
 
34
34
  export { findFilesRecursively, findFilesRecursivelyRegex, findFilesRecursivelyStringEndsWith, findFilesRecursivelyStringIncludes, findFilesRecursivelyStringStartsWith };
35
- //# sourceMappingURL=out.js.map
35
+ //# sourceMappingURL=index.mjs.map
36
36
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/findFilesRecursively.ts"],"names":[],"mappings":";;;;;AA6BA,gBAAuB,oBAAA,CAAqB,IAAA,EAAgB,SAAA,GAA2C,MAAM,IAAA,EAAqC;AACjJ,EAAA,MAAM,GAAA,GAAM,MAAM,OAAA,CAAQ,IAAI,CAAA;AAE9B,EAAA,WAAA,MAAiB,QAAQ,GAAA,EAAK;AAC7B,IAAA,IAAI,KAAK,MAAA,EAAO,IAAK,SAAA,CAAU,IAAA,CAAK,IAAI,CAAA,EAAG;AAC1C,MAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,EAAM,IAAA,CAAK,IAAI,CAAA;AAAA,IAC/B,CAAA,MAAA,IAAW,IAAA,CAAK,WAAA,EAAY,EAAG;AAC9B,MAAA,OAAO,qBAAqB,IAAA,CAAK,GAAA,CAAI,MAAM,IAAA,CAAK,IAAI,GAAG,SAAS,CAAA;AAAA,IACjE;AAAA,EACD;AACD;AAVuB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA;AAqBhB,SAAS,oCAAA,CAAqC,MAAgB,cAAA,EAAwB;AAC5F,EAAA,OAAO,qBAAqB,IAAA,EAAM,CAAC,aAAa,QAAA,CAAS,UAAA,CAAW,cAAc,CAAC,CAAA;AACpF;AAFgB,MAAA,CAAA,oCAAA,EAAA,sCAAA,CAAA;AAcT,SAAS,kCAAA,CAAmC,MAAgB,YAAA,EAAsB;AACxF,EAAA,OAAO,qBAAqB,IAAA,EAAM,CAAC,aAAa,QAAA,CAAS,QAAA,CAAS,YAAY,CAAC,CAAA;AAChF;AAFgB,MAAA,CAAA,kCAAA,EAAA,oCAAA,CAAA;AAYT,SAAS,kCAAA,CAAmC,MAAgB,OAAA,EAAiB;AACnF,EAAA,OAAO,qBAAqB,IAAA,EAAM,CAAC,aAAa,QAAA,CAAS,QAAA,CAAS,OAAO,CAAC,CAAA;AAC3E;AAFgB,MAAA,CAAA,kCAAA,EAAA,oCAAA,CAAA;AAUT,SAAS,yBAAA,CAA0B,MAAgB,KAAA,EAAe;AACxE,EAAA,OAAO,qBAAqB,IAAA,EAAM,CAAC,aAAa,KAAA,CAAM,IAAA,CAAK,QAAQ,CAAC,CAAA;AACrE;AAFgB,MAAA,CAAA,yBAAA,EAAA,2BAAA,CAAA","file":"index.mjs","sourcesContent":["import type { PathLike } from 'node:fs';\nimport { opendir } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n *\n * @param path The path in which to find files.\n * @param predicate A predicate function receives the path as a parameter. Truthy values will have the path included, falsey values will have the file excluded.\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursively(path, predicate)) {}`\n *\n * @example\n * ```typescript\n * // With CommonJS: To find all files ending with `.ts` in the src directory:\n * const path = require('node:path');\n *\n * for await (const file of findFilesRecursively(path.join(__dirname, 'src'), (filePath) => filePath.endsWith('.ts'))) {\n * console.log(file);\n * }\n * ```\n *\n * @example\n * ```typescript\n * // With ESM: To find all files ending with `.ts` in the src directory:\n * for await (const file of findFilesRecursively(new URL('src', import.meta.url), (filePath) => filePath.endsWith('.ts'))) {\n * console.log(file);\n * }\n * ```\n */\nexport async function* findFilesRecursively(path: PathLike, predicate: (filePath: string) => boolean = () => true): AsyncIterableIterator<string> {\n\tconst dir = await opendir(path);\n\n\tfor await (const item of dir) {\n\t\tif (item.isFile() && predicate(item.name)) {\n\t\t\tyield join(dir.path, item.name);\n\t\t} else if (item.isDirectory()) {\n\t\t\tyield* findFilesRecursively(join(dir.path, item.name), predicate);\n\t\t}\n\t}\n}\n\n/**\n *\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param fileStartsWith The string pattern with which the file name must start.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.startsWith}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringStartsWith(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringStartsWith(path: PathLike, fileStartsWith: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.startsWith(fileStartsWith));\n}\n\n/**\n *\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param fileEndsWith The string pattern with which the file name must end.\n * Ideally this is a file extension, however you can also provide more parts of the end of the file.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.endsWith}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringEndsWith(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringEndsWith(path: PathLike, fileEndsWith: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.endsWith(fileEndsWith));\n}\n\n/**\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param include The string pattern which must be present in the file name.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.includes}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringIncludes(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringIncludes(path: PathLike, include: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.includes(include));\n}\n\n/**\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param regex The regex pattern that the file name must match.\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyRegex(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyRegex(path: PathLike, regex: RegExp) {\n\treturn findFilesRecursively(path, (filePath) => regex.test(filePath));\n}\n"]}
package/package.json CHANGED
@@ -1,27 +1,34 @@
1
1
  {
2
2
  "name": "@sapphire/node-utilities",
3
- "version": "1.1.0-pr-601.2f2c308a.0",
3
+ "version": "1.1.0-pr-935.7da5c8bb",
4
4
  "description": "Node specific JavaScript utilities for the Sapphire Community",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
7
- "main": "dist/index.js",
8
- "module": "dist/index.mjs",
9
- "types": "dist/index.d.ts",
7
+ "main": "dist/cjs/index.cjs",
8
+ "module": "dist/esm/index.mjs",
9
+ "types": "dist/cjs/index.d.cts",
10
10
  "exports": {
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js",
13
- "types": "./dist/index.d.ts"
11
+ "import": {
12
+ "types": "./dist/esm/index.d.mts",
13
+ "default": "./dist/esm/index.mjs"
14
+ },
15
+ "require": {
16
+ "types": "./dist/cjs/index.d.cts",
17
+ "default": "./dist/cjs/index.cjs"
18
+ }
14
19
  },
15
20
  "sideEffects": false,
16
21
  "homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/utilities",
17
22
  "scripts": {
18
23
  "test": "vitest run",
19
24
  "lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
20
- "build": "tsup",
25
+ "build": "yarn gen-index && tsup && yarn build:rename-cjs-index",
26
+ "build:rename-cjs-index": "tsx ../../scripts/rename-cjs-index.cts",
21
27
  "docs": "typedoc-json-parser",
22
28
  "prepack": "yarn build",
23
29
  "bump": "cliff-jumper",
24
- "check-update": "cliff-jumper --dry-run"
30
+ "check-update": "cliff-jumper --dry-run",
31
+ "gen-index": "tsx ../../scripts/gen-index.cts node-utilities --write"
25
32
  },
26
33
  "repository": {
27
34
  "type": "git",
@@ -29,9 +36,7 @@
29
36
  "directory": "packages/node-utilities"
30
37
  },
31
38
  "files": [
32
- "dist/**/*.js*",
33
- "dist/**/*.mjs*",
34
- "dist/**/*.d*"
39
+ "dist/"
35
40
  ],
36
41
  "engines": {
37
42
  "node": ">=v16.0.0",
@@ -55,12 +60,13 @@
55
60
  "access": "public"
56
61
  },
57
62
  "devDependencies": {
58
- "@favware/cliff-jumper": "^2.0.1",
59
- "@vitest/coverage-c8": "^0.31.1",
60
- "tsup": "^6.7.0",
61
- "typedoc": "^0.24.7",
62
- "typedoc-json-parser": "^8.1.2",
63
- "typescript": "^5.0.4",
64
- "vitest": "^0.31.1"
63
+ "@favware/cliff-jumper": "^6.0.0",
64
+ "@vitest/coverage-v8": "^3.2.4",
65
+ "tsup": "^8.5.0",
66
+ "tsx": "^4.20.6",
67
+ "typedoc": "^0.26.11",
68
+ "typedoc-json-parser": "^10.2.0",
69
+ "typescript": "~5.4.5",
70
+ "vitest": "^3.2.4"
65
71
  }
66
72
  }
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/findFilesRecursively.ts"],"names":[],"mappings":";;;;AACA,SAAS,eAAe;AACxB,SAAS,YAAY;AA2BrB,gBAAuB,qBAAqB,MAAgB,YAA2C,MAAM,MAAqC;AACjJ,QAAM,MAAM,MAAM,QAAQ,IAAI;AAE9B,mBAAiB,QAAQ,KAAK;AAC7B,QAAI,KAAK,OAAO,KAAK,UAAU,KAAK,IAAI,GAAG;AAC1C,YAAM,KAAK,IAAI,MAAM,KAAK,IAAI;AAAA,IAC/B,WAAW,KAAK,YAAY,GAAG;AAC9B,aAAO,qBAAqB,KAAK,IAAI,MAAM,KAAK,IAAI,GAAG,SAAS;AAAA,IACjE;AAAA,EACD;AACD;AAVuB;AAqBhB,SAAS,qCAAqC,MAAgB,gBAAwB;AAC5F,SAAO,qBAAqB,MAAM,CAAC,aAAa,SAAS,WAAW,cAAc,CAAC;AACpF;AAFgB;AAcT,SAAS,mCAAmC,MAAgB,cAAsB;AACxF,SAAO,qBAAqB,MAAM,CAAC,aAAa,SAAS,SAAS,YAAY,CAAC;AAChF;AAFgB;AAYT,SAAS,mCAAmC,MAAgB,SAAiB;AACnF,SAAO,qBAAqB,MAAM,CAAC,aAAa,SAAS,SAAS,OAAO,CAAC;AAC3E;AAFgB;AAUT,SAAS,0BAA0B,MAAgB,OAAe;AACxE,SAAO,qBAAqB,MAAM,CAAC,aAAa,MAAM,KAAK,QAAQ,CAAC;AACrE;AAFgB","sourcesContent":["import type { PathLike } from 'node:fs';\nimport { opendir } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n *\n * @param path The path in which to find files.\n * @param predicate A predicate function receives the path as a parameter. Truthy values will have the path included, falsey values will have the file excluded.\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursively(path, predicate)) {}`\n *\n * @example\n * ```typescript\n * // With CommonJS: To find all files ending with `.ts` in the src directory:\n * const path = require('node:path');\n *\n * for await (const file of findFilesRecursively(path.join(__dirname, 'src'), (filePath) => filePath.endsWith('.ts'))) {\n * console.log(file);\n * }\n * ```\n *\n * @example\n * ```typescript\n * // With ESM: To find all files ending with `.ts` in the src directory:\n * for await (const file of findFilesRecursively(new URL('src', import.meta.url), (filePath) => filePath.endsWith('.ts'))) {\n * console.log(file);\n * }\n * ```\n */\nexport async function* findFilesRecursively(path: PathLike, predicate: (filePath: string) => boolean = () => true): AsyncIterableIterator<string> {\n\tconst dir = await opendir(path);\n\n\tfor await (const item of dir) {\n\t\tif (item.isFile() && predicate(item.name)) {\n\t\t\tyield join(dir.path, item.name);\n\t\t} else if (item.isDirectory()) {\n\t\t\tyield* findFilesRecursively(join(dir.path, item.name), predicate);\n\t\t}\n\t}\n}\n\n/**\n *\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param fileStartsWith The string pattern with which the file name must start.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.startsWith}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringStartsWith(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringStartsWith(path: PathLike, fileStartsWith: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.startsWith(fileStartsWith));\n}\n\n/**\n *\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param fileEndsWith The string pattern with which the file name must end.\n * Ideally this is a file extension, however you can also provide more parts of the end of the file.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.endsWith}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringEndsWith(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringEndsWith(path: PathLike, fileEndsWith: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.endsWith(fileEndsWith));\n}\n\n/**\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param include The string pattern which must be present in the file name.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.includes}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringIncludes(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringIncludes(path: PathLike, include: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.includes(include));\n}\n\n/**\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param regex The regex pattern that the file name must match.\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyRegex(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyRegex(path: PathLike, regex: RegExp) {\n\treturn findFilesRecursively(path, (filePath) => regex.test(filePath));\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/findFilesRecursively.ts"],"names":[],"mappings":";;;;AACA,SAAS,eAAe;AACxB,SAAS,YAAY;AA2BrB,gBAAuB,qBAAqB,MAAgB,YAA2C,MAAM,MAAqC;AACjJ,QAAM,MAAM,MAAM,QAAQ,IAAI;AAE9B,mBAAiB,QAAQ,KAAK;AAC7B,QAAI,KAAK,OAAO,KAAK,UAAU,KAAK,IAAI,GAAG;AAC1C,YAAM,KAAK,IAAI,MAAM,KAAK,IAAI;AAAA,IAC/B,WAAW,KAAK,YAAY,GAAG;AAC9B,aAAO,qBAAqB,KAAK,IAAI,MAAM,KAAK,IAAI,GAAG,SAAS;AAAA,IACjE;AAAA,EACD;AACD;AAVuB;AAqBhB,SAAS,qCAAqC,MAAgB,gBAAwB;AAC5F,SAAO,qBAAqB,MAAM,CAAC,aAAa,SAAS,WAAW,cAAc,CAAC;AACpF;AAFgB;AAcT,SAAS,mCAAmC,MAAgB,cAAsB;AACxF,SAAO,qBAAqB,MAAM,CAAC,aAAa,SAAS,SAAS,YAAY,CAAC;AAChF;AAFgB;AAYT,SAAS,mCAAmC,MAAgB,SAAiB;AACnF,SAAO,qBAAqB,MAAM,CAAC,aAAa,SAAS,SAAS,OAAO,CAAC;AAC3E;AAFgB;AAUT,SAAS,0BAA0B,MAAgB,OAAe;AACxE,SAAO,qBAAqB,MAAM,CAAC,aAAa,MAAM,KAAK,QAAQ,CAAC;AACrE;AAFgB","sourcesContent":["import type { PathLike } from 'node:fs';\nimport { opendir } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n *\n * @param path The path in which to find files.\n * @param predicate A predicate function receives the path as a parameter. Truthy values will have the path included, falsey values will have the file excluded.\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursively(path, predicate)) {}`\n *\n * @example\n * ```typescript\n * // With CommonJS: To find all files ending with `.ts` in the src directory:\n * const path = require('node:path');\n *\n * for await (const file of findFilesRecursively(path.join(__dirname, 'src'), (filePath) => filePath.endsWith('.ts'))) {\n * console.log(file);\n * }\n * ```\n *\n * @example\n * ```typescript\n * // With ESM: To find all files ending with `.ts` in the src directory:\n * for await (const file of findFilesRecursively(new URL('src', import.meta.url), (filePath) => filePath.endsWith('.ts'))) {\n * console.log(file);\n * }\n * ```\n */\nexport async function* findFilesRecursively(path: PathLike, predicate: (filePath: string) => boolean = () => true): AsyncIterableIterator<string> {\n\tconst dir = await opendir(path);\n\n\tfor await (const item of dir) {\n\t\tif (item.isFile() && predicate(item.name)) {\n\t\t\tyield join(dir.path, item.name);\n\t\t} else if (item.isDirectory()) {\n\t\t\tyield* findFilesRecursively(join(dir.path, item.name), predicate);\n\t\t}\n\t}\n}\n\n/**\n *\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param fileStartsWith The string pattern with which the file name must start.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.startsWith}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringStartsWith(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringStartsWith(path: PathLike, fileStartsWith: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.startsWith(fileStartsWith));\n}\n\n/**\n *\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param fileEndsWith The string pattern with which the file name must end.\n * Ideally this is a file extension, however you can also provide more parts of the end of the file.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.endsWith}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringEndsWith(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringEndsWith(path: PathLike, fileEndsWith: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.endsWith(fileEndsWith));\n}\n\n/**\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param include The string pattern which must be present in the file name.\n *\n * Note that we do **not** support a full globby pattern using asterisk for wildcards. It has to be an exact match with {@link String.includes}\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyStringIncludes(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyStringIncludes(path: PathLike, include: string) {\n\treturn findFilesRecursively(path, (filePath) => filePath.includes(include));\n}\n\n/**\n * @param path The path in which to find files. This can be a string, buffer, or {@link URL}.\n * @param regex The regex pattern that the file name must match.\n *\n * @return An {@link AsyncIterableIterator} of all the files. To loop over these use `for await (const file of findFilesRecursivelyRegex(path, fileNameEndsWith)) {}`\n */\nexport function findFilesRecursivelyRegex(path: PathLike, regex: RegExp) {\n\treturn findFilesRecursively(path, (filePath) => regex.test(filePath));\n}\n"]}
File without changes