@gjsify/path 0.0.1 → 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.
@@ -0,0 +1,573 @@
1
+ import {
2
+ CHAR_DOT,
3
+ CHAR_BACKWARD_SLASH,
4
+ CHAR_COLON
5
+ } from "./constants.js";
6
+ import {
7
+ assertPath,
8
+ isPathSeparator,
9
+ isWindowsDeviceRoot,
10
+ normalizeString,
11
+ _format
12
+ } from "./util.js";
13
+ const sep = "\\";
14
+ const delimiter = ";";
15
+ function resolve(...pathSegments) {
16
+ let resolvedDevice = "";
17
+ let resolvedTail = "";
18
+ let resolvedAbsolute = false;
19
+ for (let i = pathSegments.length - 1; i >= -1; i--) {
20
+ let path;
21
+ if (i >= 0) {
22
+ path = pathSegments[i];
23
+ assertPath(path);
24
+ if (path.length === 0) continue;
25
+ } else if (resolvedDevice.length === 0) {
26
+ path = typeof globalThis.process?.cwd === "function" ? globalThis.process.cwd() : "/";
27
+ } else {
28
+ path = typeof globalThis.process?.cwd === "function" ? globalThis.process.cwd() : "/";
29
+ }
30
+ const len = path.length;
31
+ let rootEnd = 0;
32
+ let device = "";
33
+ let isAbsolutePath = false;
34
+ const code = path.charCodeAt(0);
35
+ if (len > 1) {
36
+ if (isPathSeparator(code)) {
37
+ isAbsolutePath = true;
38
+ if (isPathSeparator(path.charCodeAt(1))) {
39
+ let j = 2;
40
+ let last = j;
41
+ for (; j < len; ++j) {
42
+ if (isPathSeparator(path.charCodeAt(j))) break;
43
+ }
44
+ if (j < len && j !== last) {
45
+ const firstPart = path.slice(last, j);
46
+ last = j;
47
+ for (; j < len; ++j) {
48
+ if (!isPathSeparator(path.charCodeAt(j))) break;
49
+ }
50
+ if (j < len && j !== last) {
51
+ last = j;
52
+ for (; j < len; ++j) {
53
+ if (isPathSeparator(path.charCodeAt(j))) break;
54
+ }
55
+ if (j === len) {
56
+ device = `\\\\${firstPart}\\${path.slice(last)}`;
57
+ rootEnd = j;
58
+ } else if (j !== last) {
59
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
60
+ rootEnd = j;
61
+ }
62
+ }
63
+ }
64
+ } else {
65
+ rootEnd = 1;
66
+ }
67
+ } else if (isWindowsDeviceRoot(code)) {
68
+ if (path.charCodeAt(1) === CHAR_COLON) {
69
+ device = path.slice(0, 2);
70
+ rootEnd = 2;
71
+ if (len > 2) {
72
+ if (isPathSeparator(path.charCodeAt(2))) {
73
+ isAbsolutePath = true;
74
+ rootEnd = 3;
75
+ }
76
+ }
77
+ }
78
+ }
79
+ } else if (isPathSeparator(code)) {
80
+ rootEnd = 1;
81
+ isAbsolutePath = true;
82
+ }
83
+ if (device.length > 0 && resolvedDevice.length > 0 && device.toLowerCase() !== resolvedDevice.toLowerCase()) {
84
+ continue;
85
+ }
86
+ if (resolvedDevice.length === 0 && device.length > 0) {
87
+ resolvedDevice = device;
88
+ }
89
+ if (!resolvedAbsolute) {
90
+ resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
91
+ resolvedAbsolute = isAbsolutePath;
92
+ }
93
+ if (resolvedDevice.length > 0 && resolvedAbsolute) {
94
+ break;
95
+ }
96
+ }
97
+ resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, "\\", isPathSeparator);
98
+ return resolvedDevice + (resolvedAbsolute ? "\\" : "") + resolvedTail || ".";
99
+ }
100
+ function normalize(path) {
101
+ assertPath(path);
102
+ const len = path.length;
103
+ if (len === 0) return ".";
104
+ let rootEnd = 0;
105
+ let device;
106
+ let isAbsolutePath = false;
107
+ const code = path.charCodeAt(0);
108
+ if (len > 1) {
109
+ if (isPathSeparator(code)) {
110
+ isAbsolutePath = true;
111
+ if (isPathSeparator(path.charCodeAt(1))) {
112
+ let j = 2;
113
+ let last = j;
114
+ for (; j < len; ++j) {
115
+ if (isPathSeparator(path.charCodeAt(j))) break;
116
+ }
117
+ if (j < len && j !== last) {
118
+ const firstPart = path.slice(last, j);
119
+ last = j;
120
+ for (; j < len; ++j) {
121
+ if (!isPathSeparator(path.charCodeAt(j))) break;
122
+ }
123
+ if (j < len && j !== last) {
124
+ last = j;
125
+ for (; j < len; ++j) {
126
+ if (isPathSeparator(path.charCodeAt(j))) break;
127
+ }
128
+ if (j === len) {
129
+ return `\\\\${firstPart}\\${path.slice(last)}\\`;
130
+ } else if (j !== last) {
131
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
132
+ rootEnd = j;
133
+ }
134
+ }
135
+ }
136
+ } else {
137
+ rootEnd = 1;
138
+ }
139
+ } else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
140
+ device = path.slice(0, 2);
141
+ rootEnd = 2;
142
+ if (len > 2 && isPathSeparator(path.charCodeAt(2))) {
143
+ isAbsolutePath = true;
144
+ rootEnd = 3;
145
+ }
146
+ }
147
+ } else if (isPathSeparator(code)) {
148
+ return "\\";
149
+ }
150
+ let tail;
151
+ if (rootEnd < len) {
152
+ tail = normalizeString(path.slice(rootEnd), !isAbsolutePath, "\\", isPathSeparator);
153
+ } else {
154
+ tail = "";
155
+ }
156
+ if (tail.length === 0 && !isAbsolutePath) tail = ".";
157
+ if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) {
158
+ tail += "\\";
159
+ }
160
+ if (device === void 0) {
161
+ if (isAbsolutePath) {
162
+ if (tail.length > 0) return `\\${tail}`;
163
+ return "\\";
164
+ }
165
+ if (tail.length > 0) return tail;
166
+ return "";
167
+ }
168
+ if (isAbsolutePath) {
169
+ if (tail.length > 0) return `${device}\\${tail}`;
170
+ return `${device}\\`;
171
+ }
172
+ if (tail.length > 0) return device + tail;
173
+ return device;
174
+ }
175
+ function isAbsolute(path) {
176
+ assertPath(path);
177
+ const len = path.length;
178
+ if (len === 0) return false;
179
+ const code = path.charCodeAt(0);
180
+ if (isPathSeparator(code)) return true;
181
+ if (isWindowsDeviceRoot(code) && len > 2 && path.charCodeAt(1) === CHAR_COLON) {
182
+ if (isPathSeparator(path.charCodeAt(2))) return true;
183
+ }
184
+ return false;
185
+ }
186
+ function join(...paths) {
187
+ if (paths.length === 0) return ".";
188
+ let joined;
189
+ let firstPart;
190
+ for (let i = 0; i < paths.length; ++i) {
191
+ const arg = paths[i];
192
+ assertPath(arg);
193
+ if (arg.length > 0) {
194
+ if (joined === void 0) {
195
+ joined = firstPart = arg;
196
+ } else {
197
+ joined += `\\${arg}`;
198
+ }
199
+ }
200
+ }
201
+ if (joined === void 0) return ".";
202
+ let needsReplace = true;
203
+ let slashCount = 0;
204
+ if (isPathSeparator(firstPart.charCodeAt(0))) {
205
+ ++slashCount;
206
+ const firstLen = firstPart.length;
207
+ if (firstLen > 1) {
208
+ if (isPathSeparator(firstPart.charCodeAt(1))) {
209
+ ++slashCount;
210
+ if (firstLen > 2) {
211
+ if (isPathSeparator(firstPart.charCodeAt(2))) ++slashCount;
212
+ else needsReplace = false;
213
+ }
214
+ }
215
+ }
216
+ }
217
+ if (needsReplace) {
218
+ for (; slashCount < joined.length; ++slashCount) {
219
+ if (!isPathSeparator(joined.charCodeAt(slashCount))) break;
220
+ }
221
+ if (slashCount >= 2) joined = `\\${joined.slice(slashCount)}`;
222
+ }
223
+ return normalize(joined);
224
+ }
225
+ function relative(from, to) {
226
+ assertPath(from);
227
+ assertPath(to);
228
+ if (from === to) return "";
229
+ const fromOrig = resolve(from);
230
+ const toOrig = resolve(to);
231
+ if (fromOrig === toOrig) return "";
232
+ from = fromOrig.toLowerCase();
233
+ to = toOrig.toLowerCase();
234
+ if (from === to) return "";
235
+ let fromStart = 0;
236
+ for (; fromStart < from.length; ++fromStart) {
237
+ if (from.charCodeAt(fromStart) !== CHAR_BACKWARD_SLASH) break;
238
+ }
239
+ let fromEnd = from.length;
240
+ for (; fromEnd - 1 > fromStart; --fromEnd) {
241
+ if (from.charCodeAt(fromEnd - 1) !== CHAR_BACKWARD_SLASH) break;
242
+ }
243
+ const fromLen = fromEnd - fromStart;
244
+ let toStart = 0;
245
+ for (; toStart < to.length; ++toStart) {
246
+ if (to.charCodeAt(toStart) !== CHAR_BACKWARD_SLASH) break;
247
+ }
248
+ let toEnd = to.length;
249
+ for (; toEnd - 1 > toStart; --toEnd) {
250
+ if (to.charCodeAt(toEnd - 1) !== CHAR_BACKWARD_SLASH) break;
251
+ }
252
+ const toLen = toEnd - toStart;
253
+ const length = fromLen < toLen ? fromLen : toLen;
254
+ let lastCommonSep = -1;
255
+ let i = 0;
256
+ for (; i <= length; ++i) {
257
+ if (i === length) {
258
+ if (toLen > length) {
259
+ if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
260
+ return toOrig.slice(toStart + i + 1);
261
+ } else if (i === 2) {
262
+ return toOrig.slice(toStart + i);
263
+ }
264
+ }
265
+ if (fromLen > length) {
266
+ if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
267
+ lastCommonSep = i;
268
+ } else if (i === 2) {
269
+ lastCommonSep = 3;
270
+ }
271
+ }
272
+ break;
273
+ }
274
+ const fromCode = from.charCodeAt(fromStart + i);
275
+ const toCode = to.charCodeAt(toStart + i);
276
+ if (fromCode !== toCode) break;
277
+ if (fromCode === CHAR_BACKWARD_SLASH) lastCommonSep = i;
278
+ }
279
+ if (i !== length && lastCommonSep === -1) {
280
+ return toOrig;
281
+ }
282
+ let out = "";
283
+ if (lastCommonSep === -1) lastCommonSep = 0;
284
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
285
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
286
+ if (out.length === 0) out += "..";
287
+ else out += "\\..";
288
+ }
289
+ }
290
+ if (out.length > 0) {
291
+ return out + toOrig.slice(toStart + lastCommonSep, toEnd);
292
+ }
293
+ toStart += lastCommonSep;
294
+ if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) ++toStart;
295
+ return toOrig.slice(toStart, toEnd);
296
+ }
297
+ function toNamespacedPath(path) {
298
+ if (typeof path !== "string") return path;
299
+ if (path.length === 0) return "";
300
+ const resolvedPath = resolve(path);
301
+ if (resolvedPath.length >= 3) {
302
+ if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
303
+ if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
304
+ const code = resolvedPath.charCodeAt(2);
305
+ if (code !== 63 && code !== CHAR_DOT) {
306
+ return `\\\\?\\UNC\\${resolvedPath.slice(2)}`;
307
+ }
308
+ }
309
+ } else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0)) && resolvedPath.charCodeAt(1) === CHAR_COLON && resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
310
+ return `\\\\?\\${resolvedPath}`;
311
+ }
312
+ }
313
+ return path;
314
+ }
315
+ function dirname(path) {
316
+ assertPath(path);
317
+ const len = path.length;
318
+ if (len === 0) return ".";
319
+ let rootEnd = -1;
320
+ let end = -1;
321
+ let matchedSlash = true;
322
+ let offset = 0;
323
+ const code = path.charCodeAt(0);
324
+ if (len > 1) {
325
+ if (isPathSeparator(code)) {
326
+ rootEnd = offset = 1;
327
+ if (isPathSeparator(path.charCodeAt(1))) {
328
+ let j = 2;
329
+ let last = j;
330
+ for (; j < len; ++j) {
331
+ if (isPathSeparator(path.charCodeAt(j))) break;
332
+ }
333
+ if (j < len && j !== last) {
334
+ last = j;
335
+ for (; j < len; ++j) {
336
+ if (!isPathSeparator(path.charCodeAt(j))) break;
337
+ }
338
+ if (j < len && j !== last) {
339
+ last = j;
340
+ for (; j < len; ++j) {
341
+ if (isPathSeparator(path.charCodeAt(j))) break;
342
+ }
343
+ if (j === len) return path;
344
+ if (j !== last) rootEnd = offset = j + 1;
345
+ }
346
+ }
347
+ }
348
+ } else if (isWindowsDeviceRoot(code)) {
349
+ if (path.charCodeAt(1) === CHAR_COLON) {
350
+ rootEnd = offset = 2;
351
+ if (len > 2) {
352
+ if (isPathSeparator(path.charCodeAt(2))) rootEnd = offset = 3;
353
+ }
354
+ }
355
+ }
356
+ } else if (isPathSeparator(code)) {
357
+ return path;
358
+ }
359
+ for (let i = len - 1; i >= offset; --i) {
360
+ if (isPathSeparator(path.charCodeAt(i))) {
361
+ if (!matchedSlash) {
362
+ end = i;
363
+ break;
364
+ }
365
+ } else {
366
+ matchedSlash = false;
367
+ }
368
+ }
369
+ if (end === -1) {
370
+ if (rootEnd === -1) return ".";
371
+ end = rootEnd;
372
+ }
373
+ return path.slice(0, end);
374
+ }
375
+ function basename(path, ext) {
376
+ if (ext !== void 0) assertPath(ext);
377
+ assertPath(path);
378
+ let start = 0;
379
+ let end = -1;
380
+ let matchedSlash = true;
381
+ if (path.length >= 2) {
382
+ if (isWindowsDeviceRoot(path.charCodeAt(0)) && path.charCodeAt(1) === CHAR_COLON) {
383
+ start = 2;
384
+ }
385
+ }
386
+ if (ext !== void 0 && ext.length > 0 && ext.length <= path.length) {
387
+ if (ext.length === path.length && ext === path) return "";
388
+ let extIdx = ext.length - 1;
389
+ let firstNonSlashEnd = -1;
390
+ for (let i = path.length - 1; i >= start; --i) {
391
+ const code = path.charCodeAt(i);
392
+ if (isPathSeparator(code)) {
393
+ if (!matchedSlash) {
394
+ start = i + 1;
395
+ break;
396
+ }
397
+ } else {
398
+ if (firstNonSlashEnd === -1) {
399
+ matchedSlash = false;
400
+ firstNonSlashEnd = i + 1;
401
+ }
402
+ if (extIdx >= 0) {
403
+ if (code === ext.charCodeAt(extIdx)) {
404
+ if (--extIdx === -1) end = i;
405
+ } else {
406
+ extIdx = -1;
407
+ end = firstNonSlashEnd;
408
+ }
409
+ }
410
+ }
411
+ }
412
+ if (start === end) end = firstNonSlashEnd;
413
+ else if (end === -1) end = path.length;
414
+ return path.slice(start, end);
415
+ } else {
416
+ for (let i = path.length - 1; i >= start; --i) {
417
+ if (isPathSeparator(path.charCodeAt(i))) {
418
+ if (!matchedSlash) {
419
+ start = i + 1;
420
+ break;
421
+ }
422
+ } else if (end === -1) {
423
+ matchedSlash = false;
424
+ end = i + 1;
425
+ }
426
+ }
427
+ if (end === -1) return "";
428
+ return path.slice(start, end);
429
+ }
430
+ }
431
+ function extname(path) {
432
+ assertPath(path);
433
+ let start = 0;
434
+ let startDot = -1;
435
+ let startPart = 0;
436
+ let end = -1;
437
+ let matchedSlash = true;
438
+ let preDotState = 0;
439
+ if (path.length >= 2 && path.charCodeAt(1) === CHAR_COLON && isWindowsDeviceRoot(path.charCodeAt(0))) {
440
+ start = startPart = 2;
441
+ }
442
+ for (let i = path.length - 1; i >= start; --i) {
443
+ const code = path.charCodeAt(i);
444
+ if (isPathSeparator(code)) {
445
+ if (!matchedSlash) {
446
+ startPart = i + 1;
447
+ break;
448
+ }
449
+ continue;
450
+ }
451
+ if (end === -1) {
452
+ matchedSlash = false;
453
+ end = i + 1;
454
+ }
455
+ if (code === CHAR_DOT) {
456
+ if (startDot === -1) startDot = i;
457
+ else if (preDotState !== 1) preDotState = 1;
458
+ } else if (startDot !== -1) {
459
+ preDotState = -1;
460
+ }
461
+ }
462
+ if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
463
+ return "";
464
+ }
465
+ return path.slice(startDot, end);
466
+ }
467
+ function format(pathObject) {
468
+ if (pathObject === null || typeof pathObject !== "object") {
469
+ throw new TypeError(
470
+ 'The "pathObject" argument must be of type Object. Received type ' + typeof pathObject
471
+ );
472
+ }
473
+ return _format("\\", pathObject);
474
+ }
475
+ function parse(path) {
476
+ assertPath(path);
477
+ const ret = { root: "", dir: "", base: "", ext: "", name: "" };
478
+ if (path.length === 0) return ret;
479
+ const len = path.length;
480
+ let rootEnd = 0;
481
+ let code = path.charCodeAt(0);
482
+ if (len > 1) {
483
+ if (isPathSeparator(code)) {
484
+ rootEnd = 1;
485
+ if (isPathSeparator(path.charCodeAt(1))) {
486
+ let j = 2;
487
+ let last = j;
488
+ for (; j < len; ++j) {
489
+ if (isPathSeparator(path.charCodeAt(j))) break;
490
+ }
491
+ if (j < len && j !== last) {
492
+ last = j;
493
+ for (; j < len; ++j) {
494
+ if (!isPathSeparator(path.charCodeAt(j))) break;
495
+ }
496
+ if (j < len && j !== last) {
497
+ last = j;
498
+ for (; j < len; ++j) {
499
+ if (isPathSeparator(path.charCodeAt(j))) break;
500
+ }
501
+ if (j === len) rootEnd = j;
502
+ else if (j !== last) rootEnd = j + 1;
503
+ }
504
+ }
505
+ }
506
+ } else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
507
+ rootEnd = 2;
508
+ if (len > 2 && isPathSeparator(path.charCodeAt(2))) {
509
+ rootEnd = 3;
510
+ }
511
+ }
512
+ } else if (isPathSeparator(code)) {
513
+ ret.root = ret.dir = path;
514
+ return ret;
515
+ }
516
+ if (rootEnd > 0) ret.root = path.slice(0, rootEnd);
517
+ let startDot = -1;
518
+ let startPart = rootEnd;
519
+ let end = -1;
520
+ let matchedSlash = true;
521
+ let i = path.length - 1;
522
+ let preDotState = 0;
523
+ for (; i >= rootEnd; --i) {
524
+ code = path.charCodeAt(i);
525
+ if (isPathSeparator(code)) {
526
+ if (!matchedSlash) {
527
+ startPart = i + 1;
528
+ break;
529
+ }
530
+ continue;
531
+ }
532
+ if (end === -1) {
533
+ matchedSlash = false;
534
+ end = i + 1;
535
+ }
536
+ if (code === CHAR_DOT) {
537
+ if (startDot === -1) startDot = i;
538
+ else if (preDotState !== 1) preDotState = 1;
539
+ } else if (startDot !== -1) {
540
+ preDotState = -1;
541
+ }
542
+ }
543
+ if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
544
+ if (end !== -1) {
545
+ ret.base = ret.name = path.slice(startPart, end);
546
+ }
547
+ } else {
548
+ ret.name = path.slice(startPart, startDot);
549
+ ret.base = path.slice(startPart, end);
550
+ ret.ext = path.slice(startDot, end);
551
+ }
552
+ if (startPart > 0 && startPart !== rootEnd) {
553
+ ret.dir = path.slice(0, startPart - 1);
554
+ } else {
555
+ ret.dir = ret.root;
556
+ }
557
+ return ret;
558
+ }
559
+ export {
560
+ basename,
561
+ delimiter,
562
+ dirname,
563
+ extname,
564
+ format,
565
+ isAbsolute,
566
+ join,
567
+ normalize,
568
+ parse,
569
+ relative,
570
+ resolve,
571
+ sep,
572
+ toNamespacedPath
573
+ };
@@ -0,0 +1,9 @@
1
+ export declare const CHAR_DOT = 46;
2
+ export declare const CHAR_FORWARD_SLASH = 47;
3
+ export declare const CHAR_BACKWARD_SLASH = 92;
4
+ export declare const CHAR_COLON = 58;
5
+ export declare const CHAR_QUESTION_MARK = 63;
6
+ export declare const CHAR_LOWERCASE_A = 97;
7
+ export declare const CHAR_LOWERCASE_Z = 122;
8
+ export declare const CHAR_UPPERCASE_A = 65;
9
+ export declare const CHAR_UPPERCASE_Z = 90;
@@ -0,0 +1,23 @@
1
+ import * as posix from './posix.js';
2
+ import * as win32 from './win32.js';
3
+ export type { ParsedPath, FormatInputPathObject } from './posix.js';
4
+ export declare const resolve: typeof posix.resolve, normalize: typeof posix.normalize, isAbsolute: typeof posix.isAbsolute, join: typeof posix.join, relative: typeof posix.relative, toNamespacedPath: typeof posix.toNamespacedPath, dirname: typeof posix.dirname, basename: typeof posix.basename, extname: typeof posix.extname, format: typeof posix.format, parse: typeof posix.parse, sep: string, delimiter: string;
5
+ export { posix, win32 };
6
+ declare const _default: {
7
+ resolve: typeof posix.resolve;
8
+ normalize: typeof posix.normalize;
9
+ isAbsolute: typeof posix.isAbsolute;
10
+ join: typeof posix.join;
11
+ relative: typeof posix.relative;
12
+ toNamespacedPath: typeof posix.toNamespacedPath;
13
+ dirname: typeof posix.dirname;
14
+ basename: typeof posix.basename;
15
+ extname: typeof posix.extname;
16
+ format: typeof posix.format;
17
+ parse: typeof posix.parse;
18
+ sep: string;
19
+ delimiter: string;
20
+ posix: typeof posix;
21
+ win32: typeof win32;
22
+ };
23
+ export default _default;
@@ -0,0 +1,21 @@
1
+ export interface ParsedPath {
2
+ root: string;
3
+ dir: string;
4
+ base: string;
5
+ ext: string;
6
+ name: string;
7
+ }
8
+ export type FormatInputPathObject = Partial<ParsedPath>;
9
+ export declare const sep = "/";
10
+ export declare const delimiter = ":";
11
+ export declare function resolve(...pathSegments: string[]): string;
12
+ export declare function normalize(path: string): string;
13
+ export declare function isAbsolute(path: string): boolean;
14
+ export declare function join(...paths: string[]): string;
15
+ export declare function relative(from: string, to: string): string;
16
+ export declare function toNamespacedPath(path: string): string;
17
+ export declare function dirname(path: string): string;
18
+ export declare function basename(path: string, ext?: string): string;
19
+ export declare function extname(path: string): string;
20
+ export declare function format(pathObject: FormatInputPathObject): string;
21
+ export declare function parse(path: string): ParsedPath;
@@ -0,0 +1,12 @@
1
+ export declare function assertPath(path: unknown): asserts path is string;
2
+ export declare function isPosixPathSeparator(code: number): boolean;
3
+ export declare function isPathSeparator(code: number): boolean;
4
+ export declare function isWindowsDeviceRoot(code: number): boolean;
5
+ /**
6
+ * Resolves `.` and `..` segments in a path string.
7
+ */
8
+ export declare function normalizeString(path: string, allowAboveRoot: boolean, separator: string, isPathSep: (code: number) => boolean): string;
9
+ /**
10
+ * Format a parsed path object into a path string.
11
+ */
12
+ export declare function _format(sep: string, pathObject: Record<string, any>): string;
@@ -0,0 +1,21 @@
1
+ export interface ParsedPath {
2
+ root: string;
3
+ dir: string;
4
+ base: string;
5
+ ext: string;
6
+ name: string;
7
+ }
8
+ export type FormatInputPathObject = Partial<ParsedPath>;
9
+ export declare const sep = "\\";
10
+ export declare const delimiter = ";";
11
+ export declare function resolve(...pathSegments: string[]): string;
12
+ export declare function normalize(path: string): string;
13
+ export declare function isAbsolute(path: string): boolean;
14
+ export declare function join(...paths: string[]): string;
15
+ export declare function relative(from: string, to: string): string;
16
+ export declare function toNamespacedPath(path: string): string;
17
+ export declare function dirname(path: string): string;
18
+ export declare function basename(path: string, ext?: string): string;
19
+ export declare function extname(path: string): string;
20
+ export declare function format(pathObject: FormatInputPathObject): string;
21
+ export declare function parse(path: string): ParsedPath;