@sapphire/node-utilities 1.1.0-next.d17bd10.0 → 1.1.0-next.f555c82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
package/dist/index.js CHANGED
@@ -1,45 +1,19 @@
1
- "use strict";
2
- "use strict";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
21
4
 
22
- // src/index.ts
23
- var src_exports = {};
24
- __export(src_exports, {
25
- findFilesRecursively: () => findFilesRecursively,
26
- findFilesRecursivelyRegex: () => findFilesRecursivelyRegex,
27
- findFilesRecursivelyStringEndsWith: () => findFilesRecursivelyStringEndsWith,
28
- findFilesRecursivelyStringIncludes: () => findFilesRecursivelyStringIncludes,
29
- findFilesRecursivelyStringStartsWith: () => findFilesRecursivelyStringStartsWith
30
- });
31
- module.exports = __toCommonJS(src_exports);
5
+ var promises = require('fs/promises');
6
+ var path = require('path');
32
7
 
33
- // src/lib/findFilesRecursively.ts
34
- var import_promises = require("fs/promises");
35
- var import_node_path = require("path");
36
- async function* findFilesRecursively(path, predicate = () => true) {
37
- const dir = await (0, import_promises.opendir)(path);
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ async function* findFilesRecursively(path$1, predicate = () => true) {
11
+ const dir = await promises.opendir(path$1);
38
12
  for await (const item of dir) {
39
13
  if (item.isFile() && predicate(item.name)) {
40
- yield (0, import_node_path.join)(dir.path, item.name);
14
+ yield path.join(dir.path, item.name);
41
15
  } else if (item.isDirectory()) {
42
- yield* findFilesRecursively((0, import_node_path.join)(dir.path, item.name), predicate);
16
+ yield* findFilesRecursively(path.join(dir.path, item.name), predicate);
43
17
  }
44
18
  }
45
19
  }
@@ -60,12 +34,10 @@ function findFilesRecursivelyRegex(path, regex) {
60
34
  return findFilesRecursively(path, (filePath) => regex.test(filePath));
61
35
  }
62
36
  __name(findFilesRecursivelyRegex, "findFilesRecursivelyRegex");
63
- // Annotate the CommonJS export names for ESM import in node:
64
- 0 && (module.exports = {
65
- findFilesRecursively,
66
- findFilesRecursivelyRegex,
67
- findFilesRecursivelyStringEndsWith,
68
- findFilesRecursivelyStringIncludes,
69
- findFilesRecursivelyStringStartsWith
70
- });
37
+
38
+ exports.findFilesRecursively = findFilesRecursively;
39
+ exports.findFilesRecursivelyRegex = findFilesRecursivelyRegex;
40
+ exports.findFilesRecursivelyStringEndsWith = findFilesRecursivelyStringEndsWith;
41
+ exports.findFilesRecursivelyStringIncludes = findFilesRecursivelyStringIncludes;
42
+ exports.findFilesRecursivelyStringStartsWith = findFilesRecursivelyStringStartsWith;
71
43
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/lib/findFilesRecursively.ts"],"sourcesContent":["export * from './lib/findFilesRecursively';\n","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<string>} 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<string>} 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<string>} 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<string>} 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<string>} 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,sBAAwB;AACxB,uBAAqB;AA2BrB,gBAAuB,qBAAqB,MAAgB,YAA2C,MAAM,MAAqC;AACjJ,QAAM,MAAM,UAAM,yBAAQ,IAAI;AAE9B,mBAAiB,QAAQ,KAAK;AAC7B,QAAI,KAAK,OAAO,KAAK,UAAU,KAAK,IAAI,GAAG;AAC1C,gBAAM,uBAAK,IAAI,MAAM,KAAK,IAAI;AAAA,IAC/B,WAAW,KAAK,YAAY,GAAG;AAC9B,aAAO,yBAAqB,uBAAK,IAAI,MAAM,KAAK,IAAI,GAAG,SAAS;AAAA,IACjE;AAAA,EACD;AACD;AAVuB;AAqBhB,SAAS,qCAAqC,MAAgB,gBAAwB;AAC5F,SA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E,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<string>} 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<string>} 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<string>} 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<string>} 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<string>} 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/dist/index.mjs CHANGED
@@ -1,9 +1,8 @@
1
+ import { opendir } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+
1
4
  var __defProp = Object.defineProperty;
2
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // src/lib/findFilesRecursively.ts
5
- import { opendir } from "node:fs/promises";
6
- import { join } from "node:path";
7
6
  async function* findFilesRecursively(path, predicate = () => true) {
8
7
  const dir = await opendir(path);
9
8
  for await (const item of dir) {
@@ -31,11 +30,6 @@ function findFilesRecursivelyRegex(path, regex) {
31
30
  return findFilesRecursively(path, (filePath) => regex.test(filePath));
32
31
  }
33
32
  __name(findFilesRecursivelyRegex, "findFilesRecursivelyRegex");
34
- export {
35
- findFilesRecursively,
36
- findFilesRecursivelyRegex,
37
- findFilesRecursivelyStringEndsWith,
38
- findFilesRecursivelyStringIncludes,
39
- findFilesRecursivelyStringStartsWith
40
- };
33
+
34
+ export { findFilesRecursively, findFilesRecursivelyRegex, findFilesRecursivelyStringEndsWith, findFilesRecursivelyStringIncludes, findFilesRecursivelyStringStartsWith };
41
35
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/findFilesRecursively.ts"],"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<string>} 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<string>} 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<string>} 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<string>} 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<string>} 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(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,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<string>} 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<string>} 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<string>} 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<string>} 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<string>} 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire/node-utilities",
3
- "version": "1.1.0-next.d17bd10.0",
3
+ "version": "1.1.0-next.f555c82.0",
4
4
  "description": "Node specific JavaScript utilities for the Sapphire Community",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
@@ -55,7 +55,7 @@
55
55
  "access": "public"
56
56
  },
57
57
  "devDependencies": {
58
- "@favware/cliff-jumper": "^1.8.7",
58
+ "@favware/cliff-jumper": "^1.8.8",
59
59
  "@vitest/coverage-c8": "^0.23.4",
60
60
  "tsup": "^6.2.3",
61
61
  "typedoc": "^0.23.15",