@ptolemy2002/rgx 2.7.0 → 2.7.1
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 +6 -6
- package/dist/typeGuards.d.ts +2 -2
- package/dist/typeGuards.js +2 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -305,10 +305,10 @@ Asserts that the given value is an array of RGX tokens. Validates that the value
|
|
|
305
305
|
|
|
306
306
|
### rgxTokenType
|
|
307
307
|
```typescript
|
|
308
|
-
function rgxTokenType(value:
|
|
308
|
+
function rgxTokenType(value: unknown): RGXTokenType
|
|
309
309
|
```
|
|
310
310
|
|
|
311
|
-
Determines the type of a given RGX token (`no-op`, `literal`, `native`, `convertible`, or an array of the former).
|
|
311
|
+
Determines the type of a given RGX token value (`no-op`, `literal`, `native`, `convertible`, or an array of the former) or throws an error if the value is not a valid RGX token.
|
|
312
312
|
|
|
313
313
|
If you narrow the result of this function to something more specific, you can then convert these string or array literals into their corresponding token types using the `RGXTokenFromType` utility type or `rgxTokenFromType` function.
|
|
314
314
|
|
|
@@ -323,16 +323,16 @@ if (type === 'native') {
|
|
|
323
323
|
```
|
|
324
324
|
|
|
325
325
|
#### Parameters
|
|
326
|
-
- `value` (`
|
|
326
|
+
- `value` (`unknown`): The value to check.
|
|
327
327
|
|
|
328
328
|
#### Returns
|
|
329
329
|
- `RGXTokenType`: The type of the RGX token.
|
|
330
330
|
|
|
331
331
|
### rgxTokenTypeFlat
|
|
332
332
|
```typescript
|
|
333
|
-
function rgxTokenTypeFlat(value:
|
|
333
|
+
function rgxTokenTypeFlat(value: unknown): RGXTokenTypeFlat
|
|
334
334
|
```
|
|
335
|
-
Determines the flat type of a given RGX token (`no-op`, `literal`, `native`, `convertible`, or `array`). The `array` type represents any array of RGX tokens, regardless of the types of the individual tokens within the array.
|
|
335
|
+
Determines the flat type of a given RGX token value (`no-op`, `literal`, `native`, `convertible`, or `array`) or throws an error if the value is not a valid RGX token. The `array` type represents any array of RGX tokens, regardless of the types of the individual tokens within the array.
|
|
336
336
|
|
|
337
337
|
If you narrow the result of this function to something more specific, you can then convert these string literals into their corresponding token types using the `RGXTokenFromType` utility type or `rgxTokenFromType` function.
|
|
338
338
|
|
|
@@ -346,7 +346,7 @@ if (type === 'array') {
|
|
|
346
346
|
```
|
|
347
347
|
|
|
348
348
|
#### Parameters
|
|
349
|
-
- `value` (`
|
|
349
|
+
- `value` (`unknown`): The value to check.
|
|
350
350
|
|
|
351
351
|
#### Returns
|
|
352
352
|
- `RGXTokenTypeFlat`: The flat type of the RGX token.
|
package/dist/typeGuards.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export declare function isRGXConvertibleToken(value: unknown): value is t.RGXCon
|
|
|
9
9
|
export declare function assertRGXConvertibleToken(value: unknown): asserts value is t.RGXConvertibleToken;
|
|
10
10
|
export declare function isRGXArrayToken(value: unknown): value is t.RGXToken[];
|
|
11
11
|
export declare function assertRGXArrayToken(value: unknown): asserts value is t.RGXToken[];
|
|
12
|
-
export declare function rgxTokenTypeFlat(value:
|
|
13
|
-
export declare function rgxTokenType(value:
|
|
12
|
+
export declare function rgxTokenTypeFlat(value: unknown): t.RGXTokenTypeFlat;
|
|
13
|
+
export declare function rgxTokenType(value: unknown): t.RGXTokenType;
|
|
14
14
|
export declare function rgxTokenFromType<T extends t.RGXTokenTypeGuardInput>(type: T, value: t.RGXToken): t.RGXTokenFromType<T>;
|
|
15
15
|
export declare function rgxTokenTypeToFlat(type: t.RGXTokenType): t.RGXTokenTypeFlat;
|
|
16
16
|
export declare function rgxTokenTypeGuardInputToFlat(type: t.RGXTokenTypeGuardInput): t.RGXTokenTypeFlat | null;
|
package/dist/typeGuards.js
CHANGED
|
@@ -120,21 +120,16 @@ function rgxTokenTypeFlat(value) {
|
|
|
120
120
|
return 'native';
|
|
121
121
|
if (isRGXConvertibleToken(value))
|
|
122
122
|
return 'convertible';
|
|
123
|
-
if (
|
|
123
|
+
if (isRGXArrayToken(value))
|
|
124
124
|
return 'array';
|
|
125
|
-
// Ignoring this line since it should be impossible to reach if the types are correct, but we need it to satisfy the return type
|
|
126
|
-
/* istanbul ignore next */
|
|
127
125
|
throw new e.RGXInvalidTokenError("Invalid RGX token", null, value);
|
|
128
126
|
}
|
|
129
127
|
function rgxTokenType(value) {
|
|
130
128
|
const flatType = rgxTokenTypeFlat(value);
|
|
131
129
|
if (flatType !== 'array')
|
|
132
130
|
return flatType;
|
|
133
|
-
|
|
131
|
+
else
|
|
134
132
|
return value.map(rgxTokenType);
|
|
135
|
-
// Ignoring this line since it should be impossible to reach if the types are correct, but we need it to satisfy the return type
|
|
136
|
-
/* istanbul ignore next */
|
|
137
|
-
throw new e.RGXInvalidTokenError("Invalid RGX token", null, value);
|
|
138
133
|
}
|
|
139
134
|
function rgxTokenFromType(type, value) {
|
|
140
135
|
// Ignoring this line because the function is entirely a TypeScript utility that doesn't need to be tested at runtime.
|