@mangos/filepath 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,7 +37,7 @@ _Note: `\` needs to be escaped when using it in js code._
37
37
  ```javascript
38
38
  // node resolve
39
39
  path.resolve('//?/UNC/Server/share', '../../../txt');
40
- // -> ''\\\\?\\txt'' mangled unc loot
40
+ // -> '\\\\?\\txt' mangled unc loot
41
41
 
42
42
  // this library
43
43
  filePath.resolve('//?/UNC/Server/share', '../../../txt').toString();
@@ -61,6 +61,12 @@ There are 4 exported functions:
61
61
  import { allPath, firstPath, resolve, resolvePathObject } from '@mangos/filepath';
62
62
  ```
63
63
 
64
+ There are 2 exported classes:
65
+
66
+ ```typescript
67
+ import { ParsedPath, ParsedPathError } from '@mangos/filepath';
68
+ ```
69
+
64
70
  Most of the time you will be using <a href="#fn-resolve"><code>resolve</code></a>, <a href="#fn-first-path"><code>firstPath</code></a>.
65
71
 
66
72
  <h3 id="infer-path-options">Type <code>InferPathOptions</code></h3>
@@ -96,10 +102,10 @@ An instance of `ParsedPath` has the following fields/members
96
102
 
97
103
  - members:
98
104
  - <code>toString(): <i>string</i></code>: return the original path string
99
- - <code>isRelative(): <i>boolean</i></codes>: is the a path a relative one?
105
+ - <code>isRelative(): <i>boolean</i></code>: is the a path a relative one?
100
106
  - fields:
101
107
  - <code>type: <i>string</i></code>: one of the value `devicePath`, `unc`, `dos`, `posix`.
102
- - <code>path: <i>Token[]</i></code>: the path tokenized (see source).
108
+ - <code>path: <i>FileToken[]</i></code>: the path tokenized (see source).
103
109
 
104
110
  <h3 id="parsed-path-error"><code>ParsedPathError</code> object</h3>
105
111
 
@@ -109,7 +115,7 @@ If a path has illigal characters or is invalid the result of a tokenization will
109
115
  - <code>toString(): <i>string</i></code>: algamation of all errors found during parsing.
110
116
  - attributes:
111
117
  - <code>type: <i>string</i></code>: one of the values `devicePath`, `unc`, `dos`, `posix`.
112
- - <code>path: <i>Token[]</i></code>: the path tokenized.
118
+ - <code>path: <i>FileToken[]</i></code>: the path tokenized.
113
119
 
114
120
 
115
121
  <h3 id="path-type-order-of-evaluation">Path type order of evaluation</h4>
@@ -179,7 +185,7 @@ function firstPath(path = '', options: InferPathOptions = {}): ParsedPath | Pars
179
185
  <h4 id="fn-resolve-path-object">function: <code>resolvePathObject</code></h4>
180
186
 
181
187
  ```typescript
182
- function resolvePathObject(from: ParsedPath, ...toFragments: string[]): ParsedPath | ParsedPathError;
188
+ function resolvePathObject(from: ParsedPath, ...toFragments: string[]): ParsedPath;
183
189
  ```
184
190
 
185
191
  <h5 id="fn-resolve-path-object-arguments">Arguments:</h5>
@@ -190,16 +196,16 @@ function resolvePathObject(from: ParsedPath, ...toFragments: string[]): ParsedPa
190
196
  <h5 id="fn-resolve-path-object-return">Return:</h5>
191
197
 
192
198
  - <a href="#parsed-path"><code>ParsedPath</code></a>: In case of successfull resolve.
193
- - <a href="#parsed-path-error"><code>ParsedPathError</code></a>: In case of legal structure but illegal characters in the `from` or `toFragments`.
194
199
 
195
200
  <h5 id="fn-resolve-path-object-throws">throws:</h5>
196
201
 
197
- If <code>from</code> is a <a href="#parsed-path-error"><code>ParsedPathError</code></a> an `Error` will be thrown.
202
+ - If <code>from</code> is a <a href="#parsed-path-error"><code>ParsedPathError</code></a> an `Error` will be thrown.
203
+ - If any of the `toFragments` is an invalid path an Error will be thrown.
198
204
 
199
205
  <h4 id="fn-resolve">function: <code>resolve</code></h4>
200
206
 
201
207
  ```typescript
202
- function resolve(fromStr: string, ...toFragments: string[]): ParsedPath | ParsedPathError;
208
+ function resolve(fromStr: string, ...toFragments: string[]): ParsedPath;
203
209
  ```
204
210
 
205
211
  <h5 id="fn-resolve-arguments">Arguments:</h5>
@@ -210,11 +216,10 @@ function resolve(fromStr: string, ...toFragments: string[]): ParsedPath | Parsed
210
216
  <h5 id="fn-resolve-return">Return:</h5>
211
217
 
212
218
  - <a href="#parsed-path"><code>ParsedPath</code></a>: In case of successfull resolve.
213
- - <a href="#parsed-path-error"><code>ParsedPathError</code></a>: In case of legal structure but illegal characters in the `from` or `toFragments`.
214
219
 
215
220
  <h5 id="fn-resolve-throws">throws:</h5>
216
221
 
217
- If <code>fromStr</code> is a <a href="#parsed-path-error"><code>ParsedPathError</code></a> an `Error` will be thrown.
222
+ If <code>fromStr</code> is invalid a <a href="#parsed-path-error"><code>ParsedPathError</code></a> an `Error` will be thrown.
218
223
 
219
224
  <h2>License</h2>
220
225
 
@@ -1,7 +1,7 @@
1
1
  import type { FileSystem, ParsedPathDTO } from './parser.js';
2
- import type { Token } from './Token.js';
2
+ import type { PathToken } from './Token.js';
3
3
  export declare class ParsedPath {
4
- readonly path: Token[];
4
+ readonly path: PathToken[];
5
5
  readonly type: FileSystem;
6
6
  constructor(parsed: ParsedPathDTO);
7
7
  toString(): string;
@@ -1,8 +1,8 @@
1
- import type { Token } from 'Token.js';
1
+ import type { PathToken } from 'Token.js';
2
2
  import type { FileSystem, ParsedPathDTO } from './parser.js';
3
3
  export declare class ParsedPathError {
4
4
  private readonly parsed;
5
- readonly path: Token[];
5
+ readonly path: PathToken[];
6
6
  readonly type: FileSystem;
7
7
  constructor(parsed: ParsedPathDTO);
8
8
  toString(): string;
package/dist/Token.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- import type { TokenValueType } from './types/TokenValueType.js';
2
- export declare class Token {
3
- readonly token: TokenValueType;
1
+ import type { PathTokenValueType } from './types/TokenValueType.js';
2
+ export declare class PathToken {
3
+ readonly token: PathTokenValueType;
4
4
  readonly value: string;
5
5
  readonly start: number;
6
6
  readonly end: number;
7
7
  static from(o: {
8
- token: TokenValueType;
8
+ token: PathTokenValueType;
9
9
  value: string;
10
10
  start: number;
11
11
  end: number;
12
12
  error?: string;
13
- }): Token;
13
+ }): PathToken;
14
14
  readonly error?: string;
15
- constructor(token: TokenValueType, value: string, start: number, end: number, error?: string);
15
+ constructor(token: PathTokenValueType, value: string, start: number, end: number, error?: string);
16
16
  isRoot(): boolean;
17
- equals(ot: Token): boolean;
17
+ equals(ot: PathToken): boolean;
18
18
  }
package/dist/Token.js CHANGED
@@ -1,5 +1,5 @@
1
- import { TokenEnum } from "./constants.js";
2
- class Token {
1
+ import { PathTokenEnum } from "./constants.js";
2
+ class PathToken {
3
3
  constructor(token, value, start, end, error) {
4
4
  this.token = token;
5
5
  this.value = value;
@@ -10,16 +10,16 @@ class Token {
10
10
  }
11
11
  }
12
12
  static from(o) {
13
- return new Token(o.token, o.value, o.start, o.end, o.error);
13
+ return new PathToken(o.token, o.value, o.start, o.end, o.error);
14
14
  }
15
15
  error;
16
16
  isRoot() {
17
- return this.token === TokenEnum.ROOT;
17
+ return this.token === PathTokenEnum.ROOT;
18
18
  }
19
19
  equals(ot) {
20
- return ot.token === this.token && ot.value === this.value && ot.start === this.start && ot.end === this.end && ot.error === this.error;
20
+ return ot.token === this.token && ot.value === this.value && ot.error === this.error;
21
21
  }
22
22
  }
23
23
  export {
24
- Token
24
+ PathToken
25
25
  };
@@ -1,4 +1,4 @@
1
- import { Token } from '../Token.js';
1
+ import { PathToken } from '../Token.js';
2
2
  type RegExporderdMapDDP = {
3
3
  ddpwithUNC: RegExp;
4
4
  ddpwithVolumeUUID: RegExp;
@@ -6,5 +6,5 @@ type RegExporderdMapDDP = {
6
6
  unc?: RegExp;
7
7
  };
8
8
  export declare const regExpOrderedMapDDP: RegExporderdMapDDP;
9
- export declare function ddpAbsorber(str?: string, start?: number, end?: number): Generator<Token, undefined, undefined>;
9
+ export declare function ddpAbsorber(str?: string, start?: number, end?: number): Generator<PathToken, undefined, undefined>;
10
10
  export {};
@@ -1,5 +1,5 @@
1
- import { TokenEnum } from "../constants.js";
2
- import { Token } from "../Token.js";
1
+ import { PathTokenEnum } from "../constants.js";
2
+ import { PathToken } from "../Token.js";
3
3
  import { tdpBodyAbsorber } from "./tdp.js";
4
4
  const regExpOrderedMapDDP = {
5
5
  // \\?\UNC\Server\Share\
@@ -24,7 +24,7 @@ const createRootValueMap = {
24
24
  }
25
25
  };
26
26
  function createRootToken(value, offset = 0) {
27
- return new Token(TokenEnum.ROOT, value, offset, offset + value.length - 1);
27
+ return new PathToken(PathTokenEnum.ROOT, value, offset, offset + value.length - 1);
28
28
  }
29
29
  function* ddpAbsorber(str = "", start = 0, end = str.length - 1) {
30
30
  const pks = Object.keys(regExpOrderedMapDDP);
@@ -1,2 +1,2 @@
1
- import { Token } from '../Token.js';
2
- export default function posixAbsorber(str?: string, start?: number, end?: number): Generator<Token, undefined, undefined>;
1
+ import { PathToken } from '../Token.js';
2
+ export default function posixAbsorber(str?: string, start?: number, end?: number): Generator<PathToken, undefined, undefined>;
@@ -1,12 +1,12 @@
1
1
  import absorbSuccessiveValues from "../absorbSuccessiveValues.js";
2
- import { TokenEnum } from "../constants.js";
3
- import { Token } from "../Token.js";
2
+ import { PathTokenEnum } from "../constants.js";
3
+ import { PathToken } from "../Token.js";
4
4
  import { togglePathFragment } from "../togglePathFragment.js";
5
5
  function* posixAbsorber(str = "", start = 0, end = str.length - 1) {
6
6
  let i = start;
7
7
  const root = absorbSuccessiveValues(str, (s) => s === "/", start, end);
8
8
  if (root) {
9
- yield new Token(TokenEnum.ROOT, str.slice(start, root.end + 1), start, root.end);
9
+ yield new PathToken(PathTokenEnum.ROOT, str.slice(start, root.end + 1), start, root.end);
10
10
  i = root.end + 1;
11
11
  }
12
12
  let toggle = 0;
@@ -17,12 +17,12 @@ function* posixAbsorber(str = "", start = 0, end = str.length - 1) {
17
17
  const value = str.slice(i, result.end + 1);
18
18
  let token = togglePathFragment[toggle % 2];
19
19
  if (value === "..") {
20
- token = TokenEnum.PARENT;
20
+ token = PathTokenEnum.PARENT;
21
21
  }
22
22
  if (value === ".") {
23
- token = TokenEnum.CURRENT;
23
+ token = PathTokenEnum.CURRENT;
24
24
  }
25
- yield new Token(token, value, result.start, result.end);
25
+ yield new PathToken(token, value, result.start, result.end);
26
26
  i = result.end + 1;
27
27
  }
28
28
  toggle = ++toggle % 2;
@@ -1,3 +1,3 @@
1
- import { Token } from '../Token.js';
2
- export default function tdpAbsorber(str?: string): Generator<Token, undefined, undefined>;
3
- export declare function tdpBodyAbsorber(str: string | undefined, start: number, end?: number): Generator<Token, undefined, undefined>;
1
+ import { PathToken } from '../Token.js';
2
+ export default function tdpAbsorber(str?: string): Generator<PathToken, undefined, undefined>;
3
+ export declare function tdpBodyAbsorber(str: string | undefined, start: number, end?: number): Generator<PathToken, undefined, undefined>;
@@ -1,9 +1,9 @@
1
1
  import absorbSuccessiveValues from "../absorbSuccessiveValues.js";
2
- import { TokenEnum } from "../constants.js";
2
+ import { PathTokenEnum } from "../constants.js";
3
3
  import getCWD from "../getCWD.js";
4
4
  import getDrive from "../getDrive.js";
5
5
  import mapPlatformNames from "../platform.js";
6
- import { Token } from "../Token.js";
6
+ import { PathToken } from "../Token.js";
7
7
  import { togglePathFragment } from "../togglePathFragment.js";
8
8
  import validSep from "../validSep.js";
9
9
  import { regExpOrderedMapDDP, ddpAbsorber } from "./ddp.js";
@@ -37,7 +37,7 @@ function getCWDDOSRoot() {
37
37
  }
38
38
  const drive = getDrive(getCWD());
39
39
  if (drive[0] >= "a" && drive[0] <= "z" && drive[1] === ":") {
40
- return new Token(TokenEnum.ROOT, `${drive.join("")}`, 0, 1);
40
+ return new PathToken(PathTokenEnum.ROOT, `${drive.join("")}`, 0, 1);
41
41
  }
42
42
  return void 0;
43
43
  }
@@ -73,8 +73,8 @@ function* tdpAbsorber(str = "") {
73
73
  }
74
74
  }
75
75
  const value = str.slice(result.start, result.end + 1);
76
- yield new Token(
77
- TokenEnum.PATHELT,
76
+ yield new PathToken(
77
+ PathTokenEnum.PATHELT,
78
78
  value,
79
79
  0,
80
80
  result.end,
@@ -87,7 +87,7 @@ function* tdpAbsorber(str = "") {
87
87
  }
88
88
  const drive = getDrive(str.slice(i, i + 2).toLowerCase());
89
89
  if (drive[0] >= "a" && drive[0] <= "z" && drive[1] === ":") {
90
- yield new Token(TokenEnum.ROOT, `${drive.join("")}`, i, i + 1);
90
+ yield new PathToken(PathTokenEnum.ROOT, `${drive.join("")}`, i, i + 1);
91
91
  i = 2;
92
92
  }
93
93
  yield* tdpBodyAbsorber(str, i, str.length - 1);
@@ -104,10 +104,10 @@ function* tdpBodyAbsorber(str = "", start, end = str.length - 1) {
104
104
  if (toggle === 0) {
105
105
  switch (value) {
106
106
  case "..":
107
- token = TokenEnum.PARENT;
107
+ token = PathTokenEnum.PARENT;
108
108
  break;
109
109
  case ".":
110
- token = TokenEnum.CURRENT;
110
+ token = PathTokenEnum.CURRENT;
111
111
  break;
112
112
  default: {
113
113
  const ldn = hasLegacyDeviceName(value);
@@ -120,7 +120,7 @@ function* tdpBodyAbsorber(str = "", start, end = str.length - 1) {
120
120
  }
121
121
  }
122
122
  }
123
- yield errors?.length ? new Token(token, value, result.start, result.end, errors?.join("|")) : new Token(token, value, result.start, result.end);
123
+ yield errors?.length ? new PathToken(token, value, result.start, result.end, errors?.join("|")) : new PathToken(token, value, result.start, result.end);
124
124
  i = result.end + 1;
125
125
  }
126
126
  toggle = ++toggle % 2;
@@ -1,3 +1,3 @@
1
- import { Token } from '../Token.js';
1
+ import { PathToken } from '../Token.js';
2
2
  export declare const uncRegExp: RegExp;
3
- export default function uncAbsorber(str?: string): Generator<Token, undefined, undefined>;
3
+ export default function uncAbsorber(str?: string): Generator<PathToken, undefined, undefined>;
@@ -1,5 +1,5 @@
1
- import { TokenEnum } from "../constants.js";
2
- import { Token } from "../Token.js";
1
+ import { PathTokenEnum } from "../constants.js";
2
+ import { PathToken } from "../Token.js";
3
3
  import { tdpBodyAbsorber } from "./tdp.js";
4
4
  const uncRegExp = /^(\/\/|\\\\)([^\\/\\?\\.]+)(\/|\\)([^\\/]+)(\/|\\)?/;
5
5
  function* uncAbsorber(str = "") {
@@ -11,7 +11,7 @@ function* uncAbsorber(str = "") {
11
11
  const share = match[4];
12
12
  const value = `\\\\${server}\\${share}`;
13
13
  const endUnc = value.length - 1;
14
- yield new Token(TokenEnum.ROOT, value, 0, endUnc);
14
+ yield new PathToken(PathTokenEnum.ROOT, value, 0, endUnc);
15
15
  yield* tdpBodyAbsorber(str, endUnc + 1, str.length - 1);
16
16
  }
17
17
  export {
@@ -1,11 +1,11 @@
1
- export declare const TokenEnum: {
1
+ export declare const PathTokenEnum: {
2
2
  readonly SEP: "\u0001";
3
3
  readonly ROOT: "\u0003";
4
4
  readonly PATHELT: "\u0006";
5
5
  readonly PARENT: "\u0007";
6
6
  readonly CURRENT: "\b";
7
7
  };
8
- export type TokenValueEnumType = {
9
- -readonly [K in keyof typeof TokenEnum as (typeof TokenEnum)[K]]: K;
8
+ export type PathTokenValueEnumType = {
9
+ -readonly [K in keyof typeof PathTokenEnum as (typeof PathTokenEnum)[K]]: K;
10
10
  };
11
- export declare const TokenValueEnum: TokenValueEnumType;
11
+ export declare const TokenValueEnum: PathTokenValueEnumType;
package/dist/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- const TokenEnum = {
1
+ const PathTokenEnum = {
2
2
  SEP: "",
3
3
  ROOT: "",
4
4
  PATHELT: "",
@@ -6,12 +6,12 @@ const TokenEnum = {
6
6
  CURRENT: "\b"
7
7
  };
8
8
  (() => {
9
- const entries = Object.entries(TokenEnum);
9
+ const entries = Object.entries(PathTokenEnum);
10
10
  return entries.reduce((obj, [prop, value]) => {
11
11
  obj[value] = prop;
12
12
  return obj;
13
13
  }, {});
14
14
  })();
15
15
  export {
16
- TokenEnum
16
+ PathTokenEnum
17
17
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { allPath, firstPath, resolve } from './parser.js';
2
- import type { Token } from './Token.js';
3
- import type { TokenValueType } from './types/TokenValueType.js';
4
- export { resolve, firstPath, allPath, type Token };
5
- export type { TokenValueType };
1
+ import { ParsedPath } from './ParsedPath.js';
2
+ import { ParsedPathError } from './ParsedPathError.js';
3
+ import { allPath, firstPath, resolve, resolvePathObject } from './parser.js';
4
+ import type { PathToken } from './Token.js';
5
+ import type { PathTokenValueType } from './types/TokenValueType.js';
6
+ export { resolve, firstPath, allPath, ParsedPath, ParsedPathError, resolvePathObject };
7
+ export type { PathTokenValueType, PathToken };
package/dist/index.js CHANGED
@@ -1,6 +1,11 @@
1
- import { allPath, firstPath, resolve } from "./parser.js";
1
+ import { ParsedPath } from "./ParsedPath.js";
2
+ import { ParsedPathError } from "./ParsedPathError.js";
3
+ import { allPath, firstPath, resolve, resolvePathObject } from "./parser.js";
2
4
  export {
5
+ ParsedPath,
6
+ ParsedPathError,
3
7
  allPath,
4
8
  firstPath,
5
- resolve
9
+ resolve,
10
+ resolvePathObject
6
11
  };
package/dist/parser.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  import { ParsedPath } from './ParsedPath.js';
2
2
  import { ParsedPathError } from './ParsedPathError.js';
3
- import { Token } from './Token.js';
3
+ import { PathToken } from './Token.js';
4
4
  export type FileSystem = 'devicePath' | 'unc' | 'dos' | 'posix';
5
5
  declare function firstPath(path?: string, options?: InferPathOptions): ParsedPath | ParsedPathError | undefined;
6
6
  declare function allPath(path?: string, options?: InferPathOptions): (ParsedPath | ParsedPathError)[];
7
7
  export type ParsedPathDTO = {
8
8
  type: FileSystem;
9
- path: Token[];
9
+ path: PathToken[];
10
10
  firstError?: number;
11
11
  };
12
- declare function resolve(fromStr?: string, ...toFragments: string[]): ParsedPath | ParsedPathError;
13
- declare function resolvePathObject(from: ParsedPath, ...toFragments: string[]): ParsedPath | ParsedPathError;
12
+ declare function resolve(fromStr?: string, ...toFragments: string[]): ParsedPath;
13
+ declare function resolvePathObject(from: ParsedPath, ...toFragments: string[]): ParsedPath;
14
14
  type InferPathOptions = {
15
15
  [key in FileSystem]+?: boolean;
16
16
  };
17
- export { resolve, type resolvePathObject, firstPath, allPath };
17
+ export { resolve, resolvePathObject, firstPath, allPath };
package/dist/parser.js CHANGED
@@ -2,12 +2,12 @@ import { ddpAbsorber } from "./absorbers/ddp.js";
2
2
  import posixAbsorber from "./absorbers/posix.js";
3
3
  import tdpAbsorber from "./absorbers/tdp.js";
4
4
  import uncAbsorber from "./absorbers/unc.js";
5
- import { TokenEnum } from "./constants.js";
5
+ import { PathTokenEnum } from "./constants.js";
6
6
  import getCWD from "./getCWD.js";
7
7
  import { ParsedPath } from "./ParsedPath.js";
8
8
  import { ParsedPathError } from "./ParsedPathError.js";
9
9
  import mapPlatformNames from "./platform.js";
10
- import { Token } from "./Token.js";
10
+ import { PathToken } from "./Token.js";
11
11
  const absorberMapping = {
12
12
  unc: uncAbsorber,
13
13
  dos: tdpAbsorber,
@@ -16,6 +16,9 @@ const absorberMapping = {
16
16
  };
17
17
  const allNamespaces = ["devicePath", "unc", "dos", "posix"];
18
18
  function firstPath(path = "", options = {}) {
19
+ if (path === "") {
20
+ return void 0;
21
+ }
19
22
  const iterator = inferPathType(path, options);
20
23
  const step = iterator.next();
21
24
  if (step.done) {
@@ -54,7 +57,7 @@ function last(arr) {
54
57
  }
55
58
  function upp(path) {
56
59
  let _last;
57
- for (_last = last(path); _last.token === TokenEnum.SEP; _last = last(path)) {
60
+ for (_last = last(path); _last.token === PathTokenEnum.SEP; _last = last(path)) {
58
61
  path.pop();
59
62
  }
60
63
  if (_last !== path[0]) {
@@ -62,15 +65,15 @@ function upp(path) {
62
65
  }
63
66
  }
64
67
  function add(_tokens, token) {
65
- if (token.token === TokenEnum.SEP) {
68
+ if (token.token === PathTokenEnum.SEP) {
66
69
  return;
67
70
  }
68
71
  let _last = last(_tokens);
69
- for (; _last.token === TokenEnum.SEP; _last = last(_tokens)) {
72
+ for (; _last.token === PathTokenEnum.SEP; _last = last(_tokens)) {
70
73
  _tokens.pop();
71
74
  }
72
- _tokens.push(new Token(TokenEnum.SEP, getSeperator(), _last.end + 1, _last.end + 1));
73
- _tokens.push(new Token(token.token, token.value, _last.end + 2, _last.end + 2 + token.end));
75
+ _tokens.push(new PathToken(PathTokenEnum.SEP, getSeperator(), _last.end + 1, _last.end + 1));
76
+ _tokens.push(new PathToken(token.token, token.value, _last.end + 2, _last.end + 2 + token.end));
74
77
  }
75
78
  function firstPathFromCWD() {
76
79
  return firstPath(getCWD());
@@ -107,13 +110,13 @@ function resolvePathObject(from, ...toFragments) {
107
110
  const working = structuredClone(from.path);
108
111
  for (const token of firstPathTo.path) {
109
112
  switch (token.token) {
110
- case TokenEnum.SEP:
111
- case TokenEnum.CURRENT:
113
+ case PathTokenEnum.SEP:
114
+ case PathTokenEnum.CURRENT:
112
115
  break;
113
- case TokenEnum.PARENT:
116
+ case PathTokenEnum.PARENT:
114
117
  upp(working);
115
118
  break;
116
- case TokenEnum.PATHELT:
119
+ case PathTokenEnum.PATHELT:
117
120
  add(working, token);
118
121
  break;
119
122
  }
@@ -157,5 +160,6 @@ function* inferPathType(path, options = {}) {
157
160
  export {
158
161
  allPath,
159
162
  firstPath,
160
- resolve
163
+ resolve,
164
+ resolvePathObject
161
165
  };
@@ -1,5 +1,5 @@
1
- import { TokenEnum } from "./constants.js";
2
- const togglePathFragment = [TokenEnum.PATHELT, TokenEnum.SEP];
1
+ import { PathTokenEnum } from "./constants.js";
2
+ const togglePathFragment = [PathTokenEnum.PATHELT, PathTokenEnum.SEP];
3
3
  export {
4
4
  togglePathFragment
5
5
  };
@@ -1,2 +1,2 @@
1
- import type { TokenEnum } from '../constants';
2
- export type TokenValueType = (typeof TokenEnum)[keyof typeof TokenEnum];
1
+ import type { PathTokenEnum } from '../constants';
2
+ export type PathTokenValueType = (typeof PathTokenEnum)[keyof typeof PathTokenEnum];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mangos/filepath",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "author": "jacob bogers <jkfbogers@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "main": "./dist/index.js",
18
18
  "devDependencies": {
19
19
  "@biomejs/biome": "^2.3.8",
20
- "@types/node": "^25.0.0",
20
+ "@types/node": "^25.0.3",
21
21
  "@vitest/coverage-v8": "^4.0.15",
22
22
  "typescript": "^5.9.3",
23
23
  "vite": "^7.2.7",