@stryke/path 0.22.13 → 0.23.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
@@ -2,6 +2,14 @@
2
2
 
3
3
  # Changelog for Stryke - Path
4
4
 
5
+ ## [0.22.13](https://github.com/storm-software/stryke/releases/tag/path%400.22.13) (12/17/2025)
6
+
7
+ ### Updated Dependencies
8
+
9
+ - Updated **type-checks** to **v0.5.11**
10
+ - Updated **convert** to **v0.6.26**
11
+ - Updated **types** to **v0.10.25**
12
+
5
13
  ## [0.22.12](https://github.com/storm-software/stryke/releases/tag/path%400.22.12) (12/17/2025)
6
14
 
7
15
  ### Updated Dependencies
package/dist/append.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./cwd.cjs`),t=require(`./slash.cjs`),n=require(`./is-parent-path.cjs`),r=require(`./join-paths.cjs`);function i(i,a=e.cwd()){return t.slash(n.isParentPath(i,a)?i:r.joinPaths(a,i))}const a=i;function o(e,t){return`${e}.${t.replace(/^\./,``)}`}exports.append=a,exports.appendExtension=o,exports.appendPath=i;
1
+ const e=require(`./cwd.cjs`),t=require(`./slash.cjs`),n=require(`./is-parent-path.cjs`),r=require(`./join-paths.cjs`);function i(i,a=e.cwd(),o={}){return t.slash(o.skipIfAlreadyParent!==!1&&n.isParentPath(i,a)?i:r.joinPaths(a,i))}const a=i;function o(e,t){return`${e}.${t.replace(/^\./,``)}`}exports.append=a,exports.appendExtension=o,exports.appendPath=i;
package/dist/append.d.cts CHANGED
@@ -1,4 +1,12 @@
1
1
  //#region src/append.d.ts
2
+ interface AppendPathOptions {
3
+ /**
4
+ * If `true`, the function will skip appending if the `childPath` is already a child of the `parentPath`.
5
+ *
6
+ * @defaultValue true
7
+ */
8
+ skipIfAlreadyParent?: boolean;
9
+ }
2
10
  /**
3
11
  * If not already a parent path, append the base path from the beginning of the given child path.
4
12
  *
@@ -9,13 +17,23 @@
9
17
  *
10
18
  * appendPath("/user/dev/app.ts", "/user/dev");
11
19
  * // returns "/user/dev/app.ts"
20
+ *
21
+ * appendPath("docs/readme.md");
22
+ * // returns "<current_working_directory>/docs/readme.md"
23
+ *
24
+ * appendPath("src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
25
+ * // returns "/home/user/project/src/index.ts"
26
+ *
27
+ * appendPath("/home/user/project/src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
28
+ * // returns "/home/user/project/src/index.ts"
12
29
  * ```
13
30
  *
14
31
  * @param childPath - The child path to append to the {@link parentPath}
15
32
  * @param parentPath - The parent path to add the {@link childPath} to
33
+ * @param options - Options for appending the path
16
34
  * @returns The {@link parentPath} with the {@link childPath} appended
17
35
  */
18
- declare function appendPath(childPath: string, parentPath?: string): string;
36
+ declare function appendPath(childPath: string, parentPath?: string, options?: AppendPathOptions): string;
19
37
  declare const append: typeof appendPath;
20
38
  /**
21
39
  * Append the extension to the given path.
@@ -34,5 +52,5 @@ declare const append: typeof appendPath;
34
52
  */
35
53
  declare function appendExtension(path: string, extension: string): string;
36
54
  //#endregion
37
- export { append, appendExtension, appendPath };
55
+ export { AppendPathOptions, append, appendExtension, appendPath };
38
56
  //# sourceMappingURL=append.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"append.d.cts","names":[],"sources":["../src/append.ts"],"sourcesContent":[],"mappings":";;AAuCA;AAWA;AAiBA;;;;;;;;;;;;;iBA5BgB,UAAA;cAWH,eAAM;;;;;;;;;;;;;;;;iBAiBH,eAAA"}
