@tstdl/base 0.90.58 → 0.90.59
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/.eslintrc.json +3 -3
- package/json-path/json-path.d.ts +11 -9
- package/json-path/json-path.js +9 -6
- package/package.json +2 -2
- package/utils/object/dereference.js +1 -1
package/.eslintrc.json
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"camelcase": ["off"],
|
|
29
29
|
"capitalized-comments": ["warn", "always", { "ignorePattern": "noop" }],
|
|
30
30
|
"class-methods-use-this": ["off"],
|
|
31
|
-
"complexity": ["
|
|
31
|
+
"complexity": ["off"],
|
|
32
32
|
"consistent-type-definitions": ["off"],
|
|
33
33
|
"eqeqeq": ["off"],
|
|
34
34
|
"explicit-function-return-type": ["off"],
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"id-length": ["off"],
|
|
38
38
|
"init-declarations": ["off"],
|
|
39
39
|
"line-comment-position": ["off"],
|
|
40
|
-
"max-classes-per-file": ["
|
|
40
|
+
"max-classes-per-file": ["off"],
|
|
41
41
|
"max-lines-per-function": ["warn", { "max": 100, "skipBlankLines": true, "skipComments": true }],
|
|
42
|
-
"max-lines": ["
|
|
42
|
+
"max-lines": ["off"],
|
|
43
43
|
"max-params": ["off"],
|
|
44
44
|
"max-statements": ["off"],
|
|
45
45
|
"new-cap": ["off"],
|
package/json-path/json-path.d.ts
CHANGED
|
@@ -4,22 +4,24 @@ export declare class JsonPath<T = any> implements Iterable<JsonPathNode> {
|
|
|
4
4
|
private readonly _options;
|
|
5
5
|
private _path;
|
|
6
6
|
private _nodes;
|
|
7
|
-
/**
|
|
7
|
+
/** Json path as encoded string */
|
|
8
8
|
get path(): string;
|
|
9
|
-
/**
|
|
9
|
+
/** Json path as decoded array */
|
|
10
10
|
get nodes(): readonly JsonPathNode[];
|
|
11
11
|
static get ROOT(): JsonPath;
|
|
12
12
|
constructor(options?: JsonPathOptions);
|
|
13
13
|
constructor(path: JsonPathInput, options?: JsonPathOptions);
|
|
14
|
+
static from(options?: JsonPathOptions): JsonPath;
|
|
15
|
+
static from(path: JsonPathInput, options?: JsonPathOptions): JsonPath;
|
|
14
16
|
static isJsonPath(path: string): boolean;
|
|
15
17
|
/**
|
|
16
|
-
*
|
|
18
|
+
* Add a property or index to current path
|
|
17
19
|
* @param key
|
|
18
20
|
* @returns new JsonPath instance
|
|
19
21
|
*/
|
|
20
22
|
add<K extends keyof T>(key: K): JsonPath<T[K]>;
|
|
21
23
|
/**
|
|
22
|
-
*
|
|
24
|
+
* Updates options
|
|
23
25
|
* @param options
|
|
24
26
|
* @returns new JsonPath instance
|
|
25
27
|
*/
|
|
@@ -27,9 +29,9 @@ export declare class JsonPath<T = any> implements Iterable<JsonPathNode> {
|
|
|
27
29
|
[Symbol.iterator](): Iterator<PropertyKey>;
|
|
28
30
|
}
|
|
29
31
|
export type JsonPathOptions = {
|
|
30
|
-
/**
|
|
32
|
+
/** Encode as array.0 instead of array[0] */
|
|
31
33
|
treatArrayAsObject?: boolean;
|
|
32
|
-
/**
|
|
34
|
+
/** Encode as ['foo'] instead of .foo */
|
|
33
35
|
forceBrackets?: boolean;
|
|
34
36
|
/**
|
|
35
37
|
* Prepend $
|
|
@@ -38,12 +40,12 @@ export type JsonPathOptions = {
|
|
|
38
40
|
dollar?: boolean;
|
|
39
41
|
};
|
|
40
42
|
export type JsonPathContext = {
|
|
41
|
-
/**
|
|
43
|
+
/** If path contains symbols, they are required in order to be mapped, otherwise they are created from global symbol registry */
|
|
42
44
|
symbols?: symbol[];
|
|
43
45
|
};
|
|
44
46
|
export declare function isJsonPath(path: string): boolean;
|
|
45
47
|
/**
|
|
46
|
-
*
|
|
48
|
+
* Encodes an array of nodes into a JSONPath
|
|
47
49
|
* @param nodes nodes to encode
|
|
48
50
|
* @param options encoding options
|
|
49
51
|
* @returns JSONPath string
|
|
@@ -53,7 +55,7 @@ export declare function isJsonPath(path: string): boolean;
|
|
|
53
55
|
*/
|
|
54
56
|
export declare function encodeJsonPath(nodes: readonly JsonPathNode[], options?: JsonPathOptions): string;
|
|
55
57
|
/**
|
|
56
|
-
*
|
|
58
|
+
* Decodes a JSONPath into its nodes. Only supports child operator
|
|
57
59
|
* @param path JSONPath string
|
|
58
60
|
* @returns array of nodes
|
|
59
61
|
* @example
|
package/json-path/json-path.js
CHANGED
|
@@ -6,14 +6,14 @@ export class JsonPath {
|
|
|
6
6
|
_options;
|
|
7
7
|
_path;
|
|
8
8
|
_nodes;
|
|
9
|
-
/**
|
|
9
|
+
/** Json path as encoded string */
|
|
10
10
|
get path() {
|
|
11
11
|
if (isUndefined(this._path)) {
|
|
12
12
|
this._path = encodeJsonPath(this._nodes, this._options);
|
|
13
13
|
}
|
|
14
14
|
return this._path;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
16
|
+
/** Json path as decoded array */
|
|
17
17
|
get nodes() {
|
|
18
18
|
if (isUndefined(this._nodes)) {
|
|
19
19
|
this._nodes = decodeJsonPath(this._path);
|
|
@@ -42,11 +42,14 @@ export class JsonPath {
|
|
|
42
42
|
this._options = pathOrNodesOrOptions;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
static from(pathOrNodesOrOptions = [], options = {}) {
|
|
46
|
+
return new JsonPath(pathOrNodesOrOptions, options);
|
|
47
|
+
}
|
|
45
48
|
static isJsonPath(path) {
|
|
46
49
|
return isJsonPath(path);
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
|
-
*
|
|
52
|
+
* Add a property or index to current path
|
|
50
53
|
* @param key
|
|
51
54
|
* @returns new JsonPath instance
|
|
52
55
|
*/
|
|
@@ -54,7 +57,7 @@ export class JsonPath {
|
|
|
54
57
|
return new JsonPath([...this.nodes, key], this._options);
|
|
55
58
|
}
|
|
56
59
|
/**
|
|
57
|
-
*
|
|
60
|
+
* Updates options
|
|
58
61
|
* @param options
|
|
59
62
|
* @returns new JsonPath instance
|
|
60
63
|
*/
|
|
@@ -69,7 +72,7 @@ export function isJsonPath(path) {
|
|
|
69
72
|
return parsePattern.test(path);
|
|
70
73
|
}
|
|
71
74
|
/**
|
|
72
|
-
*
|
|
75
|
+
* Encodes an array of nodes into a JSONPath
|
|
73
76
|
* @param nodes nodes to encode
|
|
74
77
|
* @param options encoding options
|
|
75
78
|
* @returns JSONPath string
|
|
@@ -106,7 +109,7 @@ export function encodeJsonPath(nodes, options = {}) {
|
|
|
106
109
|
return path.slice(1);
|
|
107
110
|
}
|
|
108
111
|
/**
|
|
109
|
-
*
|
|
112
|
+
* Decodes a JSONPath into its nodes. Only supports child operator
|
|
110
113
|
* @param path JSONPath string
|
|
111
114
|
* @returns array of nodes
|
|
112
115
|
* @example
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.59",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"koa": "^2.15",
|
|
146
146
|
"minio": "^7.1",
|
|
147
147
|
"mjml": "^4.15",
|
|
148
|
-
"mongodb": "^6.
|
|
148
|
+
"mongodb": "^6.4",
|
|
149
149
|
"nodemailer": "^6.9",
|
|
150
150
|
"playwright": "^1.42",
|
|
151
151
|
"preact": "^10.19",
|
|
@@ -7,7 +7,7 @@ import { memoizeSingle } from '../function/memoize.js';
|
|
|
7
7
|
* @returns referenced value
|
|
8
8
|
*/
|
|
9
9
|
export function compileDereferencer(reference) {
|
|
10
|
-
const nodes =
|
|
10
|
+
const nodes = JsonPath.from(reference).nodes;
|
|
11
11
|
function dereferencer(object) {
|
|
12
12
|
let target = object;
|
|
13
13
|
for (let i = 0; i < nodes.length; i++) { // eslint-disable-line @typescript-eslint/prefer-for-of
|