@mangos/filepath 1.0.6 → 1.0.8

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
@@ -64,7 +64,19 @@ import { allPath, firstPath, resolve, resolvePathObject } from '@mangos/filepath
64
64
  There are 2 exported classes:
65
65
 
66
66
  ```typescript
67
- import { ParsedPath, ParsedPathError } from '@mangos/filepath';
67
+ import { ParsedPath, ParsedPathError, PathToken } from '@mangos/filepath';
68
+ ```
69
+
70
+ There is 1 exported enum:
71
+
72
+ ```typescript
73
+ import { PathTokenEnum } from '@mangos/filepath'
74
+ ```
75
+
76
+ There is 1 exported type:
77
+
78
+ ```typescript
79
+ import type { InferPathOptions } from '@mangos/filepath'
68
80
  ```
69
81
 
70
82
  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>.
@@ -127,6 +139,37 @@ When a string is parsed it will be evaluated according to path types in the foll
127
139
  3. `dos` tokanization will be tried third, (if the `dos` boolean is set to true).
128
140
  4. `posix` tokanization will be tried forth, (if the `posix` boolean is set to true)
129
141
 
142
+ <h3 id="path-token-type"><code>PathToken</code> object</h3>
143
+
144
+ You dont create `PathToken`s yourself the api will do it for you.
145
+
146
+ ```typescript
147
+ class PathToken {
148
+ token: PathTokenValueType;
149
+ value: string; // actual path fragment (directory, seperator, or file)
150
+ start: number; // start location in the original string
151
+ end: number; // end (inclusive) in the original string
152
+ error?: string; // this token has invalid character for the OS selected
153
+ isRoot(): boolean; // is this token a Root Token (c:/, /, //?/UNC/Server/share, etc)
154
+ isPathElement(): boolean; // a normal path element
155
+ isCurrent(): boolean; // token representing "./"
156
+ isParent(): boolean // token representing "../"
157
+ isSeperator(): boolean // token representing "/" (posix) or "\" (windows, dos)
158
+ }
159
+ ```
160
+
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
+
130
173
  <h3 id="api-functions">Functions</h3>
131
174
 
132
175
  <h4 id="fn-all-path">function: <code>allPath</code></h4>
package/dist/Token.d.ts CHANGED
@@ -14,5 +14,9 @@ export declare class PathToken {
14
14
  readonly error?: string;
15
15
  constructor(token: PathTokenValueType, value: string, start: number, end: number, error?: string);
16
16
  isRoot(): boolean;
17
+ isSeparator(): boolean;
18
+ isPathElement(): boolean;
19
+ isCurrent(): boolean;
20
+ isParent(): boolean;
17
21
  equals(ot: PathToken): boolean;
18
22
  }
package/dist/Token.js CHANGED
@@ -16,6 +16,18 @@ class PathToken {
16
16
  isRoot() {
17
17
  return this.token === PathTokenEnum.ROOT;
18
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
+ }
19
31
  equals(ot) {
20
32
  return ot.token === this.token && ot.value === this.value && ot.error === this.error;
21
33
  }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
+ import { PathTokenEnum } from './constants.js';
1
2
  import { ParsedPath } from './ParsedPath.js';
2
3
  import { ParsedPathError } from './ParsedPathError.js';
3
4
  import { allPath, firstPath, resolve, resolvePathObject } from './parser.js';
4
- import type { PathToken } from './Token.js';
5
+ import { PathToken } from './Token.js';
5
6
  import type { PathTokenValueType } from './types/TokenValueType.js';
6
- export { resolve, firstPath, allPath, ParsedPath, ParsedPathError, resolvePathObject };
7
- export type { PathTokenValueType, PathToken };
7
+ export { resolve, firstPath, allPath, ParsedPath, ParsedPathError, PathToken, resolvePathObject, PathTokenEnum };
8
+ export type { PathTokenValueType };
package/dist/index.js CHANGED
@@ -1,9 +1,13 @@
1
+ import { PathTokenEnum } from "./constants.js";
1
2
  import { ParsedPath } from "./ParsedPath.js";
2
3
  import { ParsedPathError } from "./ParsedPathError.js";
3
4
  import { allPath, firstPath, resolve, resolvePathObject } from "./parser.js";
5
+ import { PathToken } from "./Token.js";
4
6
  export {
5
7
  ParsedPath,
6
8
  ParsedPathError,
9
+ PathToken,
10
+ PathTokenEnum,
7
11
  allPath,
8
12
  firstPath,
9
13
  resolve,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mangos/filepath",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "author": "jacob bogers <jkfbogers@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",