1
+ {"version":3,"file":"append.d.cts","names":[],"sources":["../src/append.ts"],"sourcesContent":[],"mappings":";UAuBiB,iBAAA;EAAA;AAmCjB;AAYA;AAiBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA7BgB,UAAA,mDAGL;cASE,eAAM;;;;;;;;;;;;;;;;iBAiBH,eAAA"}
package/dist/append.d.mts CHANGED
@@ -1,4 +1,12 @@
1
1
  //#region src/append.d.ts
2
+ interface AppendPathOptions {
3
+ /**
4
+ * If `true`, the function will skip appending if the `childPath` is already a child of the `parentPath`.
5
+ *
6
+ * @defaultValue true
7
+ */
8
+ skipIfAlreadyParent?: boolean;
9
+ }
2
10
  /**
3
11
  * If not already a parent path, append the base path from the beginning of the given child path.
4
12
  *
@@ -9,13 +17,23 @@
9
17
  *
10
18
  * appendPath("/user/dev/app.ts", "/user/dev");
11
19
  * // returns "/user/dev/app.ts"
20
+ *
21
+ * appendPath("docs/readme.md");
22
+ * // returns "<current_working_directory>/docs/readme.md"
23
+ *
24
+ * appendPath("src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
25
+ * // returns "/home/user/project/src/index.ts"
26
+ *
27
+ * appendPath("/home/user/project/src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
28
+ * // returns "/home/user/project/src/index.ts"
12
29
  * ```
13
30
  *
14
31
  * @param childPath - The child path to append to the {@link parentPath}
15
32
  * @param parentPath - The parent path to add the {@link childPath} to
33
+ * @param options - Options for appending the path
16
34
  * @returns The {@link parentPath} with the {@link childPath} appended
17
35
  */
18
- declare function appendPath(childPath: string, parentPath?: string): string;
36
+ declare function appendPath(childPath: string, parentPath?: string, options?: AppendPathOptions): string;
19
37
  declare const append: typeof appendPath;
20
38
  /**
21
39
  * Append the extension to the given path.
@@ -34,5 +52,5 @@ declare const append: typeof appendPath;
34
52
  */
35
53
  declare function appendExtension(path: string, extension: string): string;
36
54
  //#endregion
37
- export { append, appendExtension, appendPath };
55
+ export { AppendPathOptions, append, appendExtension, appendPath };
38
56
  //# sourceMappingURL=append.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"append.d.mts","names":[],"sources":["../src/append.ts"],"sourcesContent":[],"mappings":";;AAuCA;AAWA;AAiBA;;;;;;;;;;;;;iBA5BgB,UAAA;cAWH,eAAM;;;;;;;;;;;;;;;;iBAiBH,eAAA"}
