@bemoje/path 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/lib/index.cjs +174 -0
  2. package/lib/index.d.cts +16 -0
  3. package/lib/index.d.ts +16 -0
  4. package/lib/lib/cwd.cjs +16 -0
  5. package/lib/lib/cwd.d.cts +11 -0
  6. package/lib/lib/cwd.d.ts +11 -0
  7. package/lib/lib/cwd.js +10 -0
  8. package/lib/lib/dirnameDeep.cjs +17 -0
  9. package/lib/lib/dirnameDeep.d.cts +9 -0
  10. package/lib/lib/dirnameDeep.d.ts +9 -0
  11. package/lib/lib/dirnameDeep.js +11 -0
  12. package/lib/lib/hasBasename.cjs +18 -0
  13. package/lib/lib/hasBasename.d.cts +8 -0
  14. package/lib/lib/hasBasename.d.ts +8 -0
  15. package/lib/lib/hasBasename.js +12 -0
  16. package/lib/lib/hasExtname.cjs +60 -0
  17. package/lib/lib/hasExtname.d.cts +15 -0
  18. package/lib/lib/hasExtname.d.ts +15 -0
  19. package/lib/lib/hasExtname.js +58 -0
  20. package/lib/lib/hasParentDirname.cjs +12 -0
  21. package/lib/lib/hasParentDirname.d.cts +6 -0
  22. package/lib/lib/hasParentDirname.d.ts +6 -0
  23. package/lib/lib/hasParentDirname.js +10 -0
  24. package/lib/lib/isDotFile.cjs +12 -0
  25. package/lib/lib/isDotFile.d.cts +8 -0
  26. package/lib/lib/isDotFile.d.ts +8 -0
  27. package/lib/lib/isDotFile.js +10 -0
  28. package/lib/lib/isExtValid.cjs +12 -0
  29. package/lib/lib/isExtValid.d.cts +13 -0
  30. package/lib/lib/isExtValid.d.ts +13 -0
  31. package/lib/lib/isExtValid.js +10 -0
  32. package/lib/lib/isRelative.cjs +16 -0
  33. package/lib/lib/isRelative.d.cts +6 -0
  34. package/lib/lib/isRelative.d.ts +6 -0
  35. package/lib/lib/isRelative.js +10 -0
  36. package/lib/lib/isUnc.cjs +12 -0
  37. package/lib/lib/isUnc.d.cts +8 -0
  38. package/lib/lib/isUnc.d.ts +8 -0
  39. package/lib/lib/isUnc.js +10 -0
  40. package/lib/lib/isValidWin32.cjs +29 -0
  41. package/lib/lib/isValidWin32.d.cts +11 -0
  42. package/lib/lib/isValidWin32.d.ts +11 -0
  43. package/lib/lib/isValidWin32.js +27 -0
  44. package/lib/lib/prefixFilename.cjs +18 -0
  45. package/lib/lib/prefixFilename.d.cts +11 -0
  46. package/lib/lib/prefixFilename.d.ts +11 -0
  47. package/lib/lib/prefixFilename.js +12 -0
  48. package/lib/lib/root.cjs +16 -0
  49. package/lib/lib/root.d.cts +6 -0
  50. package/lib/lib/root.d.ts +6 -0
  51. package/lib/lib/root.js +10 -0
  52. package/lib/lib/suffixFilename.cjs +18 -0
  53. package/lib/lib/suffixFilename.d.cts +11 -0
  54. package/lib/lib/suffixFilename.d.ts +11 -0
  55. package/lib/lib/suffixFilename.js +12 -0
  56. package/lib/lib/toCwdRelative.cjs +16 -0
  57. package/lib/lib/toCwdRelative.d.cts +8 -0
  58. package/lib/lib/toCwdRelative.d.ts +8 -0
  59. package/lib/lib/toCwdRelative.js +10 -0
  60. package/lib/lib/toWin32.cjs +12 -0
  61. package/lib/lib/toWin32.d.cts +6 -0
  62. package/lib/lib/toWin32.d.ts +6 -0
  63. package/lib/lib/toWin32.js +10 -0
  64. package/package.json +249 -19
  65. package/index.d.ts +0 -121
  66. /package/{index.mjs → lib/index.js} +0 -0
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var path__default = /*#__PURE__*/_interopDefault(path);
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+ function isRelative(p) {
12
+ return !path__default.default.isAbsolute(p);
13
+ }
14
+ __name(isRelative, "isRelative");
15
+
16
+ exports.isRelative = isRelative;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Whether a path is a relative string, ie. not absolute.
3
+ */
4
+ declare function isRelative(p: string): boolean;
5
+
6
+ export { isRelative };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Whether a path is a relative string, ie. not absolute.
3
+ */
4
+ declare function isRelative(p: string): boolean;
5
+
6
+ export { isRelative };
@@ -0,0 +1,10 @@
1
+ import path from 'path';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ function isRelative(p) {
6
+ return !path.isAbsolute(p);
7
+ }
8
+ __name(isRelative, "isRelative");
9
+
10
+ export { isRelative };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+
6
+ // src/lib/isUnc.ts
7
+ function isUnc(filepath) {
8
+ return /^[/\\]{2,}[^/\\]+[/\\]+[^/\\]+/.test(filepath);
9
+ }
10
+ __name(isUnc, "isUnc");
11
+
12
+ exports.isUnc = isUnc;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Determines if a given filepath is a UNC path.
3
+ * @param filepath - The filepath to evaluate.
4
+ * @returns A boolean indicating whether the filepath is a UNC path.
5
+ */
6
+ declare function isUnc(filepath: string): boolean;
7
+
8
+ export { isUnc };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Determines if a given filepath is a UNC path.
3
+ * @param filepath - The filepath to evaluate.
4
+ * @returns A boolean indicating whether the filepath is a UNC path.
5
+ */
6
+ declare function isUnc(filepath: string): boolean;
7
+
8
+ export { isUnc };
@@ -0,0 +1,10 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/lib/isUnc.ts
5
+ function isUnc(filepath) {
6
+ return /^[/\\]{2,}[^/\\]+[/\\]+[^/\\]+/.test(filepath);
7
+ }
8
+ __name(isUnc, "isUnc");
9
+
10
+ export { isUnc };
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+
6
+ // src/lib/isValidWin32.ts
7
+ function isValidWin32(path, options) {
8
+ if (path.length === 0) {
9
+ return false;
10
+ }
11
+ if (path.includes("/") && path.includes("\\")) {
12
+ return false;
13
+ }
14
+ const maxLength = (options && options.extendedMaxLength ? 32767 : 260) - 12;
15
+ if (path.length > maxLength) {
16
+ return false;
17
+ }
18
+ const noDriveLetter = /^\w:(\\|\/)/g.test(path) ? path.substring(2) : path;
19
+ if (/["*:<>?|]/g.test(noDriveLetter)) {
20
+ return false;
21
+ }
22
+ if (/(\\|\/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])((\\|\/)|$)/g.test(path)) {
23
+ return false;
24
+ }
25
+ return true;
26
+ }
27
+ __name(isValidWin32, "isValidWin32");
28
+
29
+ exports.isValidWin32 = isValidWin32;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Check whether a provided windows filesystem path string is valid according to:
3
+ * https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
4
+ * @param path The path to validate.
5
+ * @throws If the path is invalid and the `assert` option is true.
6
+ */
7
+ declare function isValidWin32(path: string, options?: {
8
+ extendedMaxLength?: boolean;
9
+ }): boolean;
10
+
11
+ export { isValidWin32 };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Check whether a provided windows filesystem path string is valid according to:
3
+ * https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
4
+ * @param path The path to validate.
5
+ * @throws If the path is invalid and the `assert` option is true.
6
+ */
7
+ declare function isValidWin32(path: string, options?: {
8
+ extendedMaxLength?: boolean;
9
+ }): boolean;
10
+
11
+ export { isValidWin32 };
@@ -0,0 +1,27 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/lib/isValidWin32.ts
5
+ function isValidWin32(path, options) {
6
+ if (path.length === 0) {
7
+ return false;
8
+ }
9
+ if (path.includes("/") && path.includes("\\")) {
10
+ return false;
11
+ }
12
+ const maxLength = (options && options.extendedMaxLength ? 32767 : 260) - 12;
13
+ if (path.length > maxLength) {
14
+ return false;
15
+ }
16
+ const noDriveLetter = /^\w:(\\|\/)/g.test(path) ? path.substring(2) : path;
17
+ if (/["*:<>?|]/g.test(noDriveLetter)) {
18
+ return false;
19
+ }
20
+ if (/(\\|\/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])((\\|\/)|$)/g.test(path)) {
21
+ return false;
22
+ }
23
+ return true;
24
+ }
25
+ __name(isValidWin32, "isValidWin32");
26
+
27
+ export { isValidWin32 };
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var upath = require('upath');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var upath__default = /*#__PURE__*/_interopDefault(upath);
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+ function prefixFilename(filePath, prefix) {
12
+ const ext = upath__default.default.extname(filePath);
13
+ const fileNameWithoutExt = upath__default.default.basename(filePath, ext);
14
+ return upath__default.default.joinSafe(upath__default.default.dirname(filePath), prefix + fileNameWithoutExt + ext);
15
+ }
16
+ __name(prefixFilename, "prefixFilename");
17
+
18
+ exports.prefixFilename = prefixFilename;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Append string to the beginning of the filename.
3
+ *
4
+ * @example ```ts
5
+ * path.fileNameWithPrefix('path/to/file-name.ext', 'new-')
6
+ * // => path/to/new-file-name.ext
7
+ * ```
8
+ */
9
+ declare function prefixFilename(filePath: string, prefix: string): string;
10
+
11
+ export { prefixFilename };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Append string to the beginning of the filename.
3
+ *
4
+ * @example ```ts
5
+ * path.fileNameWithPrefix('path/to/file-name.ext', 'new-')
6
+ * // => path/to/new-file-name.ext
7
+ * ```
8
+ */
9
+ declare function prefixFilename(filePath: string, prefix: string): string;
10
+
11
+ export { prefixFilename };
@@ -0,0 +1,12 @@
1
+ import upath from 'upath';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ function prefixFilename(filePath, prefix) {
6
+ const ext = upath.extname(filePath);
7
+ const fileNameWithoutExt = upath.basename(filePath, ext);
8
+ return upath.joinSafe(upath.dirname(filePath), prefix + fileNameWithoutExt + ext);
9
+ }
10
+ __name(prefixFilename, "prefixFilename");
11
+
12
+ export { prefixFilename };
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var upath = require('upath');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var upath__default = /*#__PURE__*/_interopDefault(upath);
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+ function root(p) {
12
+ return upath__default.default.parse(p).root;
13
+ }
14
+ __name(root, "root");
15
+
16
+ exports.root = root;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the root directory of a given path.
3
+ */
4
+ declare function root(p: string): string;
5
+
6
+ export { root };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the root directory of a given path.
3
+ */
4
+ declare function root(p: string): string;
5
+
6
+ export { root };
@@ -0,0 +1,10 @@
1
+ import upath from 'upath';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ function root(p) {
6
+ return upath.parse(p).root;
7
+ }
8
+ __name(root, "root");
9
+
10
+ export { root };
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var upath = require('upath');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var upath__default = /*#__PURE__*/_interopDefault(upath);
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+ function suffixFilename(filePath, suffix) {
12
+ const split = upath__default.default.basename(filePath).split(".");
13
+ split[0] += suffix;
14
+ return upath__default.default.joinSafe(upath__default.default.dirname(filePath), split.join("."));
15
+ }
16
+ __name(suffixFilename, "suffixFilename");
17
+
18
+ exports.suffixFilename = suffixFilename;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Append string to the end of the filename.
3
+ *
4
+ * @example ```ts
5
+ * path.suffixFilename('path/to/file-name.ext', '-old')
6
+ * // => path/to/file-name-old.ext
7
+ * ```
8
+ */
9
+ declare function suffixFilename(filePath: string, suffix: string): string;
10
+
11
+ export { suffixFilename };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Append string to the end of the filename.
3
+ *
4
+ * @example ```ts
5
+ * path.suffixFilename('path/to/file-name.ext', '-old')
6
+ * // => path/to/file-name-old.ext
7
+ * ```
8
+ */
9
+ declare function suffixFilename(filePath: string, suffix: string): string;
10
+
11
+ export { suffixFilename };
@@ -0,0 +1,12 @@
1
+ import upath from 'upath';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ function suffixFilename(filePath, suffix) {
6
+ const split = upath.basename(filePath).split(".");
7
+ split[0] += suffix;
8
+ return upath.joinSafe(upath.dirname(filePath), split.join("."));
9
+ }
10
+ __name(suffixFilename, "suffixFilename");
11
+
12
+ export { suffixFilename };
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var upath = require('upath');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var upath__default = /*#__PURE__*/_interopDefault(upath);
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+ function toCwdRelative(p) {
12
+ return upath__default.default.relative(process.cwd(), p);
13
+ }
14
+ __name(toCwdRelative, "toCwdRelative");
15
+
16
+ exports.toCwdRelative = toCwdRelative;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Solve the relative path from the process.cwd() path to the {p} path.
3
+ * At times we have two absolute paths, and we need to derive the relative path from one to the other.
4
+ * This is actually the reverse transform of path.resolve.
5
+ */
6
+ declare function toCwdRelative(p: string): string;
7
+
8
+ export { toCwdRelative };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Solve the relative path from the process.cwd() path to the {p} path.
3
+ * At times we have two absolute paths, and we need to derive the relative path from one to the other.
4
+ * This is actually the reverse transform of path.resolve.
5
+ */
6
+ declare function toCwdRelative(p: string): string;
7
+
8
+ export { toCwdRelative };
@@ -0,0 +1,10 @@
1
+ import upath from 'upath';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ function toCwdRelative(p) {
6
+ return upath.relative(process.cwd(), p);
7
+ }
8
+ __name(toCwdRelative, "toCwdRelative");
9
+
10
+ export { toCwdRelative };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+
6
+ // src/lib/toWin32.ts
7
+ function toWin32(p) {
8
+ return p.replaceAll("/", "\\");
9
+ }
10
+ __name(toWin32, "toWin32");
11
+
12
+ exports.toWin32 = toWin32;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Ensures win32 backslashes are used instead of forward slashes.
3
+ */
4
+ declare function toWin32(p: string): string;
5
+
6
+ export { toWin32 };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Ensures win32 backslashes are used instead of forward slashes.
3
+ */
4
+ declare function toWin32(p: string): string;
5
+
6
+ export { toWin32 };
@@ -0,0 +1,10 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/lib/toWin32.ts
5
+ function toWin32(p) {
6
+ return p.replaceAll("/", "\\");
7
+ }
8
+ __name(toWin32, "toWin32");
9
+
10
+ export { toWin32 };