@vertesia/json 0.24.0-dev.202601221707
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/LICENSE +13 -0
- package/README.md +180 -0
- package/lib/cjs/index.js +19 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/types.js +3 -0
- package/lib/cjs/types.js.map +1 -0
- package/lib/cjs/walk.js +196 -0
- package/lib/cjs/walk.js.map +1 -0
- package/lib/esm/index.js +3 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/types.js +2 -0
- package/lib/esm/types.js.map +1 -0
- package/lib/esm/walk.js +191 -0
- package/lib/esm/walk.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/types.d.ts +7 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/walk.d.ts +33 -0
- package/lib/types/walk.d.ts.map +1 -0
- package/lib/vertesia-json.js +2 -0
- package/lib/vertesia-json.js.map +1 -0
- package/package.json +49 -0
- package/src/index.ts +2 -0
- package/src/types.ts +5 -0
- package/src/walk.test.ts +105 -0
- package/src/walk.ts +206 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2024 Composable
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# @vertesia/json
|
|
2
|
+
|
|
3
|
+
JSON utilities for TypeScript, including type definitions and object traversal with the visitor pattern.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **JSON Type Definitions**: Strict TypeScript types for JSON values
|
|
8
|
+
- **Object Walker**: Traverse nested objects and arrays using the visitor pattern
|
|
9
|
+
- **Async Support**: Async object walker for asynchronous operations during traversal
|
|
10
|
+
- **Map Function**: Transform object values while preserving structure
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @vertesia/json
|
|
16
|
+
# or
|
|
17
|
+
pnpm add @vertesia/json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### JSON Types
|
|
23
|
+
|
|
24
|
+
Strict TypeScript types for JSON values:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import type {
|
|
28
|
+
JSONPrimitive, // string | number | boolean | null
|
|
29
|
+
JSONArray, // JSONValue[]
|
|
30
|
+
JSONObject, // { [key: string]: JSONValue }
|
|
31
|
+
JSONComposite, // JSONArray | JSONObject
|
|
32
|
+
JSONValue // JSONPrimitive | JSONComposite
|
|
33
|
+
} from '@vertesia/json';
|
|
34
|
+
|
|
35
|
+
function processJson(data: JSONValue) {
|
|
36
|
+
// Type-safe JSON handling
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Object Walker
|
|
41
|
+
|
|
42
|
+
Traverse objects using the visitor pattern:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { ObjectWalker } from '@vertesia/json';
|
|
46
|
+
|
|
47
|
+
const data = {
|
|
48
|
+
name: 'John',
|
|
49
|
+
tags: ['admin', 'user'],
|
|
50
|
+
metadata: {
|
|
51
|
+
created: '2024-01-01',
|
|
52
|
+
count: 42
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const walker = new ObjectWalker();
|
|
57
|
+
|
|
58
|
+
walker.walk(data, {
|
|
59
|
+
onStartObject: (key, value) => {
|
|
60
|
+
console.log(`Start object: ${key}`);
|
|
61
|
+
},
|
|
62
|
+
onEndObject: (key, value) => {
|
|
63
|
+
console.log(`End object: ${key}`);
|
|
64
|
+
},
|
|
65
|
+
onStartIteration: (key, value) => {
|
|
66
|
+
console.log(`Start array: ${key}`);
|
|
67
|
+
},
|
|
68
|
+
onEndIteration: (key, value) => {
|
|
69
|
+
console.log(`End array: ${key}`);
|
|
70
|
+
},
|
|
71
|
+
onValue: (key, value) => {
|
|
72
|
+
console.log(`Value: ${key} = ${value}`);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Map Values
|
|
78
|
+
|
|
79
|
+
Transform values while preserving structure:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { ObjectWalker } from '@vertesia/json';
|
|
83
|
+
|
|
84
|
+
const data = {
|
|
85
|
+
name: 'John',
|
|
86
|
+
age: 30,
|
|
87
|
+
scores: [85, 90, 78]
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const walker = new ObjectWalker();
|
|
91
|
+
const result = walker.map(data, (key, value) => {
|
|
92
|
+
if (typeof value === 'number') {
|
|
93
|
+
return value * 2;
|
|
94
|
+
}
|
|
95
|
+
return value;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// result: { name: 'John', age: 60, scores: [170, 180, 156] }
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Async Object Walker
|
|
102
|
+
|
|
103
|
+
For asynchronous operations during traversal:
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import { AsyncObjectWalker } from '@vertesia/json';
|
|
107
|
+
|
|
108
|
+
const walker = new AsyncObjectWalker();
|
|
109
|
+
|
|
110
|
+
await walker.walk(data, {
|
|
111
|
+
onValue: async (key, value) => {
|
|
112
|
+
if (typeof value === 'string') {
|
|
113
|
+
await processString(value);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Async map
|
|
119
|
+
const result = await walker.map(data, async (key, value) => {
|
|
120
|
+
if (typeof value === 'string') {
|
|
121
|
+
return await translateText(value);
|
|
122
|
+
}
|
|
123
|
+
return value;
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Iterator Support
|
|
128
|
+
|
|
129
|
+
Enable support for iterables beyond arrays:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
const walker = new ObjectWalker(true); // Enable iterator support
|
|
133
|
+
|
|
134
|
+
const data = {
|
|
135
|
+
items: new Set([1, 2, 3])
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
walker.walk(data, {
|
|
139
|
+
onValue: (key, value) => {
|
|
140
|
+
console.log(key, value);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## API Reference
|
|
146
|
+
|
|
147
|
+
### Types
|
|
148
|
+
|
|
149
|
+
| Type | Description |
|
|
150
|
+
|------|-------------|
|
|
151
|
+
| `JSONPrimitive` | `string \| number \| boolean \| null` |
|
|
152
|
+
| `JSONArray` | `JSONValue[]` |
|
|
153
|
+
| `JSONObject` | `{ [key: string]: JSONValue }` |
|
|
154
|
+
| `JSONComposite` | `JSONArray \| JSONObject` |
|
|
155
|
+
| `JSONValue` | `JSONPrimitive \| JSONComposite` |
|
|
156
|
+
|
|
157
|
+
### ObjectWalker
|
|
158
|
+
|
|
159
|
+
| Method | Description |
|
|
160
|
+
|--------|-------------|
|
|
161
|
+
| `walk(obj, visitor)` | Traverse object with visitor callbacks |
|
|
162
|
+
| `map(obj, mapFn)` | Transform values while preserving structure |
|
|
163
|
+
|
|
164
|
+
### ObjectVisitor Callbacks
|
|
165
|
+
|
|
166
|
+
| Callback | Description |
|
|
167
|
+
|----------|-------------|
|
|
168
|
+
| `onStartObject(key, value)` | Called when entering an object |
|
|
169
|
+
| `onEndObject(key, value)` | Called when leaving an object |
|
|
170
|
+
| `onStartIteration(key, value)` | Called when entering an array/iterable |
|
|
171
|
+
| `onEndIteration(key, value)` | Called when leaving an array/iterable |
|
|
172
|
+
| `onValue(key, value)` | Called for primitive values |
|
|
173
|
+
|
|
174
|
+
### AsyncObjectWalker
|
|
175
|
+
|
|
176
|
+
Same API as `ObjectWalker` but all visitor callbacks and map functions return Promises.
|
|
177
|
+
|
|
178
|
+
## License
|
|
179
|
+
|
|
180
|
+
Apache-2.0
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types.js"), exports);
|
|
18
|
+
__exportStar(require("./walk.js"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,4CAAyB"}
|
package/lib/cjs/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/lib/cjs/walk.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncObjectWalker = exports.ObjectWalker = void 0;
|
|
4
|
+
class ObjectWalker {
|
|
5
|
+
supportIterators = false; // only array are supported by default
|
|
6
|
+
constructor(supportIterators = false) {
|
|
7
|
+
this.supportIterators = supportIterators;
|
|
8
|
+
}
|
|
9
|
+
walk(obj, visitor) {
|
|
10
|
+
this._walk(undefined, obj, visitor);
|
|
11
|
+
}
|
|
12
|
+
_walk(key, obj, visitor) {
|
|
13
|
+
const type = typeof obj;
|
|
14
|
+
if (!obj || type !== 'object' || obj instanceof Date) {
|
|
15
|
+
visitor.onValue && visitor.onValue(key, obj);
|
|
16
|
+
}
|
|
17
|
+
else if (Array.isArray(obj)) {
|
|
18
|
+
this._walkIterable(key, obj, visitor);
|
|
19
|
+
}
|
|
20
|
+
else if (this.supportIterators && obj[Symbol.iterator] === 'function') {
|
|
21
|
+
this._walkIterable(key, obj, visitor);
|
|
22
|
+
}
|
|
23
|
+
else if (obj.constructor === Object) { // a plain object
|
|
24
|
+
this._walkObject(key, obj, visitor);
|
|
25
|
+
}
|
|
26
|
+
else { // a random object - we treat it as a value
|
|
27
|
+
visitor.onValue && visitor.onValue(key, obj);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
_walkIterable(key, obj, visitor) {
|
|
31
|
+
visitor.onStartIteration && visitor.onStartIteration(key, obj);
|
|
32
|
+
let i = 0;
|
|
33
|
+
for (const value of obj) {
|
|
34
|
+
this._walk(i++, value, visitor);
|
|
35
|
+
}
|
|
36
|
+
visitor.onEndIteration && visitor.onEndIteration(key, obj);
|
|
37
|
+
}
|
|
38
|
+
_walkObject(key, obj, visitor) {
|
|
39
|
+
visitor.onStartObject && visitor.onStartObject(key, obj);
|
|
40
|
+
for (const k of Object.keys(obj)) {
|
|
41
|
+
this._walk(k, obj[k], visitor);
|
|
42
|
+
}
|
|
43
|
+
visitor.onEndObject && visitor.onEndObject(key, obj);
|
|
44
|
+
}
|
|
45
|
+
map(obj, mapFn) {
|
|
46
|
+
const visitor = new MapVisitor(mapFn);
|
|
47
|
+
this.walk(obj, visitor);
|
|
48
|
+
return visitor.result;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.ObjectWalker = ObjectWalker;
|
|
52
|
+
class AsyncObjectWalker {
|
|
53
|
+
supportIterators = false; // only array are supported by default
|
|
54
|
+
constructor(supportIterators = false) {
|
|
55
|
+
this.supportIterators = supportIterators;
|
|
56
|
+
}
|
|
57
|
+
async walk(obj, visitor) {
|
|
58
|
+
await this._walk(undefined, obj, visitor);
|
|
59
|
+
}
|
|
60
|
+
async _walk(key, obj, visitor) {
|
|
61
|
+
const type = typeof obj;
|
|
62
|
+
if (!obj || type !== 'object' || obj instanceof Date) {
|
|
63
|
+
visitor.onValue && (await visitor.onValue(key, obj));
|
|
64
|
+
}
|
|
65
|
+
else if (Array.isArray(obj)) {
|
|
66
|
+
await this._walkIterable(key, obj, visitor);
|
|
67
|
+
}
|
|
68
|
+
else if (this.supportIterators && obj[Symbol.iterator] === 'function') {
|
|
69
|
+
await this._walkIterable(key, obj, visitor);
|
|
70
|
+
}
|
|
71
|
+
else if (obj.constructor === Object) { // a plain object
|
|
72
|
+
await this._walkObject(key, obj, visitor);
|
|
73
|
+
}
|
|
74
|
+
else { // a random object - we treat it as a value
|
|
75
|
+
visitor.onValue && (await visitor.onValue(key, obj));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async _walkIterable(key, obj, visitor) {
|
|
79
|
+
visitor.onStartIteration && (await visitor.onStartIteration(key, obj));
|
|
80
|
+
let i = 0;
|
|
81
|
+
for (const value of obj) {
|
|
82
|
+
await this._walk(i++, value, visitor);
|
|
83
|
+
}
|
|
84
|
+
visitor.onEndIteration && (await visitor.onEndIteration(key, obj));
|
|
85
|
+
}
|
|
86
|
+
async _walkObject(key, obj, visitor) {
|
|
87
|
+
visitor.onStartObject && (await visitor.onStartObject(key, obj));
|
|
88
|
+
for (const k of Object.keys(obj)) {
|
|
89
|
+
await this._walk(k, obj[k], visitor);
|
|
90
|
+
}
|
|
91
|
+
visitor.onEndObject && (await visitor.onEndObject(key, obj));
|
|
92
|
+
}
|
|
93
|
+
async map(obj, mapFn) {
|
|
94
|
+
const visitor = new AsyncMapVisitor(mapFn);
|
|
95
|
+
await this.walk(obj, visitor);
|
|
96
|
+
return visitor.result;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.AsyncObjectWalker = AsyncObjectWalker;
|
|
100
|
+
class MapVisitor {
|
|
101
|
+
mapFn;
|
|
102
|
+
result;
|
|
103
|
+
current;
|
|
104
|
+
stack = [];
|
|
105
|
+
constructor(mapFn) {
|
|
106
|
+
this.mapFn = mapFn;
|
|
107
|
+
}
|
|
108
|
+
onStartObject(key) {
|
|
109
|
+
if (key === undefined) {
|
|
110
|
+
this.result = {};
|
|
111
|
+
this.current = this.result;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.stack.push(this.current);
|
|
115
|
+
const obj = {};
|
|
116
|
+
this.current[key] = obj;
|
|
117
|
+
this.current = obj;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
onEndObject() {
|
|
121
|
+
this.current = this.stack.pop();
|
|
122
|
+
}
|
|
123
|
+
onStartIteration(key) {
|
|
124
|
+
if (key === undefined) {
|
|
125
|
+
this.result = [];
|
|
126
|
+
this.current = this.result;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.stack.push(this.current);
|
|
130
|
+
const ar = [];
|
|
131
|
+
this.current[key] = ar;
|
|
132
|
+
this.current = ar;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
onEndIteration() {
|
|
136
|
+
this.current = this.stack.pop();
|
|
137
|
+
}
|
|
138
|
+
onValue(key, value) {
|
|
139
|
+
const r = this.mapFn(key, value);
|
|
140
|
+
if (key === undefined) {
|
|
141
|
+
this.result = r;
|
|
142
|
+
}
|
|
143
|
+
else if (r !== undefined) {
|
|
144
|
+
this.current[key] = r;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
class AsyncMapVisitor {
|
|
149
|
+
mapFn;
|
|
150
|
+
result;
|
|
151
|
+
current;
|
|
152
|
+
stack = [];
|
|
153
|
+
constructor(mapFn) {
|
|
154
|
+
this.mapFn = mapFn;
|
|
155
|
+
}
|
|
156
|
+
async onStartObject(key) {
|
|
157
|
+
if (key === undefined) {
|
|
158
|
+
this.result = {};
|
|
159
|
+
this.current = this.result;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this.stack.push(this.current);
|
|
163
|
+
const obj = {};
|
|
164
|
+
this.current[key] = obj;
|
|
165
|
+
this.current = obj;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async onEndObject() {
|
|
169
|
+
this.current = this.stack.pop();
|
|
170
|
+
}
|
|
171
|
+
async onStartIteration(key) {
|
|
172
|
+
if (key === undefined) {
|
|
173
|
+
this.result = [];
|
|
174
|
+
this.current = this.result;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
this.stack.push(this.current);
|
|
178
|
+
const ar = [];
|
|
179
|
+
this.current[key] = ar;
|
|
180
|
+
this.current = ar;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async onEndIteration() {
|
|
184
|
+
this.current = this.stack.pop();
|
|
185
|
+
}
|
|
186
|
+
async onValue(key, value) {
|
|
187
|
+
const r = await this.mapFn(key, value);
|
|
188
|
+
if (key === undefined) {
|
|
189
|
+
this.result = r;
|
|
190
|
+
}
|
|
191
|
+
else if (r !== undefined) {
|
|
192
|
+
this.current[key] = r;
|
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,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QACtB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc;QAChB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAc,EAAE,KAAU;QACpC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACvC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACpB,CAAC;aAAM,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACL,CAAC;CACJ"}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
package/lib/esm/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/lib/esm/walk.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
export class ObjectWalker {
|
|
2
|
+
supportIterators = false; // only array are supported by default
|
|
3
|
+
constructor(supportIterators = false) {
|
|
4
|
+
this.supportIterators = supportIterators;
|
|
5
|
+
}
|
|
6
|
+
walk(obj, visitor) {
|
|
7
|
+
this._walk(undefined, obj, visitor);
|
|
8
|
+
}
|
|
9
|
+
_walk(key, obj, visitor) {
|
|
10
|
+
const type = typeof obj;
|
|
11
|
+
if (!obj || type !== 'object' || obj instanceof Date) {
|
|
12
|
+
visitor.onValue && visitor.onValue(key, obj);
|
|
13
|
+
}
|
|
14
|
+
else if (Array.isArray(obj)) {
|
|
15
|
+
this._walkIterable(key, obj, visitor);
|
|
16
|
+
}
|
|
17
|
+
else if (this.supportIterators && obj[Symbol.iterator] === 'function') {
|
|
18
|
+
this._walkIterable(key, obj, visitor);
|
|
19
|
+
}
|
|
20
|
+
else if (obj.constructor === Object) { // a plain object
|
|
21
|
+
this._walkObject(key, obj, visitor);
|
|
22
|
+
}
|
|
23
|
+
else { // a random object - we treat it as a value
|
|
24
|
+
visitor.onValue && visitor.onValue(key, obj);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
_walkIterable(key, obj, visitor) {
|
|
28
|
+
visitor.onStartIteration && visitor.onStartIteration(key, obj);
|
|
29
|
+
let i = 0;
|
|
30
|
+
for (const value of obj) {
|
|
31
|
+
this._walk(i++, value, visitor);
|
|
32
|
+
}
|
|
33
|
+
visitor.onEndIteration && visitor.onEndIteration(key, obj);
|
|
34
|
+
}
|
|
35
|
+
_walkObject(key, obj, visitor) {
|
|
36
|
+
visitor.onStartObject && visitor.onStartObject(key, obj);
|
|
37
|
+
for (const k of Object.keys(obj)) {
|
|
38
|
+
this._walk(k, obj[k], visitor);
|
|
39
|
+
}
|
|
40
|
+
visitor.onEndObject && visitor.onEndObject(key, obj);
|
|
41
|
+
}
|
|
42
|
+
map(obj, mapFn) {
|
|
43
|
+
const visitor = new MapVisitor(mapFn);
|
|
44
|
+
this.walk(obj, visitor);
|
|
45
|
+
return visitor.result;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class AsyncObjectWalker {
|
|
49
|
+
supportIterators = false; // only array are supported by default
|
|
50
|
+
constructor(supportIterators = false) {
|
|
51
|
+
this.supportIterators = supportIterators;
|
|
52
|
+
}
|
|
53
|
+
async walk(obj, visitor) {
|
|
54
|
+
await this._walk(undefined, obj, visitor);
|
|
55
|
+
}
|
|
56
|
+
async _walk(key, obj, visitor) {
|
|
57
|
+
const type = typeof obj;
|
|
58
|
+
if (!obj || type !== 'object' || obj instanceof Date) {
|
|
59
|
+
visitor.onValue && (await visitor.onValue(key, obj));
|
|
60
|
+
}
|
|
61
|
+
else if (Array.isArray(obj)) {
|
|
62
|
+
await this._walkIterable(key, obj, visitor);
|
|
63
|
+
}
|
|
64
|
+
else if (this.supportIterators && obj[Symbol.iterator] === 'function') {
|
|
65
|
+
await this._walkIterable(key, obj, visitor);
|
|
66
|
+
}
|
|
67
|
+
else if (obj.constructor === Object) { // a plain object
|
|
68
|
+
await this._walkObject(key, obj, visitor);
|
|
69
|
+
}
|
|
70
|
+
else { // a random object - we treat it as a value
|
|
71
|
+
visitor.onValue && (await visitor.onValue(key, obj));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async _walkIterable(key, obj, visitor) {
|
|
75
|
+
visitor.onStartIteration && (await visitor.onStartIteration(key, obj));
|
|
76
|
+
let i = 0;
|
|
77
|
+
for (const value of obj) {
|
|
78
|
+
await this._walk(i++, value, visitor);
|
|
79
|
+
}
|
|
80
|
+
visitor.onEndIteration && (await visitor.onEndIteration(key, obj));
|
|
81
|
+
}
|
|
82
|
+
async _walkObject(key, obj, visitor) {
|
|
83
|
+
visitor.onStartObject && (await visitor.onStartObject(key, obj));
|
|
84
|
+
for (const k of Object.keys(obj)) {
|
|
85
|
+
await this._walk(k, obj[k], visitor);
|
|
86
|
+
}
|
|
87
|
+
visitor.onEndObject && (await visitor.onEndObject(key, obj));
|
|
88
|
+
}
|
|
89
|
+
async map(obj, mapFn) {
|
|
90
|
+
const visitor = new AsyncMapVisitor(mapFn);
|
|
91
|
+
await this.walk(obj, visitor);
|
|
92
|
+
return visitor.result;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
class MapVisitor {
|
|
96
|
+
mapFn;
|
|
97
|
+
result;
|
|
98
|
+
current;
|
|
99
|
+
stack = [];
|
|
100
|
+
constructor(mapFn) {
|
|
101
|
+
this.mapFn = mapFn;
|
|
102
|
+
}
|
|
103
|
+
onStartObject(key) {
|
|
104
|
+
if (key === undefined) {
|
|
105
|
+
this.result = {};
|
|
106
|
+
this.current = this.result;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.stack.push(this.current);
|
|
110
|
+
const obj = {};
|
|
111
|
+
this.current[key] = obj;
|
|
112
|
+
this.current = obj;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
onEndObject() {
|
|
116
|
+
this.current = this.stack.pop();
|
|
117
|
+
}
|
|
118
|
+
onStartIteration(key) {
|
|
119
|
+
if (key === undefined) {
|
|
120
|
+
this.result = [];
|
|
121
|
+
this.current = this.result;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.stack.push(this.current);
|
|
125
|
+
const ar = [];
|
|
126
|
+
this.current[key] = ar;
|
|
127
|
+
this.current = ar;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
onEndIteration() {
|
|
131
|
+
this.current = this.stack.pop();
|
|
132
|
+
}
|
|
133
|
+
onValue(key, value) {
|
|
134
|
+
const r = this.mapFn(key, value);
|
|
135
|
+
if (key === undefined) {
|
|
136
|
+
this.result = r;
|
|
137
|
+
}
|
|
138
|
+
else if (r !== undefined) {
|
|
139
|
+
this.current[key] = r;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
class AsyncMapVisitor {
|
|
144
|
+
mapFn;
|
|
145
|
+
result;
|
|
146
|
+
current;
|
|
147
|
+
stack = [];
|
|
148
|
+
constructor(mapFn) {
|
|
149
|
+
this.mapFn = mapFn;
|
|
150
|
+
}
|
|
151
|
+
async onStartObject(key) {
|
|
152
|
+
if (key === undefined) {
|
|
153
|
+
this.result = {};
|
|
154
|
+
this.current = this.result;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
this.stack.push(this.current);
|
|
158
|
+
const obj = {};
|
|
159
|
+
this.current[key] = obj;
|
|
160
|
+
this.current = obj;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async onEndObject() {
|
|
164
|
+
this.current = this.stack.pop();
|
|
165
|
+
}
|
|
166
|
+
async onStartIteration(key) {
|
|
167
|
+
if (key === undefined) {
|
|
168
|
+
this.result = [];
|
|
169
|
+
this.current = this.result;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
this.stack.push(this.current);
|
|
173
|
+
const ar = [];
|
|
174
|
+
this.current[key] = ar;
|
|
175
|
+
this.current = ar;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async onEndIteration() {
|
|
179
|
+
this.current = this.stack.pop();
|
|
180
|
+
}
|
|
181
|
+
async onValue(key, value) {
|
|
182
|
+
const r = await this.mapFn(key, value);
|
|
183
|
+
if (key === undefined) {
|
|
184
|
+
this.result = r;
|
|
185
|
+
}
|
|
186
|
+
else if (r !== undefined) {
|
|
187
|
+
this.current[key] = r;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=walk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.js","sourceRoot":"","sources":["../../src/walk.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAO,YAAY;IACrB,gBAAgB,GAAG,KAAK,CAAC,CAAC,sCAAsC;IAChE,YAAY,gBAAgB,GAAG,KAAK;QAChC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC7C,CAAC;IACD,IAAI,CAAC,GAAQ,EAAE,OAAsB;QACjC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,KAAK,CAAC,GAAc,EAAE,GAAQ,EAAE,OAAsB;QAClD,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC;QACxB,IAAI,CAAC,GAAG,IAAI,IAAI,KAAK,QAAQ,IAAI,GAAG,YAAY,IAAI,EAAE,CAAC;YACnD,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,EA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AG,CAAC;YACxB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;QACvB,CAAC;IACL,CAAC;IACD,KAAK,CAAC,WAAW;QACb,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,GAAc;QACjC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QAC/B,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC9B,MAAM,EAAE,GAAU,EAAE,CAAC;YACrB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QACtB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc;QAChB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAc,EAAE,KAAU;QACpC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACvC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACpB,CAAC;aAAM,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":["../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../src/types.ts","../src/walk.ts","../src/index.ts"],"fileIdsList":[[59,60]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"8cdf8847677ac7d20486e54dd3fcf09eda95812ac8ace44b4418da1bbbab6eb8","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"77fd9084330875ce8d85850944c9c6db299d45ccb2c9196cf45daa4311e5153d","signature":"308f734399e78e329dda3b455c3102f21c979bd5adc951db3c04c1bf1bcd72c9"},{"version":"5e457a59de3e8bb2643092c31fad40bdebe613f7701b837c3591fb6704048ab3","signature":"7449f98d329dcc1f475615678536ca3d224c828421b759f1a8cae2a4ba72160e"},{"version":"46d4f1e66c9fe74623c5063801587f2624852674e4efcdc1c310fd2432467ee4","signature":"1340a96c79b6f127c27d9bfc404b3f8e10c34a332538b10006ff17d47a4f1fa1"}],"root":[[59,61]],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declarationDir":"./types","esModuleInterop":true,"experimentalDecorators":true,"module":99,"noFallthroughCasesInSwitch":true,"noPropertyAccessFromIndexSignature":false,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./esm","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9,"useDefineForClassFields":true,"useUnknownInCatchVariables":true},"referencedMap":[[61,1]],"latestChangedDtsFile":"./types/index.d.ts","version":"5.9.3"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type JSONPrimitive = string | number | boolean | null;
|
|
2
|
+
export type JSONArray = JSONValue[];
|
|
3
|
+
export type JSONObject = {
|
|
4
|
+
[key: string]: JSONValue;
|
|
5
|
+
};
|
|
6
|
+
export type JSONComposite = JSONArray | JSONObject;
|
|
7
|
+
export type JSONValue = JSONPrimitive | JSONComposite;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AACpC,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AACtD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;AACnD,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type ObjectKey = string | number | undefined;
|
|
2
|
+
export interface ObjectVisitor {
|
|
3
|
+
onStartObject?: (key: ObjectKey, value: any) => void;
|
|
4
|
+
onEndObject?: (key: ObjectKey, value: any) => void;
|
|
5
|
+
onStartIteration?: (key: ObjectKey, value: Iterable<any>) => void;
|
|
6
|
+
onEndIteration?: (key: ObjectKey, value: Iterable<any>) => void;
|
|
7
|
+
onValue?: (key: ObjectKey, value: any) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface AsyncObjectVisitor {
|
|
10
|
+
onStartObject?: (key: ObjectKey, value: any) => Promise<void>;
|
|
11
|
+
onEndObject?: (key: ObjectKey, value: any) => Promise<void>;
|
|
12
|
+
onStartIteration?: (key: ObjectKey, value: Iterable<any>) => Promise<void>;
|
|
13
|
+
onEndIteration?: (key: ObjectKey, value: Iterable<any>) => Promise<void>;
|
|
14
|
+
onValue?: (key: ObjectKey, value: any) => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare class ObjectWalker {
|
|
17
|
+
supportIterators: boolean;
|
|
18
|
+
constructor(supportIterators?: boolean);
|
|
19
|
+
walk(obj: any, visitor: ObjectVisitor): void;
|
|
20
|
+
_walk(key: ObjectKey, obj: any, visitor: ObjectVisitor): void;
|
|
21
|
+
_walkIterable(key: ObjectKey, obj: any, visitor: ObjectVisitor): void;
|
|
22
|
+
_walkObject(key: ObjectKey, obj: any, visitor: ObjectVisitor): void;
|
|
23
|
+
map(obj: any, mapFn: (key: ObjectKey, value: any) => any): any;
|
|
24
|
+
}
|
|
25
|
+
export declare class AsyncObjectWalker {
|
|
26
|
+
supportIterators: boolean;
|
|
27
|
+
constructor(supportIterators?: boolean);
|
|
28
|
+
walk(obj: any, visitor: AsyncObjectVisitor): Promise<void>;
|
|
29
|
+
_walk(key: ObjectKey, obj: any, visitor: AsyncObjectVisitor): Promise<void>;
|
|
30
|
+
_walkIterable(key: ObjectKey, obj: any, visitor: AsyncObjectVisitor): Promise<void>;
|
|
31
|
+
_walkObject(key: ObjectKey, obj: any, visitor: AsyncObjectVisitor): Promise<void>;
|
|
32
|
+
map(obj: any, mapFn: (key: ObjectKey, value: any) => Promise<any>): Promise<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}_walk(t,s,r){!s||"object"!==typeof s||s instanceof Date?r.onValue&&r.onValue(t,s):Array.isArray(s)||this.supportIterators&&"function"===s[Symbol.iterator]?this._walkIterable(t,s,r):s.constructor===Object?this._walkObject(t,s,r):r.onValue&&r.onValue(t,s)}_walkIterable(t,s,r){r.onStartIteration&&r.onStartIteration(t,s);let a=0;for(const t of s)this._walk(a++,t,r);r.onEndIteration&&r.onEndIteration(t,s)}_walkObject(t,s,r){r.onStartObject&&r.onStartObject(t,s);for(const t of Object.keys(s))this._walk(t,s[t],r);r.onEndObject&&r.onEndObject(t,s)}map(t,s){const a=new r(s);return this.walk(t,a),a.result}}class s{constructor(t=!1){this.supportIterators=!1,this.supportIterators=t}async walk(t,s){await this._walk(void 0,t,s)}async _walk(t,s,r){!s||"object"!==typeof s||s instanceof Date?r.onValue&&await r.onValue(t,s):Array.isArray(s)||this.supportIterators&&"function"===s[Symbol.iterator]?await this._walkIterable(t,s,r):s.constructor===Object?await this._walkObject(t,s,r):r.onValue&&await r.onValue(t,s)}async _walkIterable(t,s,r){r.onStartIteration&&await r.onStartIteration(t,s);let a=0;for(const t of s)await this._walk(a++,t,r);r.onEndIteration&&await r.onEndIteration(t,s)}async _walkObject(t,s,r){r.onStartObject&&await r.onStartObject(t,s);for(const t of Object.keys(s))await this._walk(t,s[t],r);r.onEndObject&&await r.onEndObject(t,s)}async map(t,s){const r=new a(s);return await this.walk(t,r),r.result}}class r{constructor(t){this.mapFn=t,this.stack=[]}onStartObject(t){if(void 0===t)this.result={},this.current=this.result;else{this.stack.push(this.current);const s={};this.current[t]=s,this.current=s}}onEndObject(){this.current=this.stack.pop()}onStartIteration(t){if(void 0===t)this.result=[],this.current=this.result;else{this.stack.push(this.current);const s=[];this.current[t]=s,this.current=s}}onEndIteration(){this.current=this.stack.pop()}onValue(t,s){const r=this.mapFn(t,s);void 0===t?this.result=r:void 0!==r&&(this.current[t]=r)}}class a{constructor(t){this.mapFn=t,this.stack=[]}async onStartObject(t){if(void 0===t)this.result={},this.current=this.result;else{this.stack.push(this.current);const s={};this.current[t]=s,this.current=s}}async onEndObject(){this.current=this.stack.pop()}async onStartIteration(t){if(void 0===t)this.result=[],this.current=this.result;else{this.stack.push(this.current);const s=[];this.current[t]=s,this.current=s}}async onEndIteration(){this.current=this.stack.pop()}async onValue(t,s){const r=await this.mapFn(t,s);void 0===t?this.result=r:void 0!==r&&(this.current[t]=r)}}export{s as AsyncObjectWalker,t as ObjectWalker};
|
|
2
|
+
//# sourceMappingURL=vertesia-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertesia-json.js","sources":["../src/walk.ts"],"sourcesContent":[null],"names":["ObjectWalker","constructor","supportIterators","this","walk","obj","visitor","_walk","undefined","key","Date","onValue","Array","isArray","Symbol","iterator","_walkIterable","Object","_walkObject","onStartIteration","i","value","onEndIteration","onStartObject","k","keys","onEndObject","map","mapFn","MapVisitor","result","AsyncObjectWalker","AsyncMapVisitor","stack","current","push","pop","ar","r"],"mappings":"MAkBaA,EAET,WAAAC,CAAYC,GAAmB,GAD/BC,KAAAD,kBAAmB,EAEfC,KAAKD,iBAAmBA,CAC5B,CACA,IAAAE,CAAKC,EAAUC,GACXH,KAAKI,WAAMC,EAAWH,EAAKC,EAC/B,CACA,KAAAC,CAAME,EAAgBJ,EAAUC,IAEvBD,GAAgB,kBADDA,GACaA,aAAeK,KAC5CJ,EAAQK,SAAWL,EAAQK,QAAQF,EAAKJ,GACjCO,MAAMC,QAAQR,IAEdF,KAAKD,kBAA6C,aAAzBG,EAAIS,OAAOC,UAD3CZ,KAAKa,cAAcP,EAAKJ,EAAKC,GAGtBD,EAAIJ,cAAgBgB,OAC3Bd,KAAKe,YAAYT,EAAKJ,EAAKC,GAE3BA,EAAQK,SAAWL,EAAQK,QAAQF,EAAKJ,EAEhD,CAEA,aAAAW,CAAcP,EAAgBJ,EAAUC,GACpCA,EAAQa,kBAAoBb,EAAQa,iBAAiBV,EAAKJ,GAC1D,IAAIe,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AAyB,MAAAA,EADpBzB,KAAA8B,MAAe,EAC4D,CAE3E,mBAAMV,CAAcd,GAChB,QAAYD,IAARC,EACAN,KAAK2B,OAAS,CAAA,EACd3B,KAAK+B,QAAU/B,KAAK2B,WACjB,CACH3B,KAAK8B,MAAME,KAAKhC,KAAK+B,SACrB,MAAM7B,EAAM,CAAA,EACZF,KAAK+B,QAAQzB,GAAOJ,EACpBF,KAAK+B,QAAU7B,CACnB,CACJ,CACA,iBAAMqB,GACFvB,KAAK+B,QAAU/B,KAAK8B,MAAMG,KAC9B,CAEA,sBAAMjB,CAAiBV,GACnB,QAAYD,IAARC,EACAN,KAAK2B,OAAS,GACd3B,KAAK+B,QAAU/B,KAAK2B,WACjB,CACH3B,KAAK8B,MAAME,KAAKhC,KAAK+B,SACrB,MAAMG,EAAY,GAClBlC,KAAK+B,QAAQzB,GAAO4B,EACpBlC,KAAK+B,QAAUG,CACnB,CACJ,CAEA,oBAAMf,GACFnB,KAAK+B,QAAU/B,KAAK8B,MAAMG,KAC9B,CAEA,aAAMzB,CAAQF,EAAgBY,GAC1B,MAAMiB,QAAUnC,KAAKyB,MAAMnB,EAAKY,QACpBb,IAARC,EACAN,KAAK2B,OAASQ,OACD9B,IAAN8B,IACPnC,KAAK+B,QAAQzB,GAAO6B,EAE5B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vertesia/json",
|
|
3
|
+
"version": "0.24.0-dev.202601221707",
|
|
4
|
+
"description": "JSON utlities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./lib/types/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"exports": {
|
|
13
|
+
"types": "./lib/types/index.d.ts",
|
|
14
|
+
"import": "./lib/esm/index.js",
|
|
15
|
+
"require": "./lib/cjs/index.js"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
19
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
20
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
21
|
+
"rollup": "^4.40.2",
|
|
22
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
23
|
+
"ts-dual-module": "^0.6.3",
|
|
24
|
+
"typescript": "^5.9.3",
|
|
25
|
+
"vitest": "^4.0.16"
|
|
26
|
+
},
|
|
27
|
+
"ts_dual_module": {
|
|
28
|
+
"outDir": "lib"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/vertesia/composableai.git",
|
|
33
|
+
"directory": "packages/json"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"vertesia",
|
|
37
|
+
"json",
|
|
38
|
+
"utilities",
|
|
39
|
+
"walker",
|
|
40
|
+
"visitor",
|
|
41
|
+
"traverse",
|
|
42
|
+
"typescript"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"build": "pnpm exec tsmod build && pnpm exec rollup -c",
|
|
47
|
+
"clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
package/src/walk.test.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { ObjectWalker, AsyncObjectWalker } from "./walk.js";
|
|
3
|
+
|
|
4
|
+
describe('walk object', () => {
|
|
5
|
+
|
|
6
|
+
test('find string values', () => {
|
|
7
|
+
const obj = {
|
|
8
|
+
name: "foo",
|
|
9
|
+
age: 42,
|
|
10
|
+
children: [{
|
|
11
|
+
name: "bar",
|
|
12
|
+
age: 12,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "baz",
|
|
16
|
+
age: 15,
|
|
17
|
+
}],
|
|
18
|
+
folder: {
|
|
19
|
+
subfolder: {
|
|
20
|
+
name: "file",
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const values = ["foo", "bar", "baz", "file"].sort().join(',');
|
|
25
|
+
const found: string[] = [];
|
|
26
|
+
new ObjectWalker().walk(obj, {
|
|
27
|
+
onValue(key, value) {
|
|
28
|
+
if (typeof value === "string") {
|
|
29
|
+
found.push(value);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
expect(found.sort().join(',')).toBe(values);
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
test('map numbers to string values', () => {
|
|
37
|
+
const obj = {
|
|
38
|
+
name: "foo",
|
|
39
|
+
age: 42,
|
|
40
|
+
children: [{
|
|
41
|
+
name: "bar",
|
|
42
|
+
age: 12,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "baz",
|
|
46
|
+
age: 15,
|
|
47
|
+
}],
|
|
48
|
+
folder: {
|
|
49
|
+
subfolder: {
|
|
50
|
+
name: 123,
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const r = new ObjectWalker().map(obj, (_key, value) => {
|
|
55
|
+
if (typeof value === "number") {
|
|
56
|
+
return String(value)
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
});
|
|
60
|
+
expect(r.age).toBe("42");
|
|
61
|
+
expect(r.children[0].age).toBe("12");
|
|
62
|
+
expect(r.children[1].age).toBe("15");
|
|
63
|
+
expect(r.folder.subfolder.name).toBe("123");
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
test('map numbers in an array to string values', () => {
|
|
67
|
+
const obj = [123, { x: 1 }, { y: 2 }, { z: 3 }]
|
|
68
|
+
const r = new ObjectWalker().map(obj, (_key, value) => {
|
|
69
|
+
if (typeof value === "number") {
|
|
70
|
+
return String(value)
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
});
|
|
74
|
+
expect(r.length).toBe(4);
|
|
75
|
+
expect(r[0]).toBe("123");
|
|
76
|
+
expect(r[1].x).toBe("1");
|
|
77
|
+
expect(r[2].y).toBe("2");
|
|
78
|
+
expect(r[3].z).toBe("3");
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
test('async map', async () => {
|
|
82
|
+
const obj = { ar: [123, { x: 1 }, { y: { a: 1, b: [2] } }] };
|
|
83
|
+
const r: any = await new AsyncObjectWalker().map(obj, async (_key, value) => {
|
|
84
|
+
if (typeof value === "number") {
|
|
85
|
+
return new Promise((resolve) => {
|
|
86
|
+
return setTimeout(() => {
|
|
87
|
+
resolve(String(value));
|
|
88
|
+
}, 50);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return value;
|
|
92
|
+
});
|
|
93
|
+
expect(Array.isArray(r.ar)).toBe(true);
|
|
94
|
+
expect(r.ar.length).toBe(obj.ar.length);
|
|
95
|
+
expect(r.ar[0]).toBe("123");
|
|
96
|
+
expect(r.ar[1].x).toBe("1");
|
|
97
|
+
const y: any = r.ar[2].y;
|
|
98
|
+
expect(y.a).toBe("1");
|
|
99
|
+
console.log(y.b);
|
|
100
|
+
expect(Array.isArray(y.b)).toBe(true);
|
|
101
|
+
expect(y.b.length).toBe(1);
|
|
102
|
+
expect(y.b[0]).toBe("2");
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
})
|
package/src/walk.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
|
|
2
|
+
export type ObjectKey = string | number | undefined;
|
|
3
|
+
export interface ObjectVisitor {
|
|
4
|
+
onStartObject?: (key: ObjectKey, value: any) => void;
|
|
5
|
+
onEndObject?: (key: ObjectKey, value: any) => void;
|
|
6
|
+
onStartIteration?: (key: ObjectKey, value: Iterable<any>) => void;
|
|
7
|
+
onEndIteration?: (key: ObjectKey, value: Iterable<any>) => void;
|
|
8
|
+
onValue?: (key: ObjectKey, value: any) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AsyncObjectVisitor {
|
|
12
|
+
onStartObject?: (key: ObjectKey, value: any) => Promise<void>;
|
|
13
|
+
onEndObject?: (key: ObjectKey, value: any) => Promise<void>;
|
|
14
|
+
onStartIteration?: (key: ObjectKey, value: Iterable<any>) => Promise<void>;
|
|
15
|
+
onEndIteration?: (key: ObjectKey, value: Iterable<any>) => Promise<void>;
|
|
16
|
+
onValue?: (key: ObjectKey, value: any) => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class ObjectWalker {
|
|
20
|
+
supportIterators = false; // only array are supported by default
|
|
21
|
+
constructor(supportIterators = false) {
|
|
22
|
+
this.supportIterators = supportIterators;
|
|
23
|
+
}
|
|
24
|
+
walk(obj: any, visitor: ObjectVisitor) {
|
|
25
|
+
this._walk(undefined, obj, visitor);
|
|
26
|
+
}
|
|
27
|
+
_walk(key: ObjectKey, obj: any, visitor: ObjectVisitor) {
|
|
28
|
+
const type = typeof obj;
|
|
29
|
+
if (!obj || type !== 'object' || obj instanceof Date) {
|
|
30
|
+
visitor.onValue && visitor.onValue(key, obj);
|
|
31
|
+
} else if (Array.isArray(obj)) {
|
|
32
|
+
this._walkIterable(key, obj, visitor);
|
|
33
|
+
} else if (this.supportIterators && obj[Symbol.iterator] === 'function') {
|
|
34
|
+
this._walkIterable(key, obj, visitor);
|
|
35
|
+
} else if (obj.constructor === Object) { // a plain object
|
|
36
|
+
this._walkObject(key, obj, visitor);
|
|
37
|
+
} else { // a random object - we treat it as a value
|
|
38
|
+
visitor.onValue && visitor.onValue(key, obj);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_walkIterable(key: ObjectKey, obj: any, visitor: ObjectVisitor) {
|
|
43
|
+
visitor.onStartIteration && visitor.onStartIteration(key, obj);
|
|
44
|
+
let i = 0;
|
|
45
|
+
for (const value of obj) {
|
|
46
|
+
this._walk(i++, value, visitor);
|
|
47
|
+
}
|
|
48
|
+
visitor.onEndIteration && visitor.onEndIteration(key, obj);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_walkObject(key: ObjectKey, obj: any, visitor: ObjectVisitor) {
|
|
52
|
+
visitor.onStartObject && visitor.onStartObject(key, obj);
|
|
53
|
+
for (const k of Object.keys(obj)) {
|
|
54
|
+
this._walk(k, obj[k], visitor);
|
|
55
|
+
}
|
|
56
|
+
visitor.onEndObject && visitor.onEndObject(key, obj);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
map(obj: any, mapFn: (key: ObjectKey, value: any) => any) {
|
|
60
|
+
const visitor = new MapVisitor(mapFn);
|
|
61
|
+
this.walk(obj, visitor);
|
|
62
|
+
return visitor.result;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export class AsyncObjectWalker {
|
|
68
|
+
supportIterators = false; // only array are supported by default
|
|
69
|
+
constructor(supportIterators = false) {
|
|
70
|
+
this.supportIterators = supportIterators;
|
|
71
|
+
}
|
|
72
|
+
async walk(obj: any, visitor: AsyncObjectVisitor) {
|
|
73
|
+
await this._walk(undefined, obj, visitor);
|
|
74
|
+
}
|
|
75
|
+
async _walk(key: ObjectKey, obj: any, visitor: AsyncObjectVisitor) {
|
|
76
|
+
const type = typeof obj;
|
|
77
|
+
if (!obj || type !== 'object' || obj instanceof Date) {
|
|
78
|
+
visitor.onValue && (await visitor.onValue(key, obj));
|
|
79
|
+
} else if (Array.isArray(obj)) {
|
|
80
|
+
await this._walkIterable(key, obj, visitor);
|
|
81
|
+
} else if (this.supportIterators && obj[Symbol.iterator] === 'function') {
|
|
82
|
+
await this._walkIterable(key, obj, visitor);
|
|
83
|
+
} else if (obj.constructor === Object) { // a plain object
|
|
84
|
+
await this._walkObject(key, obj, visitor);
|
|
85
|
+
} else { // a random object - we treat it as a value
|
|
86
|
+
visitor.onValue && (await visitor.onValue(key, obj));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async _walkIterable(key: ObjectKey, obj: any, visitor: AsyncObjectVisitor) {
|
|
91
|
+
visitor.onStartIteration && (await visitor.onStartIteration(key, obj));
|
|
92
|
+
let i = 0;
|
|
93
|
+
for (const value of obj) {
|
|
94
|
+
await this._walk(i++, value, visitor);
|
|
95
|
+
}
|
|
96
|
+
visitor.onEndIteration && (await visitor.onEndIteration(key, obj));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async _walkObject(key: ObjectKey, obj: any, visitor: AsyncObjectVisitor) {
|
|
100
|
+
visitor.onStartObject && (await visitor.onStartObject(key, obj));
|
|
101
|
+
for (const k of Object.keys(obj)) {
|
|
102
|
+
await this._walk(k, obj[k], visitor);
|
|
103
|
+
}
|
|
104
|
+
visitor.onEndObject && (await visitor.onEndObject(key, obj));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async map(obj: any, mapFn: (key: ObjectKey, value: any) => Promise<any>) {
|
|
108
|
+
const visitor = new AsyncMapVisitor(mapFn);
|
|
109
|
+
await this.walk(obj, visitor);
|
|
110
|
+
return visitor.result;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class MapVisitor implements ObjectVisitor {
|
|
115
|
+
result: any;
|
|
116
|
+
current: any;
|
|
117
|
+
stack: any[] = [];
|
|
118
|
+
constructor(private mapFn: (key: ObjectKey, value: any) => any) { }
|
|
119
|
+
|
|
120
|
+
onStartObject(key: ObjectKey) {
|
|
121
|
+
if (key === undefined) {
|
|
122
|
+
this.result = {};
|
|
123
|
+
this.current = this.result;
|
|
124
|
+
} else {
|
|
125
|
+
this.stack.push(this.current);
|
|
126
|
+
const obj = {};
|
|
127
|
+
this.current[key] = obj;
|
|
128
|
+
this.current = obj;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
onEndObject() {
|
|
132
|
+
this.current = this.stack.pop();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
onStartIteration(key: ObjectKey) {
|
|
136
|
+
if (key === undefined) {
|
|
137
|
+
this.result = [];
|
|
138
|
+
this.current = this.result;
|
|
139
|
+
} else {
|
|
140
|
+
this.stack.push(this.current);
|
|
141
|
+
const ar: any[] = [];
|
|
142
|
+
this.current[key] = ar;
|
|
143
|
+
this.current = ar;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
onEndIteration() {
|
|
148
|
+
this.current = this.stack.pop();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
onValue(key: ObjectKey, value: any) {
|
|
152
|
+
const r = this.mapFn(key, value);
|
|
153
|
+
if (key === undefined) {
|
|
154
|
+
this.result = r;
|
|
155
|
+
} else if (r !== undefined) {
|
|
156
|
+
this.current[key] = r;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
class AsyncMapVisitor implements AsyncObjectVisitor {
|
|
162
|
+
result: any;
|
|
163
|
+
current: any;
|
|
164
|
+
stack: any[] = [];
|
|
165
|
+
constructor(private mapFn: (key: ObjectKey, value: any) => Promise<any>) { }
|
|
166
|
+
|
|
167
|
+
async onStartObject(key: ObjectKey) {
|
|
168
|
+
if (key === undefined) {
|
|
169
|
+
this.result = {};
|
|
170
|
+
this.current = this.result;
|
|
171
|
+
} else {
|
|
172
|
+
this.stack.push(this.current);
|
|
173
|
+
const obj = {};
|
|
174
|
+
this.current[key] = obj;
|
|
175
|
+
this.current = obj;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async onEndObject() {
|
|
179
|
+
this.current = this.stack.pop();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async onStartIteration(key: ObjectKey) {
|
|
183
|
+
if (key === undefined) {
|
|
184
|
+
this.result = [];
|
|
185
|
+
this.current = this.result;
|
|
186
|
+
} else {
|
|
187
|
+
this.stack.push(this.current);
|
|
188
|
+
const ar: any[] = [];
|
|
189
|
+
this.current[key] = ar;
|
|
190
|
+
this.current = ar;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async onEndIteration() {
|
|
195
|
+
this.current = this.stack.pop();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async onValue(key: ObjectKey, value: any) {
|
|
199
|
+
const r = await this.mapFn(key, value);
|
|
200
|
+
if (key === undefined) {
|
|
201
|
+
this.result = r;
|
|
202
|
+
} else if (r !== undefined) {
|
|
203
|
+
this.current[key] = r;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|