1
+ {"version":3,"file":"append.d.mts","names":[],"sources":["../src/append.ts"],"sourcesContent":[],"mappings":";UAuBiB,iBAAA;EAAA;AAmCjB;AAYA;AAiBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA7BgB,UAAA,mDAGL;cASE,eAAM;;;;;;;;;;;;;;;;iBAiBH,eAAA"}
package/dist/append.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{cwd as e}from"./cwd.mjs";import{slash as t}from"./slash.mjs";import{isParentPath as n}from"./is-parent-path.mjs";import{joinPaths as r}from"./join-paths.mjs";function i(i,a=e()){return t(n(i,a)?i:r(a,i))}const a=i;function o(e,t){return`${e}.${t.replace(/^\./,``)}`}export{a as append,o as appendExtension,i as appendPath};
1
+ import{cwd as e}from"./cwd.mjs";import{slash as t}from"./slash.mjs";import{isParentPath as n}from"./is-parent-path.mjs";import{joinPaths as r}from"./join-paths.mjs";function i(i,a=e(),o={}){return t(o.skipIfAlreadyParent!==!1&&n(i,a)?i:r(a,i))}const a=i;function o(e,t){return`${e}.${t.replace(/^\./,``)}`}export{a as append,o as appendExtension,i as appendPath};
2
2
  //# sourceMappingURL=append.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"append.mjs","names":[],"sources":["../src/append.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { cwd } from \"./cwd\";\nimport { isParentPath } from \"./is-parent-path\";\nimport { joinPaths } from \"./join-paths\";\nimport { slash } from \"./slash\";\n\n/**\n * If not already a parent path, append the base path from the beginning of the given child path.\n *\n * @example\n * ```ts\n * appendPath(\"src/index.ts\", \"/home/user/project\");\n * // returns \"/home/user/project/src/index.ts\"\n *\n * appendPath(\"/user/dev/app.ts\", \"/user/dev\");\n * // returns \"/user/dev/app.ts\"\n * ```\n *\n * @param childPath - The child path to append to the {@link parentPath}\n * @param parentPath - The parent path to add the {@link childPath} to\n * @returns The {@link parentPath} with the {@link childPath} appended\n */\nexport function appendPath(\n childPath: string,\n parentPath: string = cwd()\n): string {\n return slash(\n !isParentPath(childPath, parentPath)\n ? joinPaths(parentPath, childPath)\n : childPath\n );\n}\n\nexport const append = appendPath;\n\n/**\n * Append the extension to the given path.\n *\n * @example\n * ```ts\n * appendExtension(\"/home/user/project/src/index\", \".ts\");\n * // returns \"/home/user/project/src/index.ts\"\n * appendExtension(\"/home/user/project/src/index.ts\", \".js\");\n * // returns \"/home/user/project/src/index.ts.js\"\n * ```\n *\n * @param path - The path to append the extension to.\n * @param extension - The extension to append.\n * @returns The path with the appended extension.\n */\nexport function appendExtension(path: string, extension: string): string {\n return `${path}.${extension.replace(/^\\./, \"\")}`;\n}\n"],"mappings":"qKAuCA,SAAgB,EACd,EACA,EAAqB,GAAK,CAClB,CACR,OAAO,EACJ,EAAa,EAAW,EAAW,CAEhC,EADA,EAAU,EAAY,EAAU,CAErC,CAGH,MAAa,EAAS,EAiBtB,SAAgB,EAAgB,EAAc,EAA2B,CACvE,MAAO,GAAG,EAAK,GAAG,EAAU,QAAQ,MAAO,GAAG"}
1
+ {"version":3,"file":"append.mjs","names":[],"sources":["../src/append.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { cwd } from \"./cwd\";\nimport { isParentPath } from \"./is-parent-path\";\nimport { joinPaths } from \"./join-paths\";\nimport { slash } from \"./slash\";\n\nexport interface AppendPathOptions {\n /**\n * If `true`, the function will skip appending if the `childPath` is already a child of the `parentPath`.\n *\n * @defaultValue true\n */\n skipIfAlreadyParent?: boolean;\n}\n\n/**\n * If not already a parent path, append the base path from the beginning of the given child path.\n *\n * @example\n * ```ts\n * appendPath(\"src/index.ts\", \"/home/user/project\");\n * // returns \"/home/user/project/src/index.ts\"\n *\n * appendPath(\"/user/dev/app.ts\", \"/user/dev\");\n * // returns \"/user/dev/app.ts\"\n *\n * appendPath(\"docs/readme.md\");\n * // returns \"<current_working_directory>/docs/readme.md\"\n *\n * appendPath(\"src/index.ts\", \"/home/user/project\", { skipIfAlreadyParent: false });\n * // returns \"/home/user/project/src/index.ts\"\n *\n * appendPath(\"/home/user/project/src/index.ts\", \"/home/user/project\", { skipIfAlreadyParent: false });\n * // returns \"/home/user/project/src/index.ts\"\n * ```\n *\n * @param childPath - The child path to append to the {@link parentPath}\n * @param parentPath - The parent path to add the {@link childPath} to\n * @param options - Options for appending the path\n * @returns The {@link parentPath} with the {@link childPath} appended\n */\nexport function appendPath(\n childPath: string,\n parentPath: string = cwd(),\n options: AppendPathOptions = {}\n): string {\n return slash(\n options.skipIfAlreadyParent !== false && isParentPath(childPath, parentPath)\n ? childPath\n : joinPaths(parentPath, childPath)\n );\n}\n\nexport const append = appendPath;\n\n/**\n * Append the extension to the given path.\n *\n * @example\n * ```ts\n * appendExtension(\"/home/user/project/src/index\", \".ts\");\n * // returns \"/home/user/project/src/index.ts\"\n * appendExtension(\"/home/user/project/src/index.ts\", \".js\");\n * // returns \"/home/user/project/src/index.ts.js\"\n * ```\n *\n * @param path - The path to append the extension to.\n * @param extension - The extension to append.\n * @returns The path with the appended extension.\n */\nexport function appendExtension(path: string, extension: string): string {\n return `${path}.${extension.replace(/^\\./, \"\")}`;\n}\n"],"mappings":"qKA0DA,SAAgB,EACd,EACA,EAAqB,GAAK,CAC1B,EAA6B,EAAE,CACvB,CACR,OAAO,EACL,EAAQ,sBAAwB,IAAS,EAAa,EAAW,EAAW,CACxE,EACA,EAAU,EAAY,EAAU,CACrC,CAGH,MAAa,EAAS,EAiBtB,SAAgB,EAAgB,EAAc,EAA2B,CACvE,MAAO,GAAG,EAAK,GAAG,EAAU,QAAQ,MAAO,GAAG"}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { append, appendExtension, appendPath } from "./append.cjs";
1
+ import { AppendPathOptions, append, appendExtension, appendPath } from "./append.cjs";
2
2
  import { DEFAULT_ASSET_EXTS } from "./asset-extensions.cjs";
3
3
  import { correctPath, normalizeString, normalizeWindowsPath, stripStars, toAbsolutePath, toRelativePath, withTrailingSlash } from "./correct-path.cjs";
4
4
  import { cwd } from "./cwd.cjs";
@@ -11,4 +11,4 @@ import { ABSOLUTE_PATH_REGEX, DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, FILE
11
11
  import { replaceExtension, replacePath } from "./replace.cjs";
12
12
  import { resolveParentPath } from "./resolve-parent-path.cjs";
13
13
  import { formatSlash, slash } from "./slash.cjs";
14
- export { ABSOLUTE_PATH_REGEX, DEFAULT_ASSET_EXTS, DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, FILE_EXTENSION_REGEX, FindFileNameOptions, NPM_SCOPED_PACKAGE_REGEX, PACKAGE_PATH_REGEX, ROOT_FOLDER_REGEX, UNC_REGEX, append, appendExtension, appendPath, basename, correctPath, cwd, delimiter, dirname, extname, findFileDotExtension, findFileDotExtensionSafe, findFileExtension, findFileExtensionSafe, findFileName, findFilePath, findFolderName, formatSlash, hasFileExtension, hasFileName, hasFilePath, hasFolderName, isParentPath, isSystemRoot, join, joinPaths, normalizeString, normalizeWindowsPath, parsePath, posix, relative, relativePath, relativeToCurrentDir, renameFile, replaceExtension, replacePath, resolve, resolveParentPath, resolvePath, resolvePaths, slash, stripStars, toAbsolutePath, toRelativePath, win32, withTrailingSlash };
14
+ export { ABSOLUTE_PATH_REGEX, AppendPathOptions, DEFAULT_ASSET_EXTS, DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, FILE_EXTENSION_REGEX, FindFileNameOptions, NPM_SCOPED_PACKAGE_REGEX, PACKAGE_PATH_REGEX, ROOT_FOLDER_REGEX, UNC_REGEX, append, appendExtension, appendPath, basename, correctPath, cwd, delimiter, dirname, extname, findFileDotExtension, findFileDotExtensionSafe, findFileExtension, findFileExtensionSafe, findFileName, findFilePath, findFolderName, formatSlash, hasFileExtension, hasFileName, hasFilePath, hasFolderName, isParentPath, isSystemRoot, join, joinPaths, normalizeString, normalizeWindowsPath, parsePath, posix, relative, relativePath, relativeToCurrentDir, renameFile, replaceExtension, replacePath, resolve, resolveParentPath, resolvePath, resolvePaths, slash, stripStars, toAbsolutePath, toRelativePath, win32, withTrailingSlash };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { append, appendExtension, appendPath } from "./append.mjs";
1
+ import { AppendPathOptions, append, appendExtension, appendPath } from "./append.mjs";
2
2
  import { DEFAULT_ASSET_EXTS } from "./asset-extensions.mjs";
3
3
  import { correctPath, normalizeString, normalizeWindowsPath, stripStars, toAbsolutePath, toRelativePath, withTrailingSlash } from "./correct-path.mjs";
4
4
  import { cwd } from "./cwd.mjs";
@@ -11,4 +11,4 @@ import { ABSOLUTE_PATH_REGEX, DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, FILE
11
11
  import { replaceExtension, replacePath } from "./replace.mjs";
12
12
  import { resolveParentPath } from "./resolve-parent-path.mjs";
13
13
  import { formatSlash, slash } from "./slash.mjs";
14
- export { ABSOLUTE_PATH_REGEX, DEFAULT_ASSET_EXTS, DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, FILE_EXTENSION_REGEX, FindFileNameOptions, NPM_SCOPED_PACKAGE_REGEX, PACKAGE_PATH_REGEX, ROOT_FOLDER_REGEX, UNC_REGEX, append, appendExtension, appendPath, basename, correctPath, cwd, delimiter, dirname, extname, findFileDotExtension, findFileDotExtensionSafe, findFileExtension, findFileExtensionSafe, findFileName, findFilePath, findFolderName, formatSlash, hasFileExtension, hasFileName, hasFilePath, hasFolderName, isParentPath, isSystemRoot, join, joinPaths, normalizeString, normalizeWindowsPath, parsePath, posix, relative, relativePath, relativeToCurrentDir, renameFile, replaceExtension, replacePath, resolve, resolveParentPath, resolvePath, resolvePaths, slash, stripStars, toAbsolutePath, toRelativePath, win32, withTrailingSlash };
14
+ export { ABSOLUTE_PATH_REGEX, AppendPathOptions, DEFAULT_ASSET_EXTS, DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, FILE_EXTENSION_REGEX, FindFileNameOptions, NPM_SCOPED_PACKAGE_REGEX, PACKAGE_PATH_REGEX, ROOT_FOLDER_REGEX, UNC_REGEX, append, appendExtension, appendPath, basename, correctPath, cwd, delimiter, dirname, extname, findFileDotExtension, findFileDotExtensionSafe, findFileExtension, findFileExtensionSafe, findFileName, findFilePath, findFolderName, formatSlash, hasFileExtension, hasFileName, hasFilePath, hasFolderName, isParentPath, isSystemRoot, join, joinPaths, normalizeString, normalizeWindowsPath, parsePath, posix, relative, relativePath, relativeToCurrentDir, renameFile, replaceExtension, replacePath, resolve, resolveParentPath, resolvePath, resolvePaths, slash, stripStars, toAbsolutePath, toRelativePath, win32, withTrailingSlash };
@@ -1 +1 @@
1
- const e=require(`./slash.cjs`);function t(t,n){let r=e.slash(t.replace(/\\/g,`/`).replace(/\/$/,``)),i=e.slash(n.replace(/\\/g,`/`).replace(/\/$/,``));return r!==i&&r.startsWith(`${i}/`)}exports.isParentPath=t;
1
+ const e=require(`./slash.cjs`);function t(t,n){let r=e.slash(t.replaceAll(/\\/g,`/`).replace(/\/*$/,``))?.toLowerCase(),i=e.slash(n.replaceAll(/\\/g,`/`).replace(/\/*$/,``))?.toLowerCase();return r!==i&&r.startsWith(`${i}/`)}exports.isParentPath=t;
@@ -1,2 +1,2 @@
1
- import{slash as e}from"./slash.mjs";function t(t,n){let r=e(t.replace(/\\/g,`/`).replace(/\/$/,``)),i=e(n.replace(/\\/g,`/`).replace(/\/$/,``));return r!==i&&r.startsWith(`${i}/`)}export{t as isParentPath};
1
+ import{slash as e}from"./slash.mjs";function t(t,n){let r=e(t.replaceAll(/\\/g,`/`).replace(/\/*$/,``))?.toLowerCase(),i=e(n.replaceAll(/\\/g,`/`).replace(/\/*$/,``))?.toLowerCase();return r!==i&&r.startsWith(`${i}/`)}export{t as isParentPath};
2
2
  //# sourceMappingURL=is-parent-path.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-parent-path.mjs","names":[],"sources":["../src/is-parent-path.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { slash } from \"./slash\";\n\n/**\n * Check if a given path is a parent of another path.\n *\n * @example\n * ```ts\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src\");\n * // returns true\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project\");\n * // returns true\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src/other\");\n * // returns false\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/other\");\n * // returns false\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src/index.ts\");\n * // returns false\n * ```\n *\n * @param childPath - The path to check if it is a child of the parent path.\n * @param parentPath - The path to check if it is a parent of the child path.\n * @returns `true` if `childPath` is a child of `parentPath`, otherwise `false`.\n */\nexport function isParentPath(childPath: string, parentPath: string): boolean {\n const normalizedChild = slash(\n childPath.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\")\n );\n const normalizedParent = slash(\n parentPath.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\")\n );\n\n return (\n normalizedChild !== normalizedParent &&\n normalizedChild.startsWith(`${normalizedParent}/`)\n );\n}\n"],"mappings":"oCAyCA,SAAgB,EAAa,EAAmB,EAA6B,CAC3E,IAAM,EAAkB,EACtB,EAAU,QAAQ,MAAO,IAAI,CAAC,QAAQ,MAAO,GAAG,CACjD,CACK,EAAmB,EACvB,EAAW,QAAQ,MAAO,IAAI,CAAC,QAAQ,MAAO,GAAG,CAClD,CAED,OACE,IAAoB,GACpB,EAAgB,WAAW,GAAG,EAAiB,GAAG"}
1
+ {"version":3,"file":"is-parent-path.mjs","names":[],"sources":["../src/is-parent-path.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { slash } from \"./slash\";\n\n/**\n * Check if a given path is a parent of another path.\n *\n * @example\n * ```ts\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src\");\n * // returns true\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project\");\n * // returns true\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src/other\");\n * // returns false\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/other\");\n * // returns false\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src/index.ts\");\n * // returns false\n * ```\n *\n * @param childPath - The path to check if it is a child of the parent path.\n * @param parentPath - The path to check if it is a parent of the child path.\n * @returns `true` if `childPath` is a child of `parentPath`, otherwise `false`.\n */\nexport function isParentPath(childPath: string, parentPath: string): boolean {\n const normalizedChild = slash(\n childPath.replaceAll(/\\\\/g, \"/\").replace(/\\/*$/, \"\")\n )?.toLowerCase();\n const normalizedParent = slash(\n parentPath.replaceAll(/\\\\/g, \"/\").replace(/\\/*$/, \"\")\n )?.toLowerCase();\n\n return (\n normalizedChild !== normalizedParent &&\n normalizedChild.startsWith(`${normalizedParent}/`)\n );\n}\n"],"mappings":"oCAyCA,SAAgB,EAAa,EAAmB,EAA6B,CAC3E,IAAM,EAAkB,EACtB,EAAU,WAAW,MAAO,IAAI,CAAC,QAAQ,OAAQ,GAAG,CACrD,EAAE,aAAa,CACV,EAAmB,EACvB,EAAW,WAAW,MAAO,IAAI,CAAC,QAAQ,OAAQ,GAAG,CACtD,EAAE,aAAa,CAEhB,OACE,IAAoB,GACpB,EAAgB,WAAW,GAAG,EAAiB,GAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/path",
3
- "version": "0.22.13",
3
+ "version": "0.23.0",
4
4
  "type": "module",
5
5
  "description": "A package containing various utilities that expand the functionality of NodeJs's built-in `path` module",
6
6
  "repository": {
@@ -70,12 +70,12 @@
70
70
  },
71
71
  "types": "./dist/index.d.cts",
72
72
  "devDependencies": {
73
- "@storm-software/testing-tools": "^1.119.68",
74
- "@stryke/convert": "^0.6.26",
75
- "@stryke/type-checks": "^0.5.11",
76
- "@stryke/types": "^0.10.25",
73
+ "@storm-software/testing-tools": "^1.119.70",
74
+ "@stryke/convert": "^0.6.27",
75
+ "@stryke/type-checks": "^0.5.12",
76
+ "@stryke/types": "^0.10.26",
77
77
  "tsdown": "^0.17.2"
78
78
  },
79
79
  "publishConfig": { "access": "public" },
80
- "gitHead": "afcd140cfb0555b3dacd5ece701909f66c174068"
80
+ "gitHead": "df97ef1c830a6c1c50aae86f1c880b261f37f4d2"
81
81
  }