@oazmi/superbuild 0.1.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.
Files changed (118) hide show
  1. package/esm/_dnt.shims.d.ts +2 -0
  2. package/esm/_dnt.shims.d.ts.map +1 -0
  3. package/esm/_dnt.shims.js +57 -0
  4. package/esm/deps/jsr.io/@oazmi/esbuild-types/0.28.0/src/mod.d.ts +598 -0
  5. package/esm/deps/jsr.io/@oazmi/esbuild-types/0.28.0/src/mod.d.ts.map +1 -0
  6. package/esm/deps/jsr.io/@oazmi/esbuild-types/0.28.0/src/mod.js +1 -0
  7. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/alias.d.ts +617 -0
  8. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/alias.d.ts.map +1 -0
  9. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/alias.js +671 -0
  10. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array1d.d.ts +487 -0
  11. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array1d.d.ts.map +1 -0
  12. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array1d.js +536 -0
  13. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array2d.d.ts +266 -0
  14. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array2d.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array2d.js +318 -0
  16. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/binder.d.ts +368 -0
  17. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/binder.d.ts.map +1 -0
  18. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/binder.js +380 -0
  19. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/crossenv.d.ts +711 -0
  20. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/crossenv.d.ts.map +1 -0
  21. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/crossenv.js +1173 -0
  22. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/cryptoman.d.ts +171 -0
  23. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/cryptoman.d.ts.map +1 -0
  24. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/cryptoman.js +308 -0
  25. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/deps.d.ts +10 -0
  26. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/deps.d.ts.map +1 -0
  27. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/deps.js +10 -0
  28. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack.d.ts +168 -0
  29. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack.d.ts.map +1 -0
  30. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack.js +236 -0
  31. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack_varint.d.ts +90 -0
  32. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack_varint.d.ts.map +1 -0
  33. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack_varint.js +237 -0
  34. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericarray.d.ts +213 -0
  35. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericarray.d.ts.map +1 -0
  36. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericarray.js +363 -0
  37. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericmethods.d.ts +233 -0
  38. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericmethods.d.ts.map +1 -0
  39. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericmethods.js +256 -0
  40. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/pathman.d.ts +1436 -0
  41. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/pathman.d.ts.map +1 -0
  42. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/pathman.js +1730 -0
  43. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/promiseman.d.ts +647 -0
  44. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/promiseman.d.ts.map +1 -0
  45. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/promiseman.js +762 -0
  46. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/stringman.d.ts +538 -0
  47. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/stringman.d.ts.map +1 -0
  48. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/stringman.js +626 -0
  49. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/struct.d.ts +734 -0
  50. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/struct.d.ts.map +1 -0
  51. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/struct.js +764 -0
  52. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedbuffer.d.ts +137 -0
  53. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedbuffer.d.ts.map +1 -0
  54. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedbuffer.js +234 -0
  55. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedefs.d.ts +391 -0
  56. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedefs.d.ts.map +1 -0
  57. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedefs.js +8 -0
  58. package/esm/deps.d.ts +56 -0
  59. package/esm/deps.d.ts.map +1 -0
  60. package/esm/deps.js +37 -0
  61. package/esm/esbuild/metafile.d.ts +90 -0
  62. package/esm/esbuild/metafile.d.ts.map +1 -0
  63. package/esm/esbuild/metafile.js +275 -0
  64. package/esm/esbuild/native.d.ts +95 -0
  65. package/esm/esbuild/native.d.ts.map +1 -0
  66. package/esm/esbuild/native.js +127 -0
  67. package/esm/esbuild/outputfile.d.ts +86 -0
  68. package/esm/esbuild/outputfile.d.ts.map +1 -0
  69. package/esm/esbuild/outputfile.js +221 -0
  70. package/esm/esbuild/strongtypes.d.ts +90 -0
  71. package/esm/esbuild/strongtypes.d.ts.map +1 -0
  72. package/esm/esbuild/strongtypes.js +8 -0
  73. package/esm/esbuild/typedefs.d.ts +121 -0
  74. package/esm/esbuild/typedefs.d.ts.map +1 -0
  75. package/esm/esbuild/typedefs.js +55 -0
  76. package/esm/esbuild/weaktypes.d.ts +46 -0
  77. package/esm/esbuild/weaktypes.d.ts.map +1 -0
  78. package/esm/esbuild/weaktypes.js +8 -0
  79. package/esm/funcdefs.d.ts +89 -0
  80. package/esm/funcdefs.d.ts.map +1 -0
  81. package/esm/funcdefs.js +145 -0
  82. package/esm/mod.d.ts +4 -0
  83. package/esm/mod.d.ts.map +1 -0
  84. package/esm/mod.js +2 -0
  85. package/esm/package.json +3 -0
  86. package/esm/plugins/emissions_driver.d.ts +33 -0
  87. package/esm/plugins/emissions_driver.d.ts.map +1 -0
  88. package/esm/plugins/emissions_driver.js +260 -0
  89. package/esm/plugins/long_build.d.ts +138 -0
  90. package/esm/plugins/long_build.d.ts.map +1 -0
  91. package/esm/plugins/long_build.js +288 -0
  92. package/esm/plugins/native_replica.d.ts +48 -0
  93. package/esm/plugins/native_replica.d.ts.map +1 -0
  94. package/esm/plugins/native_replica.js +122 -0
  95. package/esm/super/build.d.ts +53 -0
  96. package/esm/super/build.d.ts.map +1 -0
  97. package/esm/super/build.js +39 -0
  98. package/esm/super/build_context.d.ts +83 -0
  99. package/esm/super/build_context.d.ts.map +1 -0
  100. package/esm/super/build_context.js +124 -0
  101. package/esm/super/mod.d.ts +12 -0
  102. package/esm/super/mod.d.ts.map +1 -0
  103. package/esm/super/mod.js +9 -0
  104. package/esm/super/plugin.d.ts +23 -0
  105. package/esm/super/plugin.d.ts.map +1 -0
  106. package/esm/super/plugin.js +31 -0
  107. package/esm/super/plugin_build.d.ts +38 -0
  108. package/esm/super/plugin_build.d.ts.map +1 -0
  109. package/esm/super/plugin_build.js +198 -0
  110. package/esm/super/typedefs.d.ts +323 -0
  111. package/esm/super/typedefs.d.ts.map +1 -0
  112. package/esm/super/typedefs.js +10 -0
  113. package/esm/typedefs.d.ts +21 -0
  114. package/esm/typedefs.d.ts.map +1 -0
  115. package/esm/typedefs.js +5 -0
  116. package/license.md +37 -0
  117. package/package.json +88 -0
  118. package/readme.md +181 -0
@@ -0,0 +1,1436 @@
1
+ /** utility tools for manipulating paths and obtaining `URL`s.
2
+ *
3
+ * TODO: write document level examples.
4
+ *
5
+ * url terminology:
6
+ * - urls are a subset of uris
7
+ * - a url protocol is defined as: `[scheme]://`
8
+ * - a url is defined as: `[scheme]://[host]/[path]?[queryString]#[fragmentHash]`
9
+ * - or equivalently, a url is: `[protocol][host]/[path]?[queryString]#[fragmentHash]`
10
+ * - a uri is defined as: `[scheme]:[someIdentifier]`
11
+ *
12
+ * @module
13
+ */
14
+ type PackageUriScheme = "jsr" | "npm" | "node";
15
+ type PackageUriProtocol = "jsr:" | "npm:" | "node:";
16
+ /** recognized uri schemes (i.e. the url protocol's scheme) that are returned by {@link getUriScheme}.
17
+ * - `local`: "C://absolute/path/to/file.txt"
18
+ * - `relative`: "./path/to/file.txt" or "../path/to/file.txt"
19
+ * - `file`: "file://C://absolute/path/to/file.txt"
20
+ * - `http`: "http://example.com/path/to/file.txt"
21
+ * - `https`: "https://example.com/path/to/file.txt"
22
+ * - `data`: "data:text/plain;base64,SGVsbG9Xb3JsZA==" or "data:text/plain,HelloWorld"
23
+ * - `jsr`: "jsr:@scope/package-name"
24
+ * - `npm`: "npm:@scope/package-name" or "npm:package-name"
25
+ * - `node`: "node:module" or "node:module/submodule"
26
+ */
27
+ export type UriScheme = undefined | "local" | "relative" | "file" | "http" | "https" | "data" | "blob" | PackageUriScheme;
28
+ /** this is global mapping of uri-protocol schemes that are identifiable by {@link getUriScheme} and {@link resolveAsUrl}.
29
+ * you may mutate this 2-tuple array to add or remove custom identifiable uri-schemes.
30
+ *
31
+ * @example
32
+ * adding a new uri protocol scheme named `"inline-scheme"` to our registry:
33
+ * ```ts
34
+ * import { assertEquals, assertThrows } from "jsr:@std/assert"
35
+ *
36
+ * // aliasing our functions for brevity
37
+ * const eq = assertEquals, err = assertThrows
38
+ *
39
+ * // initially, our custom "inline" scheme is unidentifiable, and cannot be used in `resolveAsUrl` as a base url
40
+ * eq(getUriScheme("inline://a/b/c.txt"), "relative")
41
+ * err(() => resolveAsUrl("./w.xyz", "inline://a/b/c.txt")) // "inline://a/b/c.txt" is identified as a relative path, and cannot be used as a base path
42
+ *
43
+ * // registering the custom protocol-scheme mapping.
44
+ * // note that you will have to declare `as any`, since the schemes are tightly defined by the type `UriScheme`.
45
+ * uriProtocolSchemeMap.push(["inline://", "inline-scheme" as any])
46
+ *
47
+ * // and now, our custom "inline" scheme becomes identifiable
48
+ * eq(getUriScheme("inline://a/b/c.txt"), "inline-scheme")
49
+ *
50
+ * // it is also now accepted by `resolveAsUrl` as a base uri
51
+ * eq(resolveAsUrl("./w.xyz", "inline://a/b/c.txt"), new URL("inline://a/b/w.xyz"))
52
+ * ```
53
+ */
54
+ export declare const uriProtocolSchemeMap: Array<[protocol: string, scheme: UriScheme]>;
55
+ /** here, you can specify which uri schemes cannot be used as a base url for resolving a url via the {@link resolveAsUrl} function.
56
+ *
57
+ * @example
58
+ * adding a new uri protocol scheme named `"base64-scheme"` to our registry, and then forbidding it from being used as a base url:
59
+ * ```ts
60
+ * import { assertEquals, assertThrows } from "jsr:@std/assert"
61
+ *
62
+ * // aliasing our functions for brevity
63
+ * const eq = assertEquals, err = assertThrows
64
+ *
65
+ * // initially, our custom "base64" scheme is unidentifiable, and cannot be used in `resolveAsUrl` as a base url
66
+ * eq(getUriScheme("base64://a/b/c.txt"), "relative")
67
+ * err(() => resolveAsUrl("./w.xyz", "base64://a/b/c.txt")) // "base64://a/b/c.txt" is identified as a relative path, and cannot be used as a base path
68
+ *
69
+ * // registering the custom protocol-scheme mapping.
70
+ * // note that you will have to declare `as any`, since the schemes are tightly defined by the type `UriScheme`.
71
+ * uriProtocolSchemeMap.push(["base64://", "base64-scheme" as any])
72
+ *
73
+ * // and now, our custom "base64" scheme becomes identifiable.
74
+ * eq(getUriScheme("base64://a/b/c.txt"), "base64-scheme")
75
+ *
76
+ * // it is also now accepted by `resolveAsUrl` as a base uri
77
+ * eq(resolveAsUrl("./w.xyz", "base64://a/b/c.txt"), new URL("base64://a/b/w.xyz"))
78
+ *
79
+ * // since we don't want to make it possible to have "base64-scheme" as a base uri, so we'll put it in the forbidden list.
80
+ * // once again `as any` is needed, since the `UriScheme` is tightly defined, and its definition cannot be changed.
81
+ * forbiddenBaseUriSchemes.push("base64-scheme" as any)
82
+ * err(() => resolveAsUrl("./w.xyz", "base64://a/b/c.txt")) // "base64://a/b/c.txt" is now amongst the forbidden schemes that cannot be combined with relative paths.
83
+ * eq(resolveAsUrl("base64://a/b/c.txt"), new URL("base64://a/b/c.txt")) // this is of course not stopping us from building urls with the "base64" scheme, so long as no relative path is attached.
84
+ * ```
85
+ */
86
+ export declare const forbiddenBaseUriSchemes: UriScheme[];
87
+ /** test whether a given path is an absolute path (either windows or posix).
88
+ *
89
+ * > [!note]
90
+ * > currently, we do consider the tilde expansion ("~") as an absolute path, even though it is not an os/fs-level path, but rather a shell feature.
91
+ * > this may result in misclassification on windows, since "~" is a valid starting character for a file or folder name
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * import { assertEquals } from "jsr:@std/assert"
96
+ *
97
+ * // aliasing our functions for brevity
98
+ * const eq = assertEquals, fn = isAbsolutePath
99
+ *
100
+ * eq(fn("/a/b/c.txt"), true)
101
+ * eq(fn("~/a/b/c.txt"), true)
102
+ * eq(fn("C:/a/b/c.txt"), true)
103
+ * eq(fn("/c:/a/b/c.txt"), true)
104
+ *
105
+ * eq(fn("a/b/c.txt"), false)
106
+ * eq(fn("./a/b/c.txt"), false)
107
+ * eq(fn("../a/b/c.txt"), false)
108
+ * ```
109
+ */
110
+ export declare const isAbsolutePath: (path: string) => boolean;
111
+ /** guesses the scheme of a url string. see {@link UriScheme} for more details.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * import { assertEquals } from "jsr:@std/assert"
116
+ *
117
+ * // aliasing our functions for brevity
118
+ * const eq = assertEquals, fn = getUriScheme
119
+ *
120
+ * eq(fn("C:/Users/me/path/to/file.txt"), "local")
121
+ * eq(fn("~/path/to/file.txt"), "local")
122
+ * eq(fn("/usr/me/path/to/file.txt"), "local")
123
+ * eq(fn("path/to/file.txt"), "relative")
124
+ * eq(fn("./path/to/file.txt"), "relative")
125
+ * eq(fn("../path/to/file.txt"), "relative")
126
+ * eq(fn("file:///c://users/me/path/to/file.txt"), "file")
127
+ * eq(fn("file:///usr/me/path/to/file.txt"), "file")
128
+ * eq(fn("jsr:@user/path/to/file"), "jsr")
129
+ * eq(fn("jsr:/@user/path/to/file"), "jsr")
130
+ * eq(fn("npm:lib/path/to/file"), "npm")
131
+ * eq(fn("npm:/lib/path/to/file"), "npm")
132
+ * eq(fn("npm:/@scope/lib/path/to/file"), "npm")
133
+ * eq(fn("node:http"), "node")
134
+ * eq(fn("node:fs/promises"), "node")
135
+ * eq(fn("data:text/plain;charset=utf-8;base64,aGVsbG8="), "data")
136
+ * eq(fn("blob:https://example.com/4800d2d8-a78c-4895"), "blob")
137
+ * eq(fn("http://google.com/style.css"), "http")
138
+ * eq(fn("https://google.com/style.css"), "https")
139
+ * eq(fn(""), undefined)
140
+ * ```
141
+ */
142
+ export declare const getUriScheme: (path: string) => UriScheme;
143
+ /** a description of a parsed jsr/npm package, that somewhat resembles the properties of regular URL. */
144
+ export interface PackagePseudoUrl {
145
+ /** the full package string, compatible to use with the `URL` constructor.
146
+ *
147
+ * > [!note]
148
+ * > this string is IS uri-encoded.
149
+ * > however, vs-code doc popup may decode the uri-encoded string,
150
+ * > giving a deceptive representation.
151
+ *
152
+ * examples:
153
+ * - `jsr:/@scope/package@version/pathname`
154
+ * - `jsr:/@scope/package`
155
+ * - `npm:/package@version/pathname`
156
+ * - `npm:/@scope/package@version`
157
+ * - `npm:/@scope/package@1.0%20-%201.2` // the version range is "1.0 - 1.2"
158
+ * - `npm:/@scope/package@%5E29` // the version range is "^9"
159
+ * - `node:/http`
160
+ * - `node:/fs/promises`
161
+ */
162
+ href: string | `${PackageUriScheme}:/${PackagePseudoUrl["host"]}${PackagePseudoUrl["pathname"]}`;
163
+ protocol: PackageUriProtocol;
164
+ /** optional scope name. */
165
+ scope?: string;
166
+ /** name of the package. the reason why we call it "pkg" instead of "package" is because "package" is a reserved word in javascript. */
167
+ pkg: string;
168
+ /** optional version string of the package. */
169
+ version?: string;
170
+ /** the pathname of the subpath that is being accessed within the package.
171
+ * this will always begin with a leading slash ("/"), even if there is no subpath being accessed.
172
+ */
173
+ pathname: string;
174
+ /** the host contains the full information about the package's string.
175
+ * that is, it has the optional scope information, the package name information, and the optional version information.
176
+ *
177
+ * > [!note]
178
+ * > this string is NOT uri-encoded, unlike {@link href}.
179
+ */
180
+ host: string | `${PackagePseudoUrl["pkg"]}` | `${PackagePseudoUrl["pkg"]}@${PackagePseudoUrl["version"]}` | `@${PackagePseudoUrl["scope"]}/${PackagePseudoUrl["pkg"]}` | `@${PackagePseudoUrl["scope"]}/${PackagePseudoUrl["pkg"]}@${PackagePseudoUrl["version"]}`;
181
+ }
182
+ /** this function parses npm and jsr package strings, and returns a pseudo URL-like object.
183
+ *
184
+ * the regex we use for parsing the input `href` string is quoted below:
185
+ * > /^(?<protocol>jsr:|npm:|node:)(\/*(@(?<scope>[^\/\s]+)\/)?(?<pkg>[^@\/\s]+)(@(?<version>[^\/\r\n\t\f\v]+))?)?(?<pathname>\/.*)?$/
186
+ *
187
+ * see the regex in action with the test cases on regex101 link: [regex101.com/r/mX3v1z/2](https://regex101.com/r/mX3v1z/2)
188
+ *
189
+ * @throws `Error` an error will be thrown if either the package name (`pkg`), or the `protocol` cannot be deduced by the regex.
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * import { assertEquals, assertThrows } from "jsr:@std/assert"
194
+ *
195
+ * // aliasing our functions for brevity
196
+ * const eq = assertEquals, err = assertThrows, fn = parsePackageUrl
197
+ *
198
+ * // basic breakdown of a package's resource uri
199
+ * eq(fn("jsr:@scope/package@version/pathname/file.ts"), {
200
+ * href: "jsr:/@scope/package@version/pathname/file.ts",
201
+ * protocol: "jsr:",
202
+ * scope: "scope",
203
+ * pkg: "package",
204
+ * version: "version",
205
+ * pathname: "/pathname/file.ts",
206
+ * host: "@scope/package@version",
207
+ * })
208
+ *
209
+ * // showing that jsr package uri's without a scope are perfectly permitted.
210
+ * // even though it isn't actually possible to do so on "jsr.io".
211
+ * // thus it is left up to the end-user to make of it what they will.
212
+ * eq(fn("jsr:package@version/pathname/"), {
213
+ * href: "jsr:/package@version/pathname/",
214
+ * protocol: "jsr:",
215
+ * scope: undefined,
216
+ * pkg: "package",
217
+ * version: "version",
218
+ * pathname: "/pathname/",
219
+ * host: "package@version",
220
+ * })
221
+ *
222
+ * // testing a case with multiple slashes ("/") after the protocol colon (":"), and no trailing slash after the version
223
+ * eq(fn("npm:///@scope/package@version"), {
224
+ * href: "npm:/@scope/package@version/",
225
+ * protocol: "npm:",
226
+ * scope: "scope",
227
+ * pkg: "package",
228
+ * version: "version",
229
+ * pathname: "/",
230
+ * host: "@scope/package@version",
231
+ * })
232
+ *
233
+ * // testing a no-scope and no-version case
234
+ * eq(fn("npm:package"), {
235
+ * href: "npm:/package/",
236
+ * protocol: "npm:",
237
+ * scope: undefined,
238
+ * pkg: "package",
239
+ * version: undefined,
240
+ * pathname: "/",
241
+ * host: "package",
242
+ * })
243
+ *
244
+ * // testing the "node:" protocol
245
+ * eq(fn("node:fs"), {
246
+ * href: "node:/fs/",
247
+ * protocol: "node:",
248
+ * scope: undefined,
249
+ * pkg: "fs",
250
+ * version: undefined,
251
+ * pathname: "/",
252
+ * host: "fs",
253
+ * })
254
+ *
255
+ * // testing the "node:" protocol with a certain pathname
256
+ * eq(fn("node:fs/promises"), {
257
+ * href: "node:/fs/promises",
258
+ * protocol: "node:",
259
+ * scope: undefined,
260
+ * pkg: "fs",
261
+ * version: undefined,
262
+ * pathname: "/promises",
263
+ * host: "fs",
264
+ * })
265
+ *
266
+ * // testing a `version` query string that contains whitespaces and url-encoded characters.
267
+ * // NOTE: the url-encoded characters in vs-code's doc popup appear decoded, so don't be fooled!
268
+ * // but the `host` is always a url-decoded string.
269
+ * eq(fn("jsr:@scope/package@1.0.0 - 1.2.0/pathname/file.ts"), {
270
+ * href: "jsr:/@scope/package@1.0.0%20-%201.2.0/pathname/file.ts",
271
+ * protocol: "jsr:",
272
+ * scope: "scope",
273
+ * pkg: "package",
274
+ * version: "1.0.0 - 1.2.0",
275
+ * pathname: "/pathname/file.ts",
276
+ * host: "@scope/package@1.0.0 - 1.2.0",
277
+ * })
278
+ *
279
+ * // testing a `version` query string that has its some of its characters (such as whitespaces) url-encoded.
280
+ * // NOTE: the url-encoded characters in vs-code's doc popup appear decoded, so don't be fooled!
281
+ * // but the `host` is always a url-decoded string.
282
+ * eq(fn("jsr:@scope/package@^2%20<2.2%20||%20>%202.3/pathname/file.ts"), {
283
+ * href: "jsr:/@scope/package@%5E2%20%3C2.2%20%7C%7C%20%3E%202.3/pathname/file.ts",
284
+ * protocol: "jsr:",
285
+ * scope: "scope",
286
+ * pkg: "package",
287
+ * version: "^2 <2.2 || > 2.3",
288
+ * pathname: "/pathname/file.ts",
289
+ * host: "@scope/package@^2 <2.2 || > 2.3",
290
+ * })
291
+ *
292
+ * // testing cases where an error should be invoked
293
+ * err(() => fn("npm:@scope/")) // missing a package name
294
+ * err(() => fn("npm:@scope//package")) // more than one slash after scope
295
+ * err(() => fn("pnpm:@scope/package@version")) // only "node:", "npm:", and "jsr:" protocols are recognized
296
+ * ```
297
+ */
298
+ export declare const parsePackageUrl: (url_href: string | URL) => PackagePseudoUrl;
299
+ /** convert a url string to an actual `URL` object.
300
+ * your input `path` url can use any scheme supported by the {@link getUriScheme} function.
301
+ * and you may also use paths with windows dir-separators ("\\"), as this function implicitly converts them a posix separator ("/").
302
+ *
303
+ * if you pass a `URL` object, then it will be returned as is.
304
+ *
305
+ * @throws `Error` an error will be thrown if `base` uri is either a relative path, or uses a data uri scheme,
306
+ * or if the provided `path` is relative, but no absolute `base` path is provided.
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * import { assertEquals, assertThrows } from "jsr:@std/assert"
311
+ *
312
+ * // aliasing our functions for brevity
313
+ * const eq = assertEquals, err = assertThrows, fn = resolveAsUrl
314
+ *
315
+ * eq(fn(new URL("some://url:8000/a/b c.txt")), new URL("some://url:8000/a/b%20c.txt"))
316
+ *
317
+ * eq(fn("/a/b/c d e.txt"), new URL("file:///a/b/c%20d%20e.txt"))
318
+ * eq(fn("~/a/b/c.txt"), new URL("file://~/a/b/c.txt"))
319
+ * eq(fn("C:/a/b/c/d/e.txt"), new URL("file:///C:/a/b/c/d/e.txt"))
320
+ * eq(fn("C:\\a\\b\\c\\d\\e.txt"), new URL("file:///C:/a/b/c/d/e.txt"))
321
+ * eq(fn("./e/f g.txt", "C:/a\\b\\c d/"), new URL("file:///C:/a/b/c%20d/e/f%20g.txt"))
322
+ * eq(fn("../c d/e/f g.txt", "C:/a/b/c d/"), new URL("file:///C:/a/b/c%20d/e/f%20g.txt"))
323
+ * eq(fn("d/../.././e.txt", "C:/a/b/c/"), new URL("file:///C:/a/b/e.txt"))
324
+ * eq(fn("d/../.././e.txt", "C:/a/b/c"), new URL("file:///C:/a/e.txt"))
325
+ * eq(fn("D:/a/b.txt", "C:/c/d.txt"), new URL("file:///D:/a/b.txt"))
326
+ * eq(fn("/a/b.txt", "C:/c/d.txt"), new URL("file:///C:/a/b.txt"))
327
+ * eq(fn("/a/b.txt", "/sys/admin/"), new URL("file:///a/b.txt"))
328
+ * eq(fn("/a/b.txt", ""), new URL("file:///a/b.txt"))
329
+ *
330
+ * eq(fn("http://cdn.esm.sh/a/b/c.txt"), new URL("http://cdn.esm.sh/a/b/c.txt"))
331
+ * eq(fn("http://cdn.esm.sh/a.txt", "file:///b/"), new URL("http://cdn.esm.sh/a.txt"))
332
+ * eq(fn("http://cdn.esm.sh/a.txt", "/b/"), new URL("http://cdn.esm.sh/a.txt"))
333
+ * eq(fn("/a/b/c.txt", "http://cdn.esm.sh/"), new URL("http://cdn.esm.sh/a/b/c.txt"))
334
+ *
335
+ * eq(fn("b/c.txt", "http://cdn.esm.sh/a/"), new URL("http://cdn.esm.sh/a/b/c.txt"))
336
+ * eq(fn("b/c.txt", "http://cdn.esm.sh/a"), new URL("http://cdn.esm.sh/b/c.txt"))
337
+ * eq(fn("./b/c.txt", "http://cdn.esm.sh/a/"), new URL("http://cdn.esm.sh/a/b/c.txt"))
338
+ * eq(fn("./b/c.txt", "http://cdn.esm.sh/a"), new URL("http://cdn.esm.sh/b/c.txt"))
339
+ * eq(fn("../b/c.txt", "https://cdn.esm.sh/a/"), new URL("https://cdn.esm.sh/b/c.txt"))
340
+ * eq(fn("../c/d.txt", "https://cdn.esm.sh/a/b"), new URL("https://cdn.esm.sh/c/d.txt"))
341
+ * eq(fn("/c/d.txt", "https://cdn.esm.sh/a/b"), new URL("https://cdn.esm.sh/c/d.txt"))
342
+ *
343
+ * eq(fn("node:fs"), new URL("node:/fs/"))
344
+ * eq(fn("node:fs/promises"), new URL("node:/fs/promises"))
345
+ * eq(fn("promises", "node:fs"), new URL("node:/fs/promises"))
346
+ * eq(fn("./promises", "node:fs"), new URL("node:/fs/promises"))
347
+ * eq(fn("./promises", "node:fs/"), new URL("node:/fs/promises"))
348
+ * eq(fn("mkdir", "node:fs/promises"), new URL("node:/fs/mkdir"))
349
+ * eq(fn("mkdir", "node:fs/promises/"), new URL("node:/fs/promises/mkdir"))
350
+ * eq(fn("./mkdir", "node:fs/promises"), new URL("node:/fs/mkdir"))
351
+ * eq(fn("./mkdir", "node:fs/promises/"), new URL("node:/fs/promises/mkdir"))
352
+ * eq(fn("/sync", "node:fs/promises/mkdir"), new URL("node:/fs/sync"))
353
+ *
354
+ * eq(fn("npm:react"), new URL("npm:/react/"))
355
+ * eq(fn("npm:react/file.txt"), new URL("npm:/react/file.txt"))
356
+ * eq(fn("npm:@facebook/react"), new URL("npm:/@facebook/react/"))
357
+ * eq(fn("./to/file.txt", "npm:react"), new URL("npm:/react/to/file.txt"))
358
+ * eq(fn("./to/file.txt", "npm:react/"), new URL("npm:/react/to/file.txt"))
359
+ * eq(fn("/to/file.txt", "npm:react/native/bin"), new URL("npm:/react/to/file.txt"))
360
+ * eq(fn("npm:react@19/jsx runtime.ts"), new URL("npm:/react@19/jsx%20runtime.ts"))
361
+ * eq(fn("npm:react@^19 <19.5/jsx.ts"), new URL("npm:/react@%5E19%20%3C19.5/jsx.ts"))
362
+ *
363
+ * eq(fn("jsr:@scope/my-lib/b.txt"), new URL("jsr:/@scope/my-lib/b.txt"))
364
+ * eq(fn("a/b.txt", "jsr:///@scope/my-lib"), new URL("jsr:/@scope/my-lib/a/b.txt"))
365
+ * eq(fn("./a/b.txt", "jsr:///@scope/my-lib"), new URL("jsr:/@scope/my-lib/a/b.txt"))
366
+ * eq(fn("a/b.txt", "jsr:///@scope/my-lib/c"), new URL("jsr:/@scope/my-lib/a/b.txt"))
367
+ * eq(fn("./a/b.txt", "jsr:///@scope/my-lib/c"), new URL("jsr:/@scope/my-lib/a/b.txt"))
368
+ * eq(fn("./a/b.txt", "jsr:///@scope/my-lib//c"), new URL("jsr:/@scope/my-lib/a/b.txt"))
369
+ * eq(fn("../a/b.txt", "jsr:/@scope/my-lib///c/"), new URL("jsr:/@scope/my-lib/a/b.txt"))
370
+ * eq(fn("./a/b.txt", "jsr:///@scope/my-lib/c/"), new URL("jsr:/@scope/my-lib/c/a/b.txt"))
371
+ * eq(fn("/a/b.txt", "jsr:my-lib/x/y/"), new URL("jsr:/my-lib/a/b.txt"))
372
+ * eq(fn("/a/b.txt", "jsr:@scope/my-lib/x/y/z"), new URL("jsr:/@scope/my-lib/a/b.txt"))
373
+ * eq(fn("/a/b.txt", "jsr:my-lib@1 || 2/x/y/z"), new URL("jsr:/my-lib@1%20%7C%7C%202/a/b.txt"))
374
+ * eq(fn("/a/b.txt", "jsr:@my/lib@1||2/x/y/z"), new URL("jsr:/@my/lib@1%7C%7C2/a/b.txt"))
375
+ *
376
+ * eq(fn("C:/a/b.txt", "jsr:@my/lib/x/y"), new URL("file:///C:/a/b.txt"))
377
+ * eq(fn("jsr:@my/lib/x/y", "C:/a/b.txt"), new URL("jsr:/@my/lib/x/y"))
378
+ * eq(fn("http://test.io/abc", "C:/a/b.txt"), new URL("http://test.io/abc"))
379
+ *
380
+ * eq(fn("blob:https://example.com/480-a78"), new URL("blob:https://example.com/480-a78"))
381
+ * eq(fn("data:text/plain;utf8,hello"), new URL("data:text/plain;utf8,hello"))
382
+ * eq(fn("data:text/plain;utf8,hello", "C:/a/b/"), new URL("data:text/plain;utf8,hello"))
383
+ *
384
+ * err(() => fn("./a/b.txt", "data:text/plain;charset=utf-8;base64,aGVsbG8="))
385
+ * err(() => fn("./a/b.txt", "blob:https://example.com/4800d2d8-a78c-4895-b68b-3690b69a0d6a"))
386
+ * err(() => fn("./a/b.txt", "./path/")) // a base path must not be relative
387
+ * err(() => fn("./a/b.txt")) // a relative path cannot be resolved on its own without a base path
388
+ * err(() => fn("./a/b.txt", "")) // an empty base path is as good as a non-existing one
389
+ * err(() => fn("fs/promises", "node:")) // the base protocol ("node:") MUST be accompanied with a package name
390
+ * ```
391
+ */
392
+ export declare const resolveAsUrl: (path: string | URL, base?: string | URL | undefined) => URL;
393
+ /** trim the leading forward-slashes at the beginning of a string.
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * import { assertEquals } from "jsr:@std/assert"
398
+ *
399
+ * // aliasing our functions for brevity
400
+ * const eq = assertEquals, fn = trimStartSlashes
401
+ *
402
+ * eq(fn("///a/b.txt//"), "a/b.txt//")
403
+ * eq(fn("/.//a/b.txt//"), ".//a/b.txt//")
404
+ * eq(fn(".///../a/b.txt//"), ".///../a/b.txt//")
405
+ * eq(fn("file:///a/b.txt//"), "file:///a/b.txt//")
406
+ * ```
407
+ */
408
+ export declare const trimStartSlashes: (str: string) => string;
409
+ /** trim the trailing forward-slashes at the end of a string, except for those that are preceded by a dotslash ("/./") or a dotdotslash ("/../")
410
+ *
411
+ * @example
412
+ * ```ts
413
+ * import { assertEquals } from "jsr:@std/assert"
414
+ *
415
+ * // aliasing our functions for brevity
416
+ * const eq = assertEquals, fn = trimEndSlashes
417
+ *
418
+ * eq(fn("///a/b.zip///"), "///a/b.zip")
419
+ * eq(fn("///a/b.zip/.///"), "///a/b.zip/./")
420
+ * eq(fn("///a/b.zip/..///"), "///a/b.zip/../")
421
+ * eq(fn("///a/b.zip/...///"), "///a/b.zip/...")
422
+ * eq(fn("///a/b.zip/wut.///"), "///a/b.zip/wut.")
423
+ * eq(fn("///a/b.zip/wut..///"), "///a/b.zip/wut..")
424
+ * eq(fn("///a/b.zip/wut...///"), "///a/b.zip/wut...")
425
+ * eq(fn(".///../a/b.zip/"), ".///../a/b.zip")
426
+ * eq(fn("file:///a/b.zip//c.txt"), "file:///a/b.zip//c.txt")
427
+ * ```
428
+ */
429
+ export declare const trimEndSlashes: (str: string) => string;
430
+ /** trim leading and trailing forward-slashes, at the beginning and end of a string.
431
+ * this is a combination of {@link trimStartSlashes} and {@link trimEndSlashes}, so see their doc comments for more precise test cases.
432
+ *
433
+ * @example
434
+ * ```ts
435
+ * import { assertEquals } from "jsr:@std/assert"
436
+ *
437
+ * // aliasing our functions for brevity
438
+ * const eq = assertEquals, fn = trimSlashes
439
+ *
440
+ * eq(fn("///a/b.zip//"), "a/b.zip")
441
+ * eq(fn("///a/b.zip/..///"), "a/b.zip/../")
442
+ * eq(fn("///a/b.zip/...///"), "a/b.zip/...")
443
+ * eq(fn("///a/b.zip/.//..///"), "a/b.zip/.//../")
444
+ * eq(fn("///a/b.zip/.//.///"), "a/b.zip/.//./")
445
+ * eq(fn(".///../a/b.zip//"), ".///../a/b.zip")
446
+ * eq(fn("file:///a/b.zip//c.txt"), "file:///a/b.zip//c.txt")
447
+ * ```
448
+ */
449
+ export declare const trimSlashes: (str: string) => string;
450
+ /** ensure that there is at least one leading slash at the beginning.
451
+ *
452
+ * @example
453
+ * ```ts
454
+ * import { assertEquals } from "jsr:@std/assert"
455
+ *
456
+ * // aliasing our functions for brevity
457
+ * const eq = assertEquals, fn = ensureStartSlash
458
+ *
459
+ * eq(fn("a/b.zip"), "/a/b.zip")
460
+ * eq(fn(".///../a/b.zip/"), "/.///../a/b.zip/")
461
+ * eq(fn("///../a/b.zip/"), "///../a/b.zip/")
462
+ * eq(fn("file:///a/b.zip//c.txt"), "/file:///a/b.zip//c.txt")
463
+ * ```
464
+ */
465
+ export declare const ensureStartSlash: (str: string) => string;
466
+ /** ensure that there is at least one leading dot-slash at the beginning.
467
+ *
468
+ * @example
469
+ * ```ts
470
+ * import { assertEquals } from "jsr:@std/assert"
471
+ *
472
+ * // aliasing our functions for brevity
473
+ * const eq = assertEquals, fn = ensureStartDotSlash
474
+ *
475
+ * eq(fn("a/b.zip"), "./a/b.zip")
476
+ * eq(fn(".///../a/b.zip/"), ".///../a/b.zip/")
477
+ * eq(fn("///../a/b.zip/"), ".///../a/b.zip/")
478
+ * eq(fn("file:///a/b.zip//c.txt"), "./file:///a/b.zip//c.txt")
479
+ * ```
480
+ */
481
+ export declare const ensureStartDotSlash: (str: string) => string;
482
+ /** ensure that there is at least one trailing slash at the end.
483
+ *
484
+ * @example
485
+ * ```ts
486
+ * import { assertEquals } from "jsr:@std/assert"
487
+ *
488
+ * // aliasing our functions for brevity
489
+ * const eq = assertEquals, fn = ensureEndSlash
490
+ *
491
+ * eq(fn("///a/b.zip//"), "///a/b.zip//")
492
+ * eq(fn(".///../a/b.zip/"), ".///../a/b.zip/")
493
+ * eq(fn(".///../a/b.zip/."), ".///../a/b.zip/./")
494
+ * eq(fn(".///../a/b.zip/./"), ".///../a/b.zip/./")
495
+ * eq(fn(".///../a/b.zip/.."), ".///../a/b.zip/../")
496
+ * eq(fn(".///../a/b.zip/../"), ".///../a/b.zip/../")
497
+ * eq(fn("file:///a/b.zip//c.txt"), "file:///a/b.zip//c.txt/")
498
+ * ```
499
+ */
500
+ export declare const ensureEndSlash: (str: string) => string;
501
+ /** trim leading forward-slashes ("/") and dot-slashes ("./"), at the beginning a string.
502
+ * but exclude non-trivial dotdotslash ("/../") from being wrongfully trimmed.
503
+ *
504
+ * @example
505
+ * ```ts
506
+ * import { assertEquals } from "jsr:@std/assert"
507
+ *
508
+ * // aliasing our functions for brevity
509
+ * const eq = assertEquals, fn = trimStartDotSlashes
510
+ *
511
+ * eq(fn("///a/b.zip/c.txt"), "a/b.zip/c.txt")
512
+ * eq(fn("///a/b.zip//"), "a/b.zip//")
513
+ * eq(fn("//..//a/b.zip//"), "..//a/b.zip//")
514
+ * eq(fn("/./..//a/b.zip//"), "..//a/b.zip//")
515
+ * eq(fn("/./.././a/b.zip//"), ".././a/b.zip//")
516
+ * eq(fn("///././///.////a/b.zip//"), "a/b.zip//")
517
+ * eq(fn(".///././///.////a/b.zip//"), "a/b.zip//")
518
+ * eq(fn("./././//././///.////a/b.zip//"), "a/b.zip//")
519
+ * eq(fn("file:///a/b.zip//c.txt"), "file:///a/b.zip//c.txt")
520
+ * ```
521
+ */
522
+ export declare const trimStartDotSlashes: (str: string) => string;
523
+ /** trim all trivial trailing forward-slashes ("/") and dot-slashes ("./"), at the end a string.
524
+ * but exclude non-trivial dotdotslash ("/../") from being wrongfully trimmed.
525
+ *
526
+ * TODO: this operation is somewhat expensive, because:
527
+ * - the implementation uses regex, however it was not possible for me to design a regex that handles the input string as is,
528
+ * so I resort to reversing the input string, and using a slightly easier-to-design regex that discovers trivial (dot)slashes in reverse order,
529
+ * and then after the string replacement, I reverse it again and return it as the output.
530
+ *
531
+ * @example
532
+ * ```ts
533
+ * import { assertEquals } from "jsr:@std/assert"
534
+ *
535
+ * // aliasing our functions for brevity
536
+ * const eq = assertEquals, fn = trimEndDotSlashes
537
+ *
538
+ * eq(fn("a/b.zip/c.txt"), "a/b.zip/c.txt")
539
+ * eq(fn("//a/b.zip//"), "//a/b.zip")
540
+ * eq(fn("/"), "")
541
+ * eq(fn("./"), "")
542
+ * eq(fn("//././//./"), "")
543
+ * eq(fn(".//././//./"), "")
544
+ * eq(fn(".//./..///./"), ".//./../")
545
+ * eq(fn("/a/b.zip/./"), "/a/b.zip")
546
+ * eq(fn("/a/b.zip/../"), "/a/b.zip/../")
547
+ * eq(fn("/a/b.zip/..//"), "/a/b.zip/../")
548
+ * eq(fn("/a/b.zip/.././"), "/a/b.zip/../")
549
+ * eq(fn("a/b.zip///././///.////"), "a/b.zip")
550
+ * eq(fn("/a/b.zip///././///.////"), "/a/b.zip")
551
+ * eq(fn("/a/b.zip/.././/.././///.////"), "/a/b.zip/.././/../")
552
+ * eq(fn("/a/b.zip/././././///.////"), "/a/b.zip")
553
+ * eq(fn("/a/b.zip./././././///.////"), "/a/b.zip.")
554
+ * eq(fn("/a/b.zip../././././///.////"), "/a/b.zip..")
555
+ * eq(fn("/a/b.zip.../././././///.////"), "/a/b.zip...")
556
+ * eq(fn("file:///a/b.zip//c.txt"), "file:///a/b.zip//c.txt")
557
+ * ```
558
+ */
559
+ export declare const trimEndDotSlashes: (str: string) => string;
560
+ /** trim leading and trailing forward-slashes ("/") and dot-slashes ("./"), at the beginning and end of a string, but keep trailing non-trivial ones intact.
561
+ * this is a combination of {@link trimStartDotSlashes} and {@link trimEndDotSlashes}, so see their doc comments for more precise test cases.
562
+ *
563
+ * @example
564
+ * ```ts
565
+ * import { assertEquals } from "jsr:@std/assert"
566
+ *
567
+ * // aliasing our functions for brevity
568
+ * const eq = assertEquals, fn = trimDotSlashes
569
+ *
570
+ * eq(fn("///a/b.zip//"), "a/b.zip")
571
+ * eq(fn(".///../a/b.zip//"), "../a/b.zip")
572
+ * eq(fn("//./././///././//../a/b.zip//"), "../a/b.zip")
573
+ * eq(fn("file:///a/b.zip//c.txt"), "file:///a/b.zip//c.txt")
574
+ * ```
575
+ */
576
+ export declare const trimDotSlashes: (str: string) => string;
577
+ /** TODO: purge this function in the future, if you absolutely do not use it anywhere.
578
+ * @deprecated
579
+ *
580
+ * > [!note]
581
+ * > you'd probably want to use {@link joinPaths} instead of this function, for any realistic set of path segments.
582
+ * > not only is this more expensive to compute, it does not distinguish between a directory and a file path (intentionally).
583
+ *
584
+ * join path segments with forward-slashes in between, and remove redundant slashes ("/") and dotslashes ("./") around each segment (if any).
585
+ * however, the first segment's leading and trailing slashes are left untouched,
586
+ * because that would potentially strip away location information (such as relative path ("./"), or absolute path ("/"), or some uri ("file:///")).
587
+ *
588
+ * if you want to ensure that your first segment is shortened, use either the {@link normalizePath} or {@link normalizePosixPath} function on it before passing it here.
589
+ *
590
+ * > [!warning]
591
+ * > it is recommended that you use segments with posix path dir-separators ("/").
592
+ *
593
+ * @example
594
+ * ```ts
595
+ * import { assertEquals } from "jsr:@std/assert"
596
+ *
597
+ * // aliasing our functions for brevity
598
+ * const eq = assertEquals, fn = joinSlash
599
+ *
600
+ * eq(fn(".///../a", "b", "c.txt"), ".///../a/b/c.txt")
601
+ * eq(fn("file:///a/", "b.zip//", "./c.txt"), "file:///a/b.zip/c.txt")
602
+ * eq(fn("file:///", "a/", "b.zip//", "./c.txt"), "file:///a/b.zip/c.txt")
603
+ * eq(fn("///a//", "b.//", "zip..//"), "///a//b./zip..")
604
+ * eq(fn("a/", "b.zip", "./c.txt", ""), "a/b.zip/c.txt/")
605
+ * eq(fn("a/", "b.zip", "./c.txt", "."), "a/b.zip/c.txt/")
606
+ * eq(fn("a/", "b.zip", "./c.txt", "./"), "a/b.zip/c.txt/")
607
+ * eq(fn("a/", "b.zip", "./c.txt", ".."), "a/b.zip/c.txt/..")
608
+ * eq(fn("a/", "b.zip", "./c.txt", "..."), "a/b.zip/c.txt/...")
609
+ * eq(fn("", "", ""), "")
610
+ * eq(fn("/", "", ""), "/")
611
+ * eq(fn("/", "/", ""), "/")
612
+ * eq(fn("/", "", "/"), "/")
613
+ * eq(fn("/", "/", "/"), "/")
614
+ * eq(fn("./", "", ""), "./")
615
+ * eq(fn("./", "./", ""), "./")
616
+ * eq(fn("./", "", "./"), "./")
617
+ * eq(fn("./", "./", "./"), "./")
618
+ * eq(fn(
619
+ * "//./././///././//../a/b.zip/.////",
620
+ * "///.////././.././c.txt/./../",
621
+ * "../../d.xyz//.//",
622
+ * ), "//./././///././//../a/b.zip/.////.././c.txt/./../../../d.xyz")
623
+ * ```
624
+ */
625
+ export declare const joinSlash: (first_segment?: string, ...segments: string[]) => string;
626
+ /** config options for {@link normalizePosixPath} and {@link normalizePath} */
627
+ export interface NormalizePathConfig {
628
+ /** specify whether or not to preserve the relative leading dotslash ("./") directory specifier?
629
+ *
630
+ * here is what you would get for each of the following input values, based on how you configure this setting:
631
+ * - `input = "././//../a/./././b.txt"`
632
+ * - `true`: `".//a/./././b.txt"`
633
+ * - `false`: `"/a/./././b.txt"`
634
+ * - `input = "./././././"`
635
+ * - `true`: `"./"`
636
+ * - `false`: `""`
637
+ * - `input = "a/b.txt/././../././"`
638
+ * - `true`: `"a"`
639
+ * - `false`: `"a"`
640
+ * - `input = "/./././/a/b.txt"`
641
+ * - `true`: `"//a/b.txt"`
642
+ * - `false`: `"//a/b.txt"`
643
+ *
644
+ * @defaultValue `true`
645
+ */
646
+ keepRelative?: boolean;
647
+ }
648
+ /** normalize a path by reducing and removing redundant dot-slash ("./" and "../") path navigators from a path.
649
+ *
650
+ * if you provide the optional `config` with the `keepRelative` set to `false`, then in the output, there will no be leading dot-slashes ("./").
651
+ * read more about the option here: {@link NormalizePathConfig.keepRelative}.
652
+ * but note that irrespective of what you set this option to be, leading leading dotdot-slashes ("../") and leading slashes ("/") will not be trimmed.
653
+ *
654
+ * even though `config` should be of {@link NormalizePathConfig} type, it also accepts `number` so that the function's signature becomes compatible with the `Array.prototype.map` method,
655
+ * however, unless you pass the correct config object type, only the default action will be taken.
656
+ *
657
+ * > [!warning]
658
+ * > you MUST provide a posix path (i.e. use "/" for dir-separator).
659
+ * > there will not be any implicit conversion of windows "\\" dir-separator.
660
+ *
661
+ * @example
662
+ * ```ts
663
+ * import { assertEquals } from "jsr:@std/assert"
664
+ *
665
+ * // aliasing our functions for brevity
666
+ * const eq = assertEquals, fn = normalizePosixPath
667
+ * // aliasing the config for disabling the preservation of leading "./"
668
+ * const remove_rel: NormalizePathConfig = { keepRelative: false }
669
+ *
670
+ * eq(fn("../a/./b/../././/c.txt"), "../a//c.txt")
671
+ * eq(fn("./././a/b/.././././//c.txt"), "./a///c.txt")
672
+ * eq(fn("./././a/b/.././././//c.txt", remove_rel), "a///c.txt")
673
+ * eq(fn("/a/b/.././././//c.txt"), "/a///c.txt")
674
+ * eq(fn("///a/b/.././././//c.txt"), "///a///c.txt")
675
+ * eq(fn("///a/b/.././.././//c.txt"), "/////c.txt")
676
+ * eq(fn("file:///./././a/b/.././././c.txt"), "file:///a/c.txt")
677
+ * eq(fn("/a/../"), "/")
678
+ * // NOTICE: the test in the next line may seem like a weird behavior.
679
+ * eq(fn("/a/../../"), "")
680
+ * eq(fn("/a/../../../"), "../")
681
+ * eq(fn("./a/../../"), "../")
682
+ * eq(fn("./a/../../../"), "../../")
683
+ * eq(fn("/a/b/../.."), "/")
684
+ * eq(fn("/a/b/."), "/a/b/")
685
+ * eq(fn("/a/b/./"), "/a/b/")
686
+ * eq(fn("/a/b/c/.."), "/a/b/")
687
+ * eq(fn("/a/b/c/../."), "/a/b/")
688
+ * eq(fn("/a/b/c/d/../.."), "/a/b/")
689
+ * eq(fn("/a/b/c/../.nomedia"), "/a/b/.nomedia")
690
+ * eq(fn(""), "")
691
+ * eq(fn("."), ".")
692
+ * eq(fn(".."), "..")
693
+ * eq(fn("./"), "./")
694
+ * eq(fn("../"), "../")
695
+ * eq(fn("../."), "../")
696
+ * eq(fn("../.."), "../../")
697
+ * eq(fn("./././././"), "./")
698
+ * eq(fn(".././././"), "../")
699
+ * eq(fn("./././.././././"), "../")
700
+ * eq(fn("./././.././.././"), "../../")
701
+ * eq(fn(".", remove_rel), "")
702
+ * eq(fn("./", remove_rel), "")
703
+ * eq(fn("./././././", remove_rel), "")
704
+ * eq(fn("./././.././././", remove_rel), "../")
705
+ * eq(fn("./././.././.././", remove_rel), "../../")
706
+ * ```
707
+ */
708
+ export declare const normalizePosixPath: (path: string, config?: NormalizePathConfig | number) => string;
709
+ /** normalize a path by reducing and removing redundant dot-slash ("./", "../", ".\\", and "..\\") path navigators from a path.
710
+ * the returned output is always a posix-style path.
711
+ *
712
+ * to read about the optional `config` parameter, refer to the docs of {@link normalizePosixPath}, which is the underlying function that takes care most of the normalization.
713
+ *
714
+ * @example
715
+ * ```ts
716
+ * import { assertEquals } from "jsr:@std/assert"
717
+ *
718
+ * // aliasing our functions for brevity
719
+ * const eq = assertEquals, fn = normalizePath
720
+ *
721
+ * eq(fn("../a/./b/../././/c.txt"), "../a//c.txt")
722
+ * eq(fn("./.\\.\\a\\b\\.././.\\.///c.txt"), "./a///c.txt")
723
+ * eq(fn("/home\\.config/a\\..\\...\\b\\./c.txt"), "/home/.config/.../b/c.txt")
724
+ * eq(fn("file:///./././a\\b/..\\././.\\c.txt"), "file:///a/c.txt")
725
+ * ```
726
+ */
727
+ export declare const normalizePath: (path: string, config?: NormalizePathConfig | number) => string;
728
+ /** convert windows directory slash "\\" to posix directory slash "/".
729
+ *
730
+ * @example
731
+ * ```ts
732
+ * import { assertEquals } from "jsr:@std/assert"
733
+ *
734
+ * // aliasing our functions for brevity
735
+ * const eq = assertEquals, fn = pathToPosixPath
736
+ *
737
+ * eq(fn("C:\\Users/my name\\file.txt"), "C:/Users/my name/file.txt")
738
+ * eq(fn("~/path/to/file.txt"), "~/path/to/file.txt")
739
+ * eq(fn("/path\\to file.txt"), "/path/to file.txt")
740
+ * ```
741
+ */
742
+ export declare const pathToPosixPath: (path: string) => string;
743
+ /** convert an array of paths to cli compatible list of paths, suitable for setting as an environment variable.
744
+ *
745
+ * @example
746
+ * ```ts
747
+ * import { assertEquals } from "jsr:@std/assert"
748
+ *
749
+ * // aliasing our functions for brevity
750
+ * const eq = assertEquals, fn = pathsToCliArg
751
+ *
752
+ * // conversion example with windows separator (";")
753
+ * eq(fn(";", [
754
+ * "./a/b/c.txt",
755
+ * "C:\\Android Studio\\sdk\\",
756
+ * "build\\libs\\"
757
+ * ]), `"./a/b/c.txt;C:/Android Studio/sdk/;build/libs/"`)
758
+ *
759
+ * // conversion example with unix separator (":")
760
+ * eq(fn(":", [
761
+ * "./a/b/c.txt",
762
+ * "~/Android Studio/sdk/",
763
+ * "build/libs/"
764
+ * ]), `"./a/b/c.txt:~/Android Studio/sdk/:build/libs/"`)
765
+ * ```
766
+ */
767
+ export declare const pathsToCliArg: (separator: ";" | ":", paths: string[]) => string;
768
+ /** find the prefix path directory common to all provided `paths`.
769
+ * > [!warning]
770
+ * > your paths MUST be normalized beforehand, and use posix dir-separators ("/").
771
+ *
772
+ * @example
773
+ * ```ts
774
+ * import { assertEquals } from "jsr:@std/assert"
775
+ *
776
+ * // aliasing our functions for brevity
777
+ * const eq = assertEquals, fn = commonNormalizedPosixPath
778
+ *
779
+ * eq(fn([
780
+ * "C:/Hello/World/This/Is/An/Example/Bla.cs",
781
+ * "C:/Hello/World/This/Is/Not/An/Example/",
782
+ * "C:/Hello/Earth/Bla/Bla/Bla",
783
+ * ]), "C:/Hello/")
784
+ *
785
+ * eq(fn([
786
+ * "C:/Hello/World/This/Is/An/Example/Bla.cs",
787
+ * "C:/Hello/World/This/is/an/example/bla.cs",
788
+ * "C:/Hello/World/This/Is/Not/An/Example/",
789
+ * ]), "C:/Hello/World/This/")
790
+ *
791
+ * eq(fn([
792
+ * "./../Hello/World/Users/This/Is/An/Example/Bla.cs",
793
+ * "./../Hello/World Users/This/Is/An/example/bla.cs",
794
+ * "./../Hello/World-Users/This/Is/Not/An/Example/",
795
+ * ]), "./../Hello/")
796
+ *
797
+ * eq(fn([
798
+ * "./Hello/World/Users/This/Is/An/Example/Bla.cs",
799
+ * "./Hello/World/",
800
+ * "./Hello/World", // the "World" here segment is not treated as a directory
801
+ * ]), "./Hello/")
802
+ *
803
+ * eq(fn([
804
+ * "C:/Hello/World/",
805
+ * "/C:/Hello/World/",
806
+ * "C:/Hello/World/",
807
+ * ]), "") // no common prefix was identified
808
+ * ```
809
+ */
810
+ export declare const commonNormalizedPosixPath: (paths: string[]) => string;
811
+ /** find the prefix path directory common to all provided `paths`.
812
+ * your input `paths` do not need to be normalized nor necessarily use posix-style separator "/".
813
+ * under the hood, this function normalizes and converts all paths to posix-style, then applies the {@link commonNormalizedPosixPath} onto them.
814
+ *
815
+ * @example
816
+ * ```ts
817
+ * import { assertEquals } from "jsr:@std/assert"
818
+ *
819
+ * // aliasing our functions for brevity
820
+ * const eq = assertEquals, fn = commonPath
821
+ *
822
+ * eq(fn([
823
+ * "C:/Hello/World/This/Is/An/Example/Bla.cs",
824
+ * "C:\\Hello\\World\\This\\Is\\Not/An/Example/",
825
+ * "C:/Hello/Earth/Bla/Bla/Bla",
826
+ * ]), "C:/Hello/")
827
+ *
828
+ * eq(fn([
829
+ * "./Hello/World/This/Used/to-be-an/example/../../../Is/An/Example/Bla.cs",
830
+ * ".\\Hello/World/This/Is/an/example/bla.cs",
831
+ * "./Hello/World/This/Is/Not/An/Example/",
832
+ * ]), "./Hello/World/This/Is/")
833
+ *
834
+ * eq(fn([
835
+ * "./../home/Hello/World/Users/This/Is/An/Example/Bla.cs",
836
+ * "././../home\\Hello\\World Users\\This\\Is/An\\example/bla.cs",
837
+ * "./../home/./.\\.\\././Hello/World-Users/./././././This/Is/Not/An/Example/",
838
+ * ]), "../home/Hello/")
839
+ *
840
+ * eq(fn([
841
+ * "\\C:/Hello/World/Users/This/Is/An/Example/Bla.cs",
842
+ * "/C:\\Hello\\World Users\\This\\Is/An\\example/bla.cs",
843
+ * "/C:/Hello/World", // the "World" here segment is not treated as a directory
844
+ * ]), "/C:/Hello/")
845
+ * ```
846
+ */
847
+ export declare const commonPath: (paths: string[]) => string;
848
+ /** replace the common path among all provided `paths` by transforming it with a custom `map_fn` function.
849
+ * all `paths` are initially normalized and converted into posix-style (so that no "\\" windows separator is prevelent).
850
+ *
851
+ * the `map_fn` function's first argument (`path_info`), is a 2-tuple of the form `[common_dir: string, subpath: string]`,
852
+ * where `common_dir` represents the directory common to all of the input `paths`, and the `subpath` represents the remaining relative path that comes after common_dir.
853
+ * - the `common_dir` always ends with a trailing slash ("/"), unless there is absolutely no common directory among the `paths` at all.
854
+ * - the `subpath` never begins with any slash (nor any dot-slashes), unless of course, you had initially provided a path containing two or more consecutive slashes.
855
+ *
856
+ * @example
857
+ * ```ts
858
+ * import { assertEquals } from "jsr:@std/assert"
859
+ *
860
+ * // aliasing our functions for brevity
861
+ * const eq = assertEquals, fn = commonPathTransform
862
+ *
863
+ * const subpath_map_fn = ([common_dir, subpath]: [string, string]) => (subpath)
864
+ *
865
+ * eq(fn([
866
+ * "C:/Hello/World/This/Is/An/Example/Bla.cs",
867
+ * "C:\\Hello\\World\\This\\Is\\Not/An/Example/",
868
+ * "C:/Hello/Earth/Bla/Bla/Bla",
869
+ * ], subpath_map_fn), [
870
+ * "World/This/Is/An/Example/Bla.cs",
871
+ * "World/This/Is/Not/An/Example/",
872
+ * "Earth/Bla/Bla/Bla",
873
+ * ])
874
+ *
875
+ * eq(fn([
876
+ * "./../././home/Hello/World/This/Used/to-be-an/example/../../../Is/An/Example/Bla.cs",
877
+ * "./././../home/Hello/World/This/Is/an/example/bla.cs",
878
+ * "./../home/Hello/World/This/Is/Not/An/Example/",
879
+ * ], subpath_map_fn), [
880
+ * "An/Example/Bla.cs",
881
+ * "an/example/bla.cs",
882
+ * "Not/An/Example/",
883
+ * ])
884
+ *
885
+ * eq(fn([
886
+ * "/C:/Hello///World/Users/This/Is/An/Example/Bla.cs",
887
+ * "/C:\\Hello\\World Users\\This\\Is/An\\example/bla.cs",
888
+ * "/C:/./.\\.\\././Hello/World-Users/./././././This/Is/Not/An/Example/",
889
+ * ], subpath_map_fn), [
890
+ * "//World/Users/This/Is/An/Example/Bla.cs",
891
+ * "World Users/This/Is/An/example/bla.cs",
892
+ * "World-Users/This/Is/Not/An/Example/",
893
+ * ])
894
+ * ```
895
+ */
896
+ export declare const commonPathTransform: <T = string, PathInfo extends [common_dir: string, subpath: string] = [common_dir: string, subpath: string]>(paths: string[], map_fn: ((path_info: PathInfo, index: number, path_infos: Array<PathInfo>) => T)) => T[];
897
+ /** purge the common path among all provided `paths`, and replace (join) it with a `new_common_dir` path.
898
+ *
899
+ * @example
900
+ * ```ts
901
+ * import { assertEquals } from "jsr:@std/assert"
902
+ *
903
+ * // aliasing our functions for brevity
904
+ * const eq = assertEquals, fn = commonPathReplace
905
+ *
906
+ * eq(fn([
907
+ * "C:/Hello/World/This/Is/An/Example/Bla.cs",
908
+ * "C:\\Hello\\World\\This\\Is\\Not/An/Example/",
909
+ * "C:/Hello/Earth/Bla/Bla/Bla",
910
+ * ], "D:/"), [
911
+ * "D:/World/This/Is/An/Example/Bla.cs",
912
+ * "D:/World/This/Is/Not/An/Example/",
913
+ * "D:/Earth/Bla/Bla/Bla",
914
+ * ])
915
+ *
916
+ * eq(fn([
917
+ * "C:/Hello/World/This/Used/to-be-an/example/../../../Is/An/Example/Bla.cs",
918
+ * "C:/Hello/World/This/Is/an/example/bla.cs",
919
+ * "C:/Hello/World/This/Is/Not/An/Example/",
920
+ * ], "D:/temp"), [ // an implicit forward slash is added.
921
+ * "D:/temp/An/Example/Bla.cs",
922
+ * "D:/temp/an/example/bla.cs",
923
+ * "D:/temp/Not/An/Example/",
924
+ * ])
925
+ *
926
+ * eq(fn([
927
+ * // there is no common ancestor among each of the paths (even "C:/" and "./C:/" are not considered to be equivalent to one another)
928
+ * "http:/Hello/World.cs",
929
+ * "./C:/Hello/World.cs",
930
+ * "C:/Hello/World/file.cs",
931
+ * ], "D:/temp/"), [
932
+ * "D:/temp/http:/Hello/World.cs",
933
+ * "D:/temp/C:/Hello/World.cs",
934
+ * "D:/temp/C:/Hello/World/file.cs",
935
+ * ])
936
+ *
937
+ * eq(fn([
938
+ * "/C:/Hello///World/Users/This/Is/An/Example/Bla.cs",
939
+ * "/C:\\Hello\\World Users\\This\\Is/An\\example/bla.cs",
940
+ * "/C:/./.\\.\\././Hello/World-Users/./././././This/Is/Not/An/Example/",
941
+ * ], "file:///./.\\HELLO.\\./../"), [ // the `new_common_dir` is not normalized by this function
942
+ * "file:///./.\\HELLO.\\./..///World/Users/This/Is/An/Example/Bla.cs",
943
+ * "file:///./.\\HELLO.\\./../World Users/This/Is/An/example/bla.cs",
944
+ * "file:///./.\\HELLO.\\./../World-Users/This/Is/Not/An/Example/",
945
+ * ])
946
+ * ```
947
+ */
948
+ export declare const commonPathReplace: (paths: string[], new_common_dir: string) => string[];
949
+ /** the file path info data parsed by {@link parseFilepath}.
950
+ *
951
+ * example: if we have a file path `"D:/Hello\\World\\temp/.././dist for web/file.tar.gz"`, then the following will be its parsed components:
952
+ * - `path = "D:/Hello/World/dist for web/file.tar.gz"` - the normalized full path.
953
+ * - `dirpath = "D:/Hello/World/dist for web/"` - the normalized full path of the directory in which the file resides in. always has a trailing slash ("/").
954
+ * - `dirname = "dist for web"` - the name of the directory in which the file exists, without any leading or trailing slashes ("/").
955
+ * - `filename = "file.tar.gz"` - the name of the file, without any leading slashes ("/"), and cannot possibly have a trailing slash without being parsed as a directory instead of a file.
956
+ * - `basename = "file.tar"` - the `filename`, but with the final extension portion removed.
957
+ * - `extname = ".gz"` - the final extension portion of the `filename`.
958
+ */
959
+ export interface FilepathInfo {
960
+ path: string;
961
+ dirpath: string;
962
+ dirname: string;
963
+ filename: string;
964
+ basename: string;
965
+ extname: string;
966
+ }
967
+ /** parses the provided file path and breaks it down into useful bit described by the interface {@link FilepathInfo}.
968
+ * note that a file path must never end in a trailing slash ("/"), and conversely,
969
+ * a folder path must always in a trailing slash ("/"), otherwise it will be parsed as a file.
970
+ *
971
+ * @example
972
+ * ```ts
973
+ * import { assertEquals } from "jsr:@std/assert"
974
+ *
975
+ * // aliasing our functions for brevity
976
+ * const eq = assertEquals, fn = parseFilepathInfo
977
+ *
978
+ * eq(fn("/home\\user/docs"), {
979
+ * path: "/home/user/docs",
980
+ * dirpath: "/home/user/",
981
+ * dirname: "user",
982
+ * filename: "docs",
983
+ * basename: "docs",
984
+ * extname: "",
985
+ * })
986
+ *
987
+ * eq(fn("home\\user/docs/"), {
988
+ * path: "home/user/docs/",
989
+ * dirpath: "home/user/docs/",
990
+ * dirname: "docs",
991
+ * filename: "",
992
+ * basename: "",
993
+ * extname: "",
994
+ * })
995
+ *
996
+ * eq(fn("/home/xyz/.././././user/.bashrc."), {
997
+ * path: "/home/user/.bashrc.",
998
+ * dirpath: "/home/user/",
999
+ * dirname: "user",
1000
+ * filename: ".bashrc.",
1001
+ * basename: ".bashrc.",
1002
+ * extname: "",
1003
+ * })
1004
+ *
1005
+ * eq(fn("C:\\home\\user/.file.tar.gz"), {
1006
+ * path: "C:/home/user/.file.tar.gz",
1007
+ * dirpath: "C:/home/user/",
1008
+ * dirname: "user",
1009
+ * filename: ".file.tar.gz",
1010
+ * basename: ".file.tar",
1011
+ * extname: ".gz", // only the last bit of the extension makes it to here
1012
+ * })
1013
+ *
1014
+ * eq(fn("/home/user///file.txt"), {
1015
+ * path: "/home/user///file.txt",
1016
+ * dirpath: "/home/user///",
1017
+ * dirname: "", // this is because the there is no name attached between the last two slashes of the `dirpath = "/home/user///"`
1018
+ * filename: "file.txt",
1019
+ * basename: "file",
1020
+ * extname: ".txt",
1021
+ * })
1022
+ *
1023
+ * eq(fn("file://C:/home\\hello world.txt"), {
1024
+ * path: "file://C:/home/hello world.txt", // file-urls are not converted, nor is any kind of url
1025
+ * dirpath: "file://C:/home/",
1026
+ * dirname: "home",
1027
+ * filename: "hello world.txt",
1028
+ * basename: "hello world",
1029
+ * extname: ".txt",
1030
+ * })
1031
+ * ```
1032
+ */
1033
+ export declare const parseFilepathInfo: (file_path: string) => FilepathInfo;
1034
+ /** convert the input file-url to a filesystem local-path.
1035
+ * however, if the input uri is not a file url (for instance `"C:/x/y/z"`, or `"http://hello.com"`),
1036
+ * then `undefined` will be returned.
1037
+ *
1038
+ * if you are looking to convert any _potential_ file-url back to a filesystem local-path,
1039
+ * then the {@link ensureFileUrlIsLocalPath} function would be better suited for your need.
1040
+ *
1041
+ * @example
1042
+ * ```ts
1043
+ * import { assertEquals } from "jsr:@std/assert"
1044
+ *
1045
+ * // aliasing our functions for brevity
1046
+ * const
1047
+ * fn = fileUrlToLocalPath,
1048
+ * eq = assertEquals
1049
+ *
1050
+ * eq( fn("file:///C:/Users/me/projects/"), "C:/Users/me/projects/")
1051
+ * eq( fn("file:///C:\\Users\\me/projects/"), "C:/Users/me/projects/")
1052
+ * eq( fn("file:///sys/etc/bin/deno.so"), "/sys/etc/bin/deno.so")
1053
+ * eq( fn("file:///sys\\etc/bin\\deno.so"), "/sys/etc/bin/deno.so")
1054
+ * eq( fn("file://localhost/C:/Users/me/projects/"), "C:/Users/me/projects/")
1055
+ * eq( fn("file://localhost/sys/etc/bin/deno.so"), "/sys/etc/bin/deno.so")
1056
+ * eq(fn(new URL("file:///C:/Users/me/projects/")), "C:/Users/me/projects/")
1057
+ * eq(fn(new URL("file:///sys/etc/bin/deno.so")), "/sys/etc/bin/deno.so")
1058
+ * eq(fn(new URL("file://localhost/C:/Users/me/projects/")), "C:/Users/me/projects/")
1059
+ * eq(fn(new URL("file://localhost/sys/etc/bin/deno.so")), "/sys/etc/bin/deno.so")
1060
+ *
1061
+ * // everything below is not a file-url, and therefore cannot be converted.
1062
+ * eq( fn("http://localhost:8000/hello/world/"), undefined)
1063
+ * eq( fn("C:/Users/me/projects/"), undefined)
1064
+ * eq( fn("/sys/etc/bin/deno.so"), undefined)
1065
+ * eq( fn(""), undefined)
1066
+ * ```
1067
+ */
1068
+ export declare const fileUrlToLocalPath: (file_url: URL | string) => string | undefined;
1069
+ /** a fault tolerant variant of {@link fileUrlToLocalPath} that assures you that any file-url path will get converted into a filesystem local-path.
1070
+ * otherwise, when a non-file-url is provided, its string representation (href) will be returned if it was a `URL`,
1071
+ * else the original string will be returned back.
1072
+ *
1073
+ * @example
1074
+ * ```ts
1075
+ * import { assertEquals } from "jsr:@std/assert"
1076
+ *
1077
+ * // aliasing our functions for brevity
1078
+ * const
1079
+ * fn = ensureFileUrlIsLocalPath,
1080
+ * eq = assertEquals
1081
+ *
1082
+ * eq( fn("C:/Users/me/projects/"), "C:/Users/me/projects/")
1083
+ * eq( fn("C:\\Users\\me/projects/"), "C:/Users/me/projects/")
1084
+ * eq( fn("/C:/Users\\me/projects/"), "/C:/Users/me/projects/") // note the erroneous leading slash
1085
+ * eq( fn("/sys\\etc/bin\\deno.so"), "/sys/etc/bin/deno.so")
1086
+ * eq( fn("file:///C:/Users/me/projects/"), "C:/Users/me/projects/")
1087
+ * eq( fn("file://////C:\\Users\\me/projects/"), "C:/Users/me/projects/")
1088
+ * eq( fn("file:///sys\\etc/bin\\deno.so"), "/sys/etc/bin/deno.so")
1089
+ * eq( fn("file://localhost/C:/Users/me/projects/"), "C:/Users/me/projects/")
1090
+ * eq(fn(new URL("file://localhost/sys/etc/bin/deno.so")), "/sys/etc/bin/deno.so")
1091
+ * eq( fn("http://localhost:8000/hello/world/"), "http://localhost:8000/hello/world/")
1092
+ * eq( fn("npm:react-jsx"), "npm:react-jsx")
1093
+ * eq( fn("jsr:@std/assert"), "jsr:@std/assert")
1094
+ * eq( fn("./src/mod.ts"), "./src/mod.ts")
1095
+ * eq( fn(""), "")
1096
+ * ```
1097
+ */
1098
+ export declare const ensureFileUrlIsLocalPath: (path: string | URL) => string;
1099
+ /** find the path `to_path`, relative to `from_path`.
1100
+ *
1101
+ * TODO: the claim below is wrong, because `joinSlash` cannot do "./" traversal correctly. for instance `joinSlash("a/b/c.txt", "./") === "a/b/c.txt/"`, but you'd expect it to be `"a/b/"` if we had correctly resolved the path.
1102
+ * which is why the output from this function will not work with `joinSlash`, but it will work with {@link resolveAsUrl} or `URL.parse` (when you provide `from_path` as the base path, and `from_path` is NOT a relative path, otherwise the `URL` constructor will fail).
1103
+ *
1104
+ * ~~if we call the result `rel_path`, then {@link joinSlash | joining} the `from_path` with `rel_path` and normalizing it should give you back `to_path`.~~
1105
+ *
1106
+ * note that both `from_path` and `to_path` must have a common root folder in their path strings.
1107
+ * for instance, if both paths begin with a relative segment `"./"`, then it will be assumed that both paths are referring to the same common root ancestral directory.
1108
+ * however, if for instance, `from_path` begins with a `"C:/"` segment, while `to_path` begins with either `"./"` or `"D:/"` or `http://` segment, then this function will fail,
1109
+ * as it will not be possible for it to navigate/transcend from one point of reference to a completely different point of reference.
1110
+ *
1111
+ * so, to be safe, wherever you are certain that both paths are of a certain common type:
1112
+ * before passing them here, you should either apply the {@link ensureStartDotSlash} function for relative paths, or apply the {@link ensureStartSlash} for absolute local paths,
1113
+ * or write a custom "ensure" function for your situation. (for example, you could write an "ensureHttp" function that ensures that your path begins with `"http"`).
1114
+ *
1115
+ * @throws `Error` an error will be thrown if there isn't any common ancestral directory between the two provided paths.
1116
+ *
1117
+ * @example
1118
+ * ```ts
1119
+ * import { assertEquals, assertThrows } from "jsr:@std/assert"
1120
+ *
1121
+ * // aliasing our functions for brevity
1122
+ * const eq = assertEquals, err = assertThrows, fn = relativePath
1123
+ *
1124
+ * eq(fn(
1125
+ * "././hello/world/a/b/c/d/g/../e.txt",
1126
+ * "././hello/world/a/b/x/y/w/../z/",
1127
+ * ), "../../x/y/z/")
1128
+ *
1129
+ * eq(fn(
1130
+ * "././hello/world/a/b/c/d/g/../e.txt",
1131
+ * "././hello/world/a/b/x/y/w/../z/e.md",
1132
+ * ), "../../x/y/z/e.md")
1133
+ *
1134
+ * eq(fn(
1135
+ * ".\\./hello\\world\\a/b\\c/d/g/../",
1136
+ * "././hello/world/a/b/x/y/w/../z/e.md",
1137
+ * ), "../../x/y/z/e.md")
1138
+ *
1139
+ * eq(fn(
1140
+ * "././hello/world/a/b/c/d/",
1141
+ * "././hello/world/a/b/x/y/w/../z/e.md",
1142
+ * ), "../../x/y/z/e.md")
1143
+ *
1144
+ * eq(fn(
1145
+ * "././hello/world/a/b/c/d/g/../",
1146
+ * "././hello/world/a/b/x/y/w/../z/e.md",
1147
+ * ), "../../x/y/z/e.md")
1148
+ *
1149
+ * eq(fn(
1150
+ * "././hello/world/a/b/c/d/",
1151
+ * "././hello/world/a/b/x/y/w/../z/",
1152
+ * ), "../../x/y/z/")
1153
+ *
1154
+ * eq(fn(
1155
+ * "./././e.txt",
1156
+ * "./e.md",
1157
+ * ), "./e.md")
1158
+ *
1159
+ * eq(fn(
1160
+ * "/e.txt",
1161
+ * "/e.md",
1162
+ * ), "./e.md")
1163
+ *
1164
+ * eq(fn(
1165
+ * "C:/e.txt",
1166
+ * "C:/e.md",
1167
+ * ), "./e.md")
1168
+ *
1169
+ * eq(fn(
1170
+ * "././hello/world/a/b/c/d/g/../e.txt",
1171
+ * "././hello/world/a/k/../b/q/../c/d/e.md",
1172
+ * ), "./e.md")
1173
+ *
1174
+ * eq(fn(
1175
+ * "./",
1176
+ * "./",
1177
+ * ), "./")
1178
+ *
1179
+ * eq(fn(
1180
+ * "/",
1181
+ * "/",
1182
+ * ), "./")
1183
+ *
1184
+ * // there is no common ancestral root between the two paths (since one is absolute, while the other is relative)
1185
+ * err(() => fn(
1186
+ * "/e.txt",
1187
+ * "./e.md",
1188
+ * ))
1189
+ *
1190
+ * // there is no common ancestral root between the two paths
1191
+ * err(() => fn(
1192
+ * "C:/e.txt",
1193
+ * "D:/e.md",
1194
+ * ))
1195
+ *
1196
+ * // there is no common ancestral root between the two paths
1197
+ * err(() => fn(
1198
+ * "http://e.txt",
1199
+ * "./e.md",
1200
+ * ))
1201
+ *
1202
+ * // there is no common ancestral root between the two paths
1203
+ * err(() => fn(
1204
+ * "file:///C:/e.txt",
1205
+ * "C:/e.md",
1206
+ * ))
1207
+ * ```
1208
+ */
1209
+ export declare const relativePath: (from_path: string, to_path: string) => string;
1210
+ /** joins multiple posix path segments into a single normalized path,
1211
+ * correctly handling files and directories differently when the `"./"` and `"../"` navigation commands are encountered.
1212
+ *
1213
+ * > [!note]
1214
+ * > the `joinPosixPaths` function differs from `joinSlash` in that it treats segments without a trailing slash as files by default.
1215
+ * > furthermore, `joinPosixPaths` is much more quicker to compute, as opposed to `joinSlash`, which uses some complex regex on each segment.
1216
+ * > the only reason you might realistically want to use `joinSlash` is when you desire an non-normalized output.
1217
+ *
1218
+ * @example
1219
+ * ```ts
1220
+ * import { assertEquals } from "jsr:@std/assert"
1221
+ *
1222
+ * // aliasing our functions for brevity
1223
+ * const eq = assertEquals, fn = joinPosixPaths
1224
+ *
1225
+ * eq(fn("a", "b", "c.zip"), "a/b/c.zip")
1226
+ * eq(fn("a", "b", "c/"), "a/b/c/")
1227
+ * eq(fn("a/", "b/", "c/"), "a/b/c/")
1228
+ * eq(fn("a", "b", "c.zip", "./"), "a/b/")
1229
+ * eq(fn("a", "b", "c/", "./"), "a/b/c/")
1230
+ * eq(fn("a", "b", "c", "../"), "a/")
1231
+ * eq(fn("a", "b", "c/d.txt", "./e.txt"), "a/b/c/e.txt")
1232
+ * eq(fn("a", "b", "c/d.txt", "../e.txt"), "a/b/e.txt")
1233
+ * eq(fn("a/b", "c/d.txt", "..", "e.txt"), "a/b/e.txt") // notice that you can use "." instead of "./"
1234
+ * eq(fn("a/", "b/", "c/", "../", "./","d.txt"), "a/b/d.txt")
1235
+ * eq(fn("a/b", "c/", "..", ".","d.txt"), "a/b/d.txt") // notice that you can use ".." instead of "../"
1236
+ * eq(fn("a/b", "c/", ".d.txt"), "a/b/c/.d.txt")
1237
+ * eq(fn("a/b", "c/", "..d.txt"), "a/b/c/..d.txt")
1238
+ * eq(fn("a/b", "c/", ".d"), "a/b/c/.d")
1239
+ * eq(fn("a/b", "c/", ".d."), "a/b/c/.d.")
1240
+ * eq(fn("a/b", "c/", "..d"), "a/b/c/..d")
1241
+ * eq(fn("a/b", "c/", "..d."), "a/b/c/..d.")
1242
+ * eq(fn("a/b", "c/", "..d.."), "a/b/c/..d..")
1243
+ * eq(fn("a/b", "c/", "..d.", "e.txt"), "a/b/c/..d./e.txt")
1244
+ * eq(fn("a/b", "c/", "..d..", "e.txt"), "a/b/c/..d../e.txt")
1245
+ * eq(fn("./a", "./b", "./c"), "./c")
1246
+ * eq(fn("./a", "/b", "/c"), "./a//b//c")
1247
+ * eq(fn("./a/", "/b/", "/c"), "./a//b//c")
1248
+ * eq(fn("/a", "b.zip", "./c.zip"), "/a/c.zip")
1249
+ * eq(fn("/a", "b.zip", "./c.zip/", "../d.txt"), "/a/d.txt")
1250
+ * eq(fn("/a", "b.zip/", "./c.txt"), "/a/b.zip/c.txt")
1251
+ * eq(fn("/a", "b.zip/", "./c.txt/", "../d.txt"), "/a/b.zip/d.txt")
1252
+ * eq(fn("file:", "//", "a/b/c", "./d"), "file:///a/b/d")
1253
+ * eq(fn("file:///", "a/b/c", "./d"), "file:///a/b/d")
1254
+ * ```
1255
+ */
1256
+ export declare const joinPosixPaths: (...segments: string[]) => string;
1257
+ /** joins multiple path segments into a single normalized posix path,
1258
+ * correctly handling files and directories differently when the `"./"` and `"../"` navigation commands are encountered.
1259
+ *
1260
+ * for lots of other (posix-only) test cases, see the doc comments of {@link joinPosixPaths}.
1261
+ *
1262
+ * @example
1263
+ * ```ts
1264
+ * import { assertEquals } from "jsr:@std/assert"
1265
+ *
1266
+ * // aliasing our functions for brevity
1267
+ * const eq = assertEquals, fn = joinPaths
1268
+ *
1269
+ * eq(fn("C:\\", "a", "b", "c.zip"), "C:/a/b/c.zip")
1270
+ * eq(fn("a", "b", "c.zip"), "a/b/c.zip")
1271
+ * eq(fn("/a\\b\\", "c/"), "/a/b/c/")
1272
+ * eq(fn("a", "b", "c.zip", "./"), "a/b/")
1273
+ * eq(fn("a", "b", "c.zip", "../"), "a/")
1274
+ * eq(fn("a", "b", "c.zip", "./d.txt"), "a/b/d.txt")
1275
+ * eq(fn("a", "b", "c.zip", "../d.txt"), "a/d.txt")
1276
+ * eq(fn("a/b/c/", "..", "./", "d.txt"), "a/b/d.txt")
1277
+ * eq(fn("a/b/c/", "../", ".", "d.txt"), "a/b/d.txt")
1278
+ * eq(fn("a/b/c", "../", "./", "d.txt"), "a/d.txt")
1279
+ * eq(fn("file:", "\\\\", "a/b/c", "./d"), "file:///a/b/d")
1280
+ * eq(fn("file://\\", "a/b/c", "./d/"), "file:///a/b/d/")
1281
+ * ```
1282
+ */
1283
+ export declare const joinPaths: (...segments: string[]) => string;
1284
+ /** this is a factory function for creating customizable posix path-resolving functions.
1285
+ * a path-resolving function is one that takes in a list of path-segments, and then computes the absolute normalized path of all the segments combined.
1286
+ *
1287
+ * since it is not possible for this submodule to know the context under which you are computing/resolving paths,
1288
+ * it becomes impossible to give a meaning to a list of path segmensts that begin with a relative path.
1289
+ * which is why you would need to feed this factory function with the (static or dynamic) location of your current working path (directory),
1290
+ * and it will spit out a path-resolver function that is tailored to your specific working-directory's path.
1291
+ *
1292
+ * > [!note]
1293
+ * > if you want to preserve the starting relative segments, (i.e. you don't want an absolute path),
1294
+ * > then you're looking for the {@link joinPosixPaths} (or {@link joinPaths}) function, not this one.
1295
+ *
1296
+ * an important detail to note is that whenever an absolute path segment is encountered, all segments prior to it are discarded
1297
+ * (i.e. not joined with a "/" separator, like the way {@link joinPaths} does).
1298
+ * this behavior is enforced to remain consistent with popular implementations of path-resolvers, like:
1299
+ * - python's pathlib [`Path.resolve`](https://docs.python.org/3/library/pathlib):
1300
+ * > _If a segment is an absolute path, all previous segments are ignored_
1301
+ * - deno-std's path [`resolve`](https://jsr.io/@std/path/doc/~/resolve), from [`jsr:@std/path`](https://jsr.io/@std/path)
1302
+ *
1303
+ * > [!caution]
1304
+ * > this path resolver function works best when only absolute and relative path segments are provided.
1305
+ * > when root (but not necessarily absolute) path segments are encountered, such as `/sys/bin`,
1306
+ * > our function will typically assume that it is referring to an absolute local-filesystem path `/sys/bin`.
1307
+ * >
1308
+ * > but as you may be aware, the "correct" interpretation of the root path depends on the context of the preceding absolute path segment.
1309
+ * > for example:
1310
+ * > - if the preceding absolute path segment was `C:/a/b/c/d.txt`, and the current path segment is `/sys/bin`,
1311
+ * > then our result will be `/sys/bin`, but the result in most implementations (including deno-std's path module) would be `C:/sys/bin`.
1312
+ * > - similarly, if the preceding absolute path segment was `http://test.com/a/b/c/d.txt`, and the current path segment is `/sys/bin`,
1313
+ * > then our result will be `/sys/bin`, but the "correct" url path resolution (via `new URL(...)`) should have been `http://test.com/sys.bin`.
1314
+ * >
1315
+ * > this is why, if you're dealing with ambiguous root paths that are not necessarily tied down to your posix-filesystem's root,
1316
+ * > you should use the {@link resolveAsUrl} function instead, as it is aware of most common types of base contexts/domains for path evaluation.
1317
+ * > but on the other hand, you will be unable to use your custom {@link absolute_segment_test_fn}, nor be able to resolve multiple segments all at oncce.
1318
+ * >
1319
+ * > TODO: contemplate if it would be a good idea to add a configuration interface to this factory function,
1320
+ * > where one will be able to set their custom join rule when a root path segment is discovered, in addition to containing the {@link absolute_segment_test_fn}.
1321
+ * > the signature of the root-join function would look like: `(abs_path_evaluated_up_till_now: string, current_root_path_segment: string) => string`.
1322
+ *
1323
+ * @example
1324
+ * ```ts
1325
+ * import { assertEquals } from "jsr:@std/assert"
1326
+ *
1327
+ * const
1328
+ * cwd = "/x/y/z",
1329
+ * getCwd = () => (cwd),
1330
+ * // we also define a custom absolute segment path tester function that will identify "file://" and "http://" segments as absolute path,
1331
+ * // in addition to the standard filesystem local path absoluteness tester `isAbsolutePath`.
1332
+ * custom_absolute_path_segment_tester = (segment: string) => {
1333
+ * if (isAbsolutePath(segment)) { return true }
1334
+ * if (segment.startsWith("file://")) { return true }
1335
+ * if (segment.startsWith("http://")) { return true }
1336
+ * return false
1337
+ * },
1338
+ * resolvePosixPath = resolvePosixPathFactory(getCwd, custom_absolute_path_segment_tester)
1339
+ *
1340
+ * // aliasing our functions for brevity
1341
+ * const eq = assertEquals, fn = resolvePosixPath
1342
+ *
1343
+ * // relative path resolution
1344
+ * eq(fn("a", "b", "c.zip"), "/x/y/z/a/b/c.zip")
1345
+ * eq(fn("./a", "b", "c/"), "/x/y/z/a/b/c/")
1346
+ * eq(fn("a/", "b/", "c/"), "/x/y/z/a/b/c/")
1347
+ * eq(fn("../a", "../b", "c/"), "/x/b/c/")
1348
+ * eq(fn("../a/", "../b", "c/"), "/x/y/b/c/")
1349
+ * eq(fn("a", "b", "c.zip", "./"), "/x/y/z/a/b/")
1350
+ * eq(fn("a", "b", "c/", "./"), "/x/y/z/a/b/c/")
1351
+ * eq(fn("a", "b", "c", "../"), "/x/y/z/a/")
1352
+ * eq(fn("a", "b", "c/d.txt", "./e.txt"), "/x/y/z/a/b/c/e.txt")
1353
+ * eq(fn("a", "b", "c/d.txt", "../e.txt"), "/x/y/z/a/b/e.txt")
1354
+ * eq(fn("a/b", "c/d.txt", "..", "e.txt"), "/x/y/z/a/b/e.txt") // notice that you can use "." instead of "./"
1355
+ * eq(fn("a/", "b/", "c/", "../", "./","d.txt"), "/x/y/z/a/b/d.txt")
1356
+ * eq(fn("a/b", "c/", "..", ".","d.txt"), "/x/y/z/a/b/d.txt") // notice that you can use ".." instead of "../"
1357
+ * eq(fn("a/b", "c/", ".d.txt"), "/x/y/z/a/b/c/.d.txt")
1358
+ * eq(fn("a/b", "c/", "..d.txt"), "/x/y/z/a/b/c/..d.txt")
1359
+ * eq(fn("a/b", "c/", ".d"), "/x/y/z/a/b/c/.d")
1360
+ * eq(fn("a/b", "c/", ".d."), "/x/y/z/a/b/c/.d.")
1361
+ * eq(fn("a/b", "c/", "..d"), "/x/y/z/a/b/c/..d")
1362
+ * eq(fn("a/b", "c/", "..d."), "/x/y/z/a/b/c/..d.")
1363
+ * eq(fn("a/b", "c/", "..d.."), "/x/y/z/a/b/c/..d..")
1364
+ * eq(fn("a/b", "c/", "..d.", "e.txt"), "/x/y/z/a/b/c/..d./e.txt")
1365
+ * eq(fn("a/b", "c/", "..d..", "e.txt"), "/x/y/z/a/b/c/..d../e.txt")
1366
+ * eq(fn("./a", "./b", "./c"), "/x/y/z/c")
1367
+ *
1368
+ * // pre-existing absolute path resolution
1369
+ * eq(fn("./a", "/b", "/c"), "/c") // both "/b" and "/c" are absolute paths, and so they purge all segments behind them.
1370
+ * eq(fn("./a/", "/b/", "./c"), "/b/c") // "/b/" is an absolute path, hence it negates all segments prior to it.
1371
+ * eq(fn("file:///", "a/b/c", "./d"), "file:///a/b/d") // the first "file:///" segment is an absolute path according to our `custom_absolute_path_segment_tester`
1372
+ * eq(fn("file:/", "a/b/c", "./d"), "/x/y/z/file:/a/b/d") // "file:/" is not considered as an absolute path by `custom_absolute_path_segment_tester`, thus it the cwd will be prepended to the final path
1373
+ * eq(fn("file:", "a/b/c", "./d"), "/x/y/z/file:/a/b/d") // same as before, but we're putting emphasis on the mandatory "/" separator that gets added after the "file:" segment
1374
+ * eq(fn("a/b/c", "http://d/e/f.txt"), "http://d/e/f.txt") // the "http://" segment is identified as an absolute path by our `custom_absolute_path_segment_tester`
1375
+ * ```
1376
+ */
1377
+ export declare const resolvePosixPathFactory: (absolute_current_dir: string | (() => string), absolute_segment_test_fn?: (segment: string) => boolean) => ((...segments: string[]) => string);
1378
+ /** this is a factory function for creating customizable path-resolving functions.
1379
+ *
1380
+ * {@inheritDoc resolvePosixPathFactory}
1381
+ *
1382
+ * @example
1383
+ * ```ts
1384
+ * import { assertEquals } from "jsr:@std/assert"
1385
+ *
1386
+ * const
1387
+ * cwd = "x:\\y\\z",
1388
+ * getCwd = () => (cwd),
1389
+ * // we also define a custom absolute segment path tester function that will identify "file://" and "http://" segments as absolute path,
1390
+ * // in addition to the standard filesystem local path absoluteness tester `isAbsolutePath`.
1391
+ * custom_absolute_path_segment_tester = (segment: string) => {
1392
+ * if (isAbsolutePath(segment)) { return true }
1393
+ * if (segment.startsWith("file://")) { return true }
1394
+ * if (segment.startsWith("http://")) { return true }
1395
+ * return false
1396
+ * },
1397
+ * resolvePosixPath = resolvePathFactory(getCwd, custom_absolute_path_segment_tester)
1398
+ *
1399
+ * // aliasing our functions for brevity
1400
+ * const eq = assertEquals, fn = resolvePosixPath
1401
+ *
1402
+ * // relative path resolution
1403
+ * eq(fn("a", "b", "c.zip"), "x:/y/z/a/b/c.zip")
1404
+ * eq(fn(".\\a", "b", "c\\"), "x:/y/z/a/b/c/")
1405
+ * eq(fn("a/", "b/", "c/"), "x:/y/z/a/b/c/")
1406
+ * eq(fn("../a", "../b", "c\\"), "x:/b/c/")
1407
+ * eq(fn("../a/", "../b", "c/"), "x:/y/b/c/")
1408
+ * eq(fn("a", "b", "c.zip", "./"), "x:/y/z/a/b/")
1409
+ *
1410
+ * // pre-existing absolute path resolution
1411
+ * eq(fn("./a", "/b", "c:/"), "c:/") // both "/b" and "c:/" are absolute paths, and so they purge all segments behind them.
1412
+ * eq(fn("./a/", "\\b/", "./c"), "/b/c") // "\\b/" is an absolute path, hence it negates all segments prior to it.
1413
+ * eq(fn("file:///", "a/b/c", "./d"), "file:///a/b/d") // the first "file:///" segment is an absolute path according to our `custom_absolute_path_segment_tester`
1414
+ * eq(fn("file:/", "a/b/c", "./d"), "x:/y/z/file:/a/b/d") // "file:/" is not considered as an absolute path by `custom_absolute_path_segment_tester`, thus it the cwd will be prepended to the final path
1415
+ * eq(fn("file:", "a/b\\c", ".\\d"), "x:/y/z/file:/a/b/d") // same as before, but we're putting emphasis on the mandatory "/" separator that gets added after the "file:" segment
1416
+ * eq(fn("a/b/c", "http://d/e/f.txt"), "http://d/e/f.txt") // the "http://" segment is identified as an absolute path by our `custom_absolute_path_segment_tester`
1417
+ * ```
1418
+ *
1419
+ * for lots of other (posix-only) test cases, see the doc comments of {@link resolvePosixPathFactory}.
1420
+ */
1421
+ export declare const resolvePathFactory: (absolute_current_dir: string | (() => string), absolute_segment_test_fn?: (segment: string) => boolean) => ((...segments: string[]) => string);
1422
+ /** convert a glob string to a regex object.
1423
+ *
1424
+ * TODO: purge the info below:
1425
+ * in this implementation, only the wildcards `"*"`, `"**"`, and the optional `"?"` is given meaning.
1426
+ * all else, including parenthesis, brackets, dots, and backslash, are escaped when being converted into a regex.
1427
+ *
1428
+ * TODO: test it
1429
+ * TODO: also implement a `isGlobPattern` function
1430
+ * TODO: make it so that the user can configure which features to turn on or off
1431
+ *
1432
+ * @beta
1433
+ */
1434
+ export declare const globPatternToRegex: (glob_pattern: string) => RegExp;
1435
+ export {};
1436
+ //# sourceMappingURL=pathman.d.ts.map