@mangos/filepath 1.0.8 → 1.0.9

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
@@ -67,12 +67,6 @@ There are 2 exported classes:
67
67
  import { ParsedPath, ParsedPathError, PathToken } from '@mangos/filepath';
68
68
  ```
69
69
 
70
- There is 1 exported enum:
71
-
72
- ```typescript
73
- import { PathTokenEnum } from '@mangos/filepath'
74
- ```
75
-
76
70
  There is 1 exported type:
77
71
 
78
72
  ```typescript
@@ -145,7 +139,6 @@ You dont create `PathToken`s yourself the api will do it for you.
145
139
 
146
140
  ```typescript
147
141
  class PathToken {
148
- token: PathTokenValueType;
149
142
  value: string; // actual path fragment (directory, seperator, or file)
150
143
  start: number; // start location in the original string
151
144
  end: number; // end (inclusive) in the original string
@@ -155,21 +148,10 @@ class PathToken {
155
148
  isCurrent(): boolean; // token representing "./"
156
149
  isParent(): boolean // token representing "../"
157
150
  isSeperator(): boolean // token representing "/" (posix) or "\" (windows, dos)
151
+ hasError(): boolean // did tokenizing the path associated an error with this token
158
152
  }
159
153
  ```
160
154
 
161
- The `PathTokenValueType` match the exported `PathTokenEnum` object
162
-
163
- ```typescript
164
- export const PathTokenEnum = {
165
- SEP: '\x01', // path seperator
166
- ROOT: '\x03', // the root (if it is an absolute path)
167
- PATHELT: '\x06', // directory, file,
168
- PARENT: '\x07', // two dots (..) meaning parent directory
169
- CURRENT: '\x08', // a single dot (.) meaning current directory
170
- } as const;
171
- ```
172
-
173
155
  <h3 id="api-functions">Functions</h3>
174
156
 
175
157
  <h4 id="fn-all-path">function: <code>allPath</code></h4>
@@ -1,9 +1,14 @@
1
- import type { FileSystem, ParsedPathDTO } from './parser.js';
2
- import type { PathToken } from './Token.js';
1
+ import type { FileSystem, ParsedPathInputDTO } from './parser.js';
2
+ import type { PathToken, PathTokenDTO } from './types/PathToken.js';
3
3
  export declare class ParsedPath {
4
4
  readonly path: PathToken[];
5
5
  readonly type: FileSystem;
6
- constructor(parsed: ParsedPathDTO);
6
+ constructor(parsed: ParsedPathInputDTO);
7
7
  toString(): string;
8
8
  isRelative(): boolean;
9
+ toDTO(): ParsedPathDTO;
9
10
  }
11
+ export type ParsedPathDTO = {
12
+ type: FileSystem;
13
+ path: PathTokenDTO[];
14
+ };
@@ -11,6 +11,12 @@ class ParsedPath {
11
11
  isRelative() {
12
12
  return this.path[0].isRoot() === false;
13
13
  }
14
+ toDTO() {
15
+ return {
16
+ type: this.type,
17
+ path: this.path.map((pt) => pt.toDTO())
18
+ };
19
+ }
14
20
  }
15
21
  export {
16
22
  ParsedPath
@@ -1,9 +1,11 @@
1
- import type { PathToken } from 'Token.js';
2
- import type { FileSystem, ParsedPathDTO } from './parser.js';
1
+ import type { ParsedPathDTO } from 'ParsedPath.js';
2
+ import type { PathToken } from 'types/PathToken.js';
3
+ import type { FileSystem, ParsedPathInputDTO } from './parser.js';
3
4
  export declare class ParsedPathError {
4
5
  private readonly parsed;
5
6
  readonly path: PathToken[];
6
7
  readonly type: FileSystem;
7
- constructor(parsed: ParsedPathDTO);
8
+ constructor(parsed: ParsedPathInputDTO);
8
9
  toString(): string;
10
+ toDTO(): ParsedPathDTO;
9
11
  }
@@ -14,6 +14,12 @@ class ParsedPathError {
14
14
  return "";
15
15
  }).join("\n");
16
16
  }
17
+ toDTO() {
18
+ return {
19
+ type: this.type,
20
+ path: this.path.map((pt) => pt.toDTO())
21
+ };
22
+ }
17
23
  }
18
24
  export {
19
25
  ParsedPathError
@@ -0,0 +1,28 @@
1
+ import { PathTokenEnum } from './constants.js';
2
+ import type { PathToken, PathTokenDTO } from './types/PathToken.js';
3
+ import type { PathTokenValueType } from './types/TokenValueType.js';
4
+ export declare class PathTokenImpl implements PathToken {
5
+ #private;
6
+ static from(o: {
7
+ type: keyof typeof PathTokenEnum;
8
+ value: string;
9
+ start: number;
10
+ end: number;
11
+ error?: string | undefined;
12
+ }): PathTokenImpl;
13
+ constructor(token: PathTokenValueType, value: string, start: number, end: number, error?: string);
14
+ isRoot(): boolean;
15
+ isSeparator(): boolean;
16
+ isPathElement(): boolean;
17
+ isCurrent(): boolean;
18
+ isParent(): boolean;
19
+ equals(ot: PathToken): boolean;
20
+ hasError(): boolean;
21
+ get type(): PathTokenValueType;
22
+ get error(): string | undefined;
23
+ get value(): string;
24
+ get end(): number;
25
+ get start(): number;
26
+ clone(): PathTokenImpl;
27
+ toDTO(): PathTokenDTO;
28
+ }
@@ -0,0 +1,71 @@
1
+ import { PathTokenEnum, TokenValueEnum } from "./constants.js";
2
+ class PathTokenImpl {
3
+ static from(o) {
4
+ return new PathTokenImpl(PathTokenEnum[o.type], o.value, o.start, o.end, o.error);
5
+ }
6
+ constructor(token, value, start, end, error) {
7
+ this.#token = token;
8
+ this.#value = value;
9
+ this.#end = end;
10
+ this.#start = start;
11
+ if (error) {
12
+ this.#error = error;
13
+ }
14
+ }
15
+ isRoot() {
16
+ return this.#token === PathTokenEnum.ROOT;
17
+ }
18
+ isSeparator() {
19
+ return this.#token === PathTokenEnum.SEP;
20
+ }
21
+ isPathElement() {
22
+ return this.#token === PathTokenEnum.PATHELT;
23
+ }
24
+ isCurrent() {
25
+ return this.#token === PathTokenEnum.CURRENT;
26
+ }
27
+ isParent() {
28
+ return this.#token === PathTokenEnum.PARENT;
29
+ }
30
+ equals(ot) {
31
+ return ot.type === this.type && ot.value === this.value && ot.error === this.error;
32
+ }
33
+ hasError() {
34
+ return !!this.error;
35
+ }
36
+ get type() {
37
+ return this.#token;
38
+ }
39
+ get error() {
40
+ return this.#error;
41
+ }
42
+ get value() {
43
+ return this.#value;
44
+ }
45
+ get end() {
46
+ return this.#end;
47
+ }
48
+ get start() {
49
+ return this.#start;
50
+ }
51
+ clone() {
52
+ return new PathTokenImpl(this.#token, this.#value, this.#start, this.#end, this.#error);
53
+ }
54
+ toDTO() {
55
+ return {
56
+ type: TokenValueEnum[this.#token],
57
+ ...this.#error && { error: this.#error },
58
+ value: this.#value,
59
+ end: this.#end,
60
+ start: this.#start
61
+ };
62
+ }
63
+ #error;
64
+ #token;
65
+ #value;
66
+ #end;
67
+ #start;
68
+ }
69
+ export {
70
+ PathTokenImpl
71
+ };
@@ -1,4 +1,4 @@
1
- import { PathToken } from '../Token.js';
1
+ import { PathTokenImpl } from '../PathTokenImpl.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<PathToken, undefined, undefined>;
9
+ export declare function ddpAbsorber(str?: string, start?: number, end?: number): Generator<PathTokenImpl, undefined, undefined>;
10
10
  export {};
@@ -1,5 +1,5 @@
1
1
  import { PathTokenEnum } from "../constants.js";
2
- import { PathToken } from "../Token.js";
2
+ import { PathTokenImpl } from "../PathTokenImpl.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 PathToken(PathTokenEnum.ROOT, value, offset, offset + value.length - 1);
27
+ return new PathTokenImpl(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 { PathToken } from '../Token.js';
2
- export default function posixAbsorber(str?: string, start?: number, end?: number): Generator<PathToken, undefined, undefined>;
1
+ import { PathTokenImpl } from '../PathTokenImpl.js';
2
+ export default function posixAbsorber(str?: string, start?: number, end?: number): Generator<PathTokenImpl, undefined, undefined>;
@@ -1,12 +1,12 @@
1
1
  import absorbSuccessiveValues from "../absorbSuccessiveValues.js";
2
2
  import { PathTokenEnum } from "../constants.js";
3
- import { PathToken } from "../Token.js";
3
+ import { PathTokenImpl } from "../PathTokenImpl.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 PathToken(PathTokenEnum.ROOT, str.slice(start, root.end + 1), start, root.end);
9
+ yield new PathTokenImpl(PathTokenEnum.ROOT, str.slice(start, root.end + 1), start, root.end);
10
10
  i = root.end + 1;
11
11
  }
12
12
  let toggle = 0;
@@ -22,7 +22,7 @@ function* posixAbsorber(str = "", start = 0, end = str.length - 1) {
22
22
  if (value === ".") {
23
23
  token = PathTokenEnum.CURRENT;
24
24
  }
25
- yield new PathToken(token, value, result.start, result.end);
25
+ yield new PathTokenImpl(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 { 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
+ import { PathTokenImpl } from '../PathTokenImpl.js';
2
+ export default function tdpAbsorber(str?: string): Generator<PathTokenImpl, undefined, undefined>;
3
+ export declare function tdpBodyAbsorber(str: string | undefined, start: number, end?: number): Generator<PathTokenImpl, undefined, undefined>;
@@ -2,8 +2,8 @@ import absorbSuccessiveValues from "../absorbSuccessiveValues.js";
2
2
  import { PathTokenEnum } from "../constants.js";
3
3
  import getCWD from "../getCWD.js";
4
4
  import getDrive from "../getDrive.js";
5
+ import { PathTokenImpl } from "../PathTokenImpl.js";
5
6
  import mapPlatformNames from "../platform.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 PathToken(PathTokenEnum.ROOT, `${drive.join("")}`, 0, 1);
40
+ return new PathTokenImpl(PathTokenEnum.ROOT, `${drive.join("")}`, 0, 1);
41
41
  }
42
42
  return void 0;
43
43
  }
@@ -73,7 +73,7 @@ function* tdpAbsorber(str = "") {
73
73
  }
74
74
  }
75
75
  const value = str.slice(result.start, result.end + 1);
76
- yield new PathToken(
76
+ yield new PathTokenImpl(
77
77
  PathTokenEnum.PATHELT,
78
78
  value,
79
79
  0,
@@ -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 PathToken(PathTokenEnum.ROOT, `${drive.join("")}`, i, i + 1);
90
+ yield new PathTokenImpl(PathTokenEnum.ROOT, `${drive.join("")}`, i, i + 1);
91
91
  i = 2;
92
92
  }
93
93
  yield* tdpBodyAbsorber(str, i, str.length - 1);
@@ -120,7 +120,7 @@ function* tdpBodyAbsorber(str = "", start, end = str.length - 1) {
120
120
  }
121
121
  }
122
122
  }
123
- yield errors?.length ? new PathToken(token, value, result.start, result.end, errors?.join("|")) : new PathToken(token, value, result.start, result.end);
123
+ yield errors?.length ? new PathTokenImpl(token, value, result.start, result.end, errors?.join("|")) : new PathTokenImpl(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 { PathToken } from '../Token.js';
1
+ import { PathTokenImpl } from '../PathTokenImpl.js';
2
2
  export declare const uncRegExp: RegExp;
3
- export default function uncAbsorber(str?: string): Generator<PathToken, undefined, undefined>;
3
+ export default function uncAbsorber(str?: string): Generator<PathTokenImpl, undefined, undefined>;
@@ -1,5 +1,5 @@
1
1
  import { PathTokenEnum } from "../constants.js";
2
- import { PathToken } from "../Token.js";
2
+ import { PathTokenImpl } from "../PathTokenImpl.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 PathToken(PathTokenEnum.ROOT, value, 0, endUnc);
14
+ yield new PathTokenImpl(PathTokenEnum.ROOT, value, 0, endUnc);
15
15
  yield* tdpBodyAbsorber(str, endUnc + 1, str.length - 1);
16
16
  }
17
17
  export {
package/dist/constants.js CHANGED
@@ -5,7 +5,7 @@ const PathTokenEnum = {
5
5
  PARENT: "\x07",
6
6
  CURRENT: "\b"
7
7
  };
8
- (() => {
8
+ const TokenValueEnum = (() => {
9
9
  const entries = Object.entries(PathTokenEnum);
10
10
  return entries.reduce((obj, [prop, value]) => {
11
11
  obj[value] = prop;
@@ -13,5 +13,6 @@ const PathTokenEnum = {
13
13
  }, {});
14
14
  })();
15
15
  export {
16
- PathTokenEnum
16
+ PathTokenEnum,
17
+ TokenValueEnum
17
18
  };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { PathTokenEnum } from './constants.js';
2
1
  import { ParsedPath } from './ParsedPath.js';
3
2
  import { ParsedPathError } from './ParsedPathError.js';
3
+ import { PathTokenImpl } from './PathTokenImpl.js';
4
4
  import { allPath, firstPath, resolve, resolvePathObject } from './parser.js';
5
- import { PathToken } from './Token.js';
5
+ import type { PathToken } from './types/PathToken.js';
6
+ import type { Token } from './types/Token.js';
6
7
  import type { PathTokenValueType } from './types/TokenValueType.js';
7
- export { resolve, firstPath, allPath, ParsedPath, ParsedPathError, PathToken, resolvePathObject, PathTokenEnum };
8
- export type { PathTokenValueType };
8
+ export { resolve, firstPath, allPath, ParsedPath, ParsedPathError, PathTokenImpl, resolvePathObject };
9
+ export type { PathTokenValueType, Token, PathToken };
package/dist/index.js CHANGED
@@ -1,13 +1,11 @@
1
- import { PathTokenEnum } from "./constants.js";
2
1
  import { ParsedPath } from "./ParsedPath.js";
3
2
  import { ParsedPathError } from "./ParsedPathError.js";
3
+ import { PathTokenImpl } from "./PathTokenImpl.js";
4
4
  import { allPath, firstPath, resolve, resolvePathObject } from "./parser.js";
5
- import { PathToken } from "./Token.js";
6
5
  export {
7
6
  ParsedPath,
8
7
  ParsedPathError,
9
- PathToken,
10
- PathTokenEnum,
8
+ PathTokenImpl,
11
9
  allPath,
12
10
  firstPath,
13
11
  resolve,
package/dist/parser.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { ParsedPath } from './ParsedPath.js';
2
2
  import { ParsedPathError } from './ParsedPathError.js';
3
- import { PathToken } from './Token.js';
3
+ import type { PathToken } from './types/PathToken.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
- export type ParsedPathDTO = {
7
+ export type ParsedPathInputDTO = {
8
8
  type: FileSystem;
9
9
  path: PathToken[];
10
10
  firstError?: number;
package/dist/parser.js CHANGED
@@ -6,8 +6,8 @@ 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
+ import { PathTokenImpl } from "./PathTokenImpl.js";
9
10
  import mapPlatformNames from "./platform.js";
10
- import { PathToken } from "./Token.js";
11
11
  const absorberMapping = {
12
12
  unc: uncAbsorber,
13
13
  dos: tdpAbsorber,
@@ -57,7 +57,7 @@ function last(arr) {
57
57
  }
58
58
  function upp(path) {
59
59
  let _last;
60
- for (_last = last(path); _last.token === PathTokenEnum.SEP; _last = last(path)) {
60
+ for (_last = last(path); _last.isSeparator(); _last = last(path)) {
61
61
  path.pop();
62
62
  }
63
63
  if (_last !== path[0]) {
@@ -65,15 +65,15 @@ function upp(path) {
65
65
  }
66
66
  }
67
67
  function add(_tokens, token) {
68
- if (token.token === PathTokenEnum.SEP) {
68
+ if (token.isSeparator()) {
69
69
  return;
70
70
  }
71
71
  let _last = last(_tokens);
72
- for (; _last.token === PathTokenEnum.SEP; _last = last(_tokens)) {
72
+ for (; _last.type === PathTokenEnum.SEP; _last = last(_tokens)) {
73
73
  _tokens.pop();
74
74
  }
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));
75
+ _tokens.push(new PathTokenImpl(PathTokenEnum.SEP, getSeperator(), _last.end + 1, _last.end + 1));
76
+ _tokens.push(new PathTokenImpl(token.type, token.value, _last.end + 2, _last.end + 2 + token.end));
77
77
  }
78
78
  function firstPathFromCWD() {
79
79
  return firstPath(getCWD());
@@ -107,16 +107,16 @@ function resolvePathObject(from, ...toFragments) {
107
107
  }
108
108
  return resolvePathObject(firstPathTo, ...toFragments);
109
109
  }
110
- const working = structuredClone(from.path);
110
+ const working = from.path.map((s) => s.clone());
111
111
  for (const token of firstPathTo.path) {
112
- switch (token.token) {
113
- case PathTokenEnum.SEP:
114
- case PathTokenEnum.CURRENT:
112
+ switch (true) {
113
+ case token.isSeparator():
114
+ case token.isCurrent():
115
115
  break;
116
- case PathTokenEnum.PARENT:
116
+ case token.isParent():
117
117
  upp(working);
118
118
  break;
119
- case PathTokenEnum.PATHELT:
119
+ case token.isPathElement():
120
120
  add(working, token);
121
121
  break;
122
122
  }
@@ -0,0 +1,26 @@
1
+ import type { PathTokenEnum } from '../constants.js';
2
+ import type { Token } from './Token';
3
+ import type { PathTokenValueType } from './TokenValueType.js';
4
+ export interface PathToken extends Token {
5
+ isRoot(): boolean;
6
+ isSeparator(): boolean;
7
+ isPathElement(): boolean;
8
+ isCurrent(): boolean;
9
+ isParent(): boolean;
10
+ equals(ot: PathToken): boolean;
11
+ hasError(): boolean;
12
+ get error(): undefined | string;
13
+ get type(): PathTokenValueType;
14
+ get value(): string;
15
+ get end(): number;
16
+ get start(): number;
17
+ clone(): PathToken;
18
+ toDTO(): PathTokenDTO;
19
+ }
20
+ export type PathTokenDTO = {
21
+ type: keyof typeof PathTokenEnum;
22
+ error?: undefined | string;
23
+ value: string;
24
+ end: number;
25
+ start: number;
26
+ };
@@ -0,0 +1,3 @@
1
+ export interface Token {
2
+ equals(a: Token): boolean;
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mangos/filepath",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "author": "jacob bogers <jkfbogers@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",
package/dist/Token.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import type { PathTokenValueType } from './types/TokenValueType.js';
2
- export declare class PathToken {
3
- readonly token: PathTokenValueType;
4
- readonly value: string;
5
- readonly start: number;
6
- readonly end: number;
7
- static from(o: {
8
- token: PathTokenValueType;
9
- value: string;
10
- start: number;
11
- end: number;
12
- error?: string;
13
- }): PathToken;
14
- readonly error?: string;
15
- constructor(token: PathTokenValueType, value: string, start: number, end: number, error?: string);
16
- isRoot(): boolean;
17
- isSeparator(): boolean;
18
- isPathElement(): boolean;
19
- isCurrent(): boolean;
20
- isParent(): boolean;
21
- equals(ot: PathToken): boolean;
22
- }
package/dist/Token.js DELETED
@@ -1,37 +0,0 @@
1
- import { PathTokenEnum } from "./constants.js";
2
- class PathToken {
3
- constructor(token, value, start, end, error) {
4
- this.token = token;
5
- this.value = value;
6
- this.start = start;
7
- this.end = end;
8
- if (error) {
9
- this.error = error;
10
- }
11
- }
12
- static from(o) {
13
- return new PathToken(o.token, o.value, o.start, o.end, o.error);
14
- }
15
- error;
16
- isRoot() {
17
- return this.token === PathTokenEnum.ROOT;
18
- }
19
- isSeparator() {
20
- return this.token === PathTokenEnum.SEP;
21
- }
22
- isPathElement() {
23
- return this.token === PathTokenEnum.PATHELT;
24
- }
25
- isCurrent() {
26
- return this.token === PathTokenEnum.CURRENT;
27
- }
28
- isParent() {
29
- return this.token === PathTokenEnum.PARENT;
30
- }
31
- equals(ot) {
32
- return ot.token === this.token && ot.value === this.value && ot.error === this.error;
33
- }
34
- }
35
- export {
36
- PathToken
37
- };