xypriss 9.12.49 → 9.12.52
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/dist/cjs/src/xhsc/utils/ObjectUtils.js +146 -486
- package/dist/cjs/src/xhsc/utils/ObjectUtils.js.map +1 -1
- package/dist/cjs/src/xhsc/utils/ObjectWrapper.js +672 -0
- package/dist/cjs/src/xhsc/utils/ObjectWrapper.js.map +1 -0
- package/dist/esm/src/xhsc/utils/ObjectUtils.js +146 -485
- package/dist/esm/src/xhsc/utils/ObjectUtils.js.map +1 -1
- package/dist/esm/src/xhsc/utils/ObjectWrapper.js +670 -0
- package/dist/esm/src/xhsc/utils/ObjectWrapper.js.map +1 -0
- package/dist/index.d.ts +307 -41
- package/package.json +1 -1
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var xyprissSecurity = require('xypriss-security');
|
|
4
|
+
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
class ObjectWrapper {
|
|
7
|
+
constructor(obj) {
|
|
8
|
+
this.current = obj;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* **value**
|
|
12
|
+
*
|
|
13
|
+
* Unwraps and returns the underlying plain object held by this wrapper.
|
|
14
|
+
* Call this at the end of a chain to get back a normal object.
|
|
15
|
+
*
|
|
16
|
+
* @returns The current wrapped object.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const obj = __sys__.utils.obj.of({ a: 1 });
|
|
21
|
+
* obj.value(); // { a: 1 }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
value() {
|
|
25
|
+
return this.current;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* **raw**
|
|
29
|
+
*
|
|
30
|
+
* Alias for {@link value}. Useful when `value` reads awkwardly in context.
|
|
31
|
+
*
|
|
32
|
+
* @returns The current wrapped object.
|
|
33
|
+
*/
|
|
34
|
+
raw() {
|
|
35
|
+
return this.current;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* **clone**
|
|
39
|
+
*
|
|
40
|
+
* Deep-clones the wrapped object (via `XStringify`) and continues
|
|
41
|
+
* the chain on the cloned copy, leaving the original untouched.
|
|
42
|
+
*
|
|
43
|
+
* @returns `this`, now wrapping a deep copy of the previous value.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const source = { nested: { count: 1 } };
|
|
48
|
+
* const obj = __sys__.utils.obj.of(source).clone();
|
|
49
|
+
* obj.value().nested.count = 99;
|
|
50
|
+
* // source.nested.count is still 1
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
clone() {
|
|
54
|
+
this.current = JSON.parse(xyprissSecurity.XStringify(this.current));
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* **pick**
|
|
59
|
+
*
|
|
60
|
+
* Narrows the wrapped object down to only the given keys.
|
|
61
|
+
*
|
|
62
|
+
* @param keys - The keys to keep.
|
|
63
|
+
* @returns `this`, now wrapping only the picked keys.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* __sys__.utils.obj.of({ a: 1, b: 2, c: 3 }).pick(["a", "c"]).value();
|
|
68
|
+
* // { a: 1, c: 3 }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
pick(keys) {
|
|
72
|
+
const result = keys.reduce((acc, key) => {
|
|
73
|
+
if (key in this.current)
|
|
74
|
+
acc[key] = this.current[key];
|
|
75
|
+
return acc;
|
|
76
|
+
}, {});
|
|
77
|
+
return new ObjectWrapper(result);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* **deepPick**
|
|
81
|
+
*
|
|
82
|
+
* Extracts a subset of the wrapped object using dot-notation paths,
|
|
83
|
+
* preserving the original nested structure. Paths that do not exist
|
|
84
|
+
* in the object are silently ignored.
|
|
85
|
+
*
|
|
86
|
+
* @param paths - Dot-notation paths to extract (e.g. `"a.b.c"`).
|
|
87
|
+
* @param separator - Path separator (default: `"."`)
|
|
88
|
+
* @returns A new wrapper around the extracted nested object.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const data = {
|
|
93
|
+
* user: { name: "Alice", age: 30, password: "secret" },
|
|
94
|
+
* meta: { created: "2024-01-01", version: 2 },
|
|
95
|
+
* };
|
|
96
|
+
*
|
|
97
|
+
* __sys__.utils.obj
|
|
98
|
+
* .of(data)
|
|
99
|
+
* .deepPick(["user.name", "user.age", "meta.version"])
|
|
100
|
+
* .value();
|
|
101
|
+
* // { user: { name: "Alice", age: 30 }, meta: { version: 2 } }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
deepPick(paths, separator) {
|
|
105
|
+
const sep = separator ?? ".";
|
|
106
|
+
const result = {};
|
|
107
|
+
for (const path of paths) {
|
|
108
|
+
const parts = path.split(sep);
|
|
109
|
+
let src = this.current;
|
|
110
|
+
let dst = result;
|
|
111
|
+
for (let i = 0; i < parts.length; i++) {
|
|
112
|
+
const part = parts[i];
|
|
113
|
+
if (src === null || src === undefined || !(part in src)) {
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
if (i === parts.length - 1) {
|
|
117
|
+
dst[part] = src[part];
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
if (typeof dst[part] !== "object" ||
|
|
121
|
+
dst[part] === null ||
|
|
122
|
+
Array.isArray(dst[part])) {
|
|
123
|
+
dst[part] = {};
|
|
124
|
+
}
|
|
125
|
+
dst = dst[part];
|
|
126
|
+
src = src[part];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return new ObjectWrapper(result);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* **omit**
|
|
134
|
+
*
|
|
135
|
+
* Removes the given keys from the wrapped object.
|
|
136
|
+
*
|
|
137
|
+
* @param keys - The keys to remove.
|
|
138
|
+
* @returns `this`, now wrapping the object without those keys.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* __sys__.utils.obj.of({ a: 1, b: 2, c: 3 }).omit(["b"]).value();
|
|
143
|
+
* // { a: 1, c: 3 }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
omit(keys) {
|
|
147
|
+
const result = { ...this.current };
|
|
148
|
+
keys.forEach((key) => delete result[key]);
|
|
149
|
+
return new ObjectWrapper(result);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* **isEmpty**
|
|
153
|
+
*
|
|
154
|
+
* Checks whether the wrapped object has no own enumerable keys.
|
|
155
|
+
* This is a terminal read (does not return the wrapper), since it
|
|
156
|
+
* yields a boolean rather than an object.
|
|
157
|
+
*
|
|
158
|
+
* @returns `true` if the object has no own keys.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* __sys__.utils.obj.of({}).isEmpty(); // true
|
|
163
|
+
* __sys__.utils.obj.of({ a: 1 }).isEmpty(); // false
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
isEmpty() {
|
|
167
|
+
return Object.keys(this.current).length === 0;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* **hasEmpty / hasAnyEmpty**
|
|
171
|
+
*
|
|
172
|
+
* Checks whether at least one property value in the object is empty
|
|
173
|
+
* (`undefined`, `null`, `""` empty/whitespace string, empty `[]`, or empty `{}`).
|
|
174
|
+
* If an optional list of `keys` is provided, only those keys will be inspected.
|
|
175
|
+
*
|
|
176
|
+
* @param keys - Optional array of specific keys to inspect. If omitted, all own keys are checked.
|
|
177
|
+
* @param options - Optional configuration (e.g. `trim: boolean`).
|
|
178
|
+
* @returns `true` if at least one value is empty/undefined, `false` otherwise.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* const contact = __sys__.utils.obj.of({ name: "Alice", phone: undefined, email: "" });
|
|
183
|
+
* contact.hasEmpty(); // true (phone is undefined, email is empty)
|
|
184
|
+
* contact.hasEmpty(["name"]); // false (name is defined and non-empty)
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
hasEmpty(keys, options = { trim: true }) {
|
|
188
|
+
const targetKeys = keys && keys.length > 0 ? keys : Object.keys(this.current);
|
|
189
|
+
if (targetKeys.length === 0)
|
|
190
|
+
return true;
|
|
191
|
+
const isValueEmpty = (val) => {
|
|
192
|
+
if (val === undefined || val === null)
|
|
193
|
+
return true;
|
|
194
|
+
if (typeof val === "string") {
|
|
195
|
+
return options.trim !== false ? val.trim().length === 0 : val.length === 0;
|
|
196
|
+
}
|
|
197
|
+
if (Array.isArray(val))
|
|
198
|
+
return val.length === 0;
|
|
199
|
+
if (typeof val === "object") {
|
|
200
|
+
if (val instanceof Date || val instanceof RegExp)
|
|
201
|
+
return false;
|
|
202
|
+
return Object.keys(val).length === 0;
|
|
203
|
+
}
|
|
204
|
+
return false;
|
|
205
|
+
};
|
|
206
|
+
return targetKeys.some((k) => isValueEmpty(this.current[k]));
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* **hasAnyEmpty**
|
|
210
|
+
*
|
|
211
|
+
* Alias for {@link hasEmpty}. Returns `true` if at least one property value
|
|
212
|
+
* is `undefined`, `null`, empty string, empty array, or empty object.
|
|
213
|
+
*/
|
|
214
|
+
hasAnyEmpty(keys, options) {
|
|
215
|
+
return this.hasEmpty(keys, options);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* **isAllEmpty**
|
|
219
|
+
*
|
|
220
|
+
* Checks whether **all** property values in the object are empty
|
|
221
|
+
* (`undefined`, `null`, `""` empty/whitespace string, empty `[]`, or empty `{}`).
|
|
222
|
+
* If the object has no keys, returns `true`.
|
|
223
|
+
*
|
|
224
|
+
* @param keys - Optional array of specific keys to inspect.
|
|
225
|
+
* @param options - Optional configuration (e.g. `trim: boolean`).
|
|
226
|
+
* @returns `true` if all inspected values are empty/undefined, `false` otherwise.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* __sys__.utils.obj.of({ a: undefined, b: "", c: null }).isAllEmpty(); // true
|
|
231
|
+
* __sys__.utils.obj.of({ a: "value", b: "" }).isAllEmpty(); // false
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
isAllEmpty(keys, options = { trim: true }) {
|
|
235
|
+
const targetKeys = keys && keys.length > 0 ? keys : Object.keys(this.current);
|
|
236
|
+
if (targetKeys.length === 0)
|
|
237
|
+
return true;
|
|
238
|
+
const isValueEmpty = (val) => {
|
|
239
|
+
if (val === undefined || val === null)
|
|
240
|
+
return true;
|
|
241
|
+
if (typeof val === "string") {
|
|
242
|
+
return options.trim !== false ? val.trim().length === 0 : val.length === 0;
|
|
243
|
+
}
|
|
244
|
+
if (Array.isArray(val))
|
|
245
|
+
return val.length === 0;
|
|
246
|
+
if (typeof val === "object") {
|
|
247
|
+
if (val instanceof Date || val instanceof RegExp)
|
|
248
|
+
return false;
|
|
249
|
+
return Object.keys(val).length === 0;
|
|
250
|
+
}
|
|
251
|
+
return false;
|
|
252
|
+
};
|
|
253
|
+
return targetKeys.every((k) => isValueEmpty(this.current[k]));
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* **hasAny / hasAnyValue / hasPresent**
|
|
257
|
+
*
|
|
258
|
+
* Checks whether **at least one** property value in the object is present and non-empty
|
|
259
|
+
* (not `undefined`, not `null`, not `""` empty string, not empty `[]`, and not empty `{}`).
|
|
260
|
+
*
|
|
261
|
+
* This is the exact inverse of {@link isAllEmpty}.
|
|
262
|
+
*
|
|
263
|
+
* @param keys - Optional array of specific keys to inspect.
|
|
264
|
+
* @param options - Optional configuration (e.g. `trim: boolean`).
|
|
265
|
+
* @returns `true` if at least one property is non-empty.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* const contact = __sys__.utils.obj.of({ name: undefined, phone: "+225010203", email: "" });
|
|
270
|
+
* contact.hasAny(); // true (phone is filled)
|
|
271
|
+
*
|
|
272
|
+
* const emptyContact = __sys__.utils.obj.of({ name: undefined, phone: "", email: null });
|
|
273
|
+
* emptyContact.hasAny(); // false (all fields empty)
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
hasAny(keys, options = { trim: true }) {
|
|
277
|
+
return !this.isAllEmpty(keys, options);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* **hasAnyValue**
|
|
281
|
+
*
|
|
282
|
+
* Alias for {@link hasAny}.
|
|
283
|
+
*/
|
|
284
|
+
hasAnyValue(keys, options) {
|
|
285
|
+
return this.hasAny(keys, options);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* **hasNonNull**
|
|
289
|
+
*
|
|
290
|
+
* Checks whether **at least one** property in the object is not `null` and not `undefined`.
|
|
291
|
+
* (Allows empty strings `""`, `[]` or `{}` as long as the value is defined and not `null`).
|
|
292
|
+
*
|
|
293
|
+
* @param keys - Optional array of specific keys to inspect.
|
|
294
|
+
* @returns `true` if at least one property is not null and not undefined.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```ts
|
|
298
|
+
* __sys__.utils.obj.of({ a: undefined, b: null, c: "" }).hasNonNull(); // true (c is "")
|
|
299
|
+
* __sys__.utils.obj.of({ a: undefined, b: null }).hasNonNull(); // false
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
hasNonNull(keys) {
|
|
303
|
+
const targetKeys = keys && keys.length > 0 ? keys : Object.keys(this.current);
|
|
304
|
+
if (targetKeys.length === 0)
|
|
305
|
+
return false;
|
|
306
|
+
return targetKeys.some((k) => this.current[k] !== null && this.current[k] !== undefined);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* **isAllNonNull**
|
|
310
|
+
*
|
|
311
|
+
* Checks whether **all** properties in the object are not `null` and not `undefined`.
|
|
312
|
+
*
|
|
313
|
+
* @param keys - Optional array of specific keys to inspect.
|
|
314
|
+
* @returns `true` if all properties are not null and not undefined.
|
|
315
|
+
*/
|
|
316
|
+
isAllNonNull(keys) {
|
|
317
|
+
const targetKeys = keys && keys.length > 0 ? keys : Object.keys(this.current);
|
|
318
|
+
if (targetKeys.length === 0)
|
|
319
|
+
return true;
|
|
320
|
+
return targetKeys.every((k) => this.current[k] !== null && this.current[k] !== undefined);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* **hasUndefined**
|
|
324
|
+
*
|
|
325
|
+
* Checks whether at least one property value in the object is strictly `undefined` or missing.
|
|
326
|
+
*
|
|
327
|
+
* @param keys - Optional array of specific keys to inspect.
|
|
328
|
+
* @returns `true` if at least one value is `undefined`.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* __sys__.utils.obj.of({ a: "ok", b: undefined }).hasUndefined(); // true
|
|
333
|
+
* __sys__.utils.obj.of({ a: "ok", b: null }).hasUndefined(); // false
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
hasUndefined(keys) {
|
|
337
|
+
const targetKeys = keys && keys.length > 0 ? keys : Object.keys(this.current);
|
|
338
|
+
if (targetKeys.length === 0)
|
|
339
|
+
return true;
|
|
340
|
+
return targetKeys.some((k) => this.current[k] === undefined);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* **compact**
|
|
344
|
+
*
|
|
345
|
+
* Returns a new {@link ObjectWrapper} with all `undefined`, `null`, and empty string
|
|
346
|
+
* properties removed from the wrapped object.
|
|
347
|
+
*
|
|
348
|
+
* @param options - Optional configuration (e.g. `trim: boolean`).
|
|
349
|
+
* @returns A new wrapper around the cleaned object.
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```ts
|
|
353
|
+
* __sys__.utils.obj.of({ name: "Alice", email: "", phone: undefined, notes: null })
|
|
354
|
+
* .compact()
|
|
355
|
+
* .value();
|
|
356
|
+
* // { name: "Alice" }
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
compact(options = { trim: true }) {
|
|
360
|
+
const result = {};
|
|
361
|
+
for (const key of Object.keys(this.current)) {
|
|
362
|
+
const val = this.current[key];
|
|
363
|
+
if (val === undefined || val === null)
|
|
364
|
+
continue;
|
|
365
|
+
if (typeof val === "string") {
|
|
366
|
+
const isEmptyStr = options.trim !== false ? val.trim().length === 0 : val.length === 0;
|
|
367
|
+
if (isEmptyStr)
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
result[key] = val;
|
|
371
|
+
}
|
|
372
|
+
return new ObjectWrapper(result);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* **flatten**
|
|
376
|
+
*
|
|
377
|
+
* Collapses the wrapped object's nested structure into flat
|
|
378
|
+
* dot-notation (or custom separator) keys.
|
|
379
|
+
*
|
|
380
|
+
* @param separator - Path separator (default: `"."`).
|
|
381
|
+
* @returns A new wrapper around the flattened object.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```ts
|
|
385
|
+
* __sys__.utils.obj.of({ a: { b: 1 } }).flatten().value();
|
|
386
|
+
* // { "a.b": 1 }
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
flatten(separator = ".") {
|
|
390
|
+
const result = {};
|
|
391
|
+
const recurse = (current, path = "") => {
|
|
392
|
+
for (const [key, val] of Object.entries(current)) {
|
|
393
|
+
const newPath = path ? `${path}${separator}${key}` : key;
|
|
394
|
+
if (val &&
|
|
395
|
+
typeof val === "object" &&
|
|
396
|
+
!Array.isArray(val) &&
|
|
397
|
+
Object.keys(val).length > 0) {
|
|
398
|
+
recurse(val, newPath);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
result[newPath] = val;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
recurse(this.current);
|
|
406
|
+
return new ObjectWrapper(result);
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* **unflatten**
|
|
410
|
+
*
|
|
411
|
+
* Reverses {@link flatten}, expanding dot-notation (or custom
|
|
412
|
+
* separator) keys back into a nested object.
|
|
413
|
+
*
|
|
414
|
+
* @param separator - Path separator used in the flat keys (default: `"."`).
|
|
415
|
+
* @returns A new wrapper around the nested object.
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```ts
|
|
419
|
+
* __sys__.utils.obj.of({ "a.b": 1, "a.c": 2 }).unflatten().value();
|
|
420
|
+
* // { a: { b: 1, c: 2 } }
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
unflatten(separator = ".") {
|
|
424
|
+
const result = {};
|
|
425
|
+
for (const [flatKey, val] of Object.entries(this.current)) {
|
|
426
|
+
const parts = flatKey.split(separator);
|
|
427
|
+
let cursor = result;
|
|
428
|
+
parts.forEach((part, i) => {
|
|
429
|
+
if (i === parts.length - 1) {
|
|
430
|
+
cursor[part] = val;
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
if (typeof cursor[part] !== "object" ||
|
|
434
|
+
cursor[part] === null) {
|
|
435
|
+
cursor[part] = {};
|
|
436
|
+
}
|
|
437
|
+
cursor = cursor[part];
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
return new ObjectWrapper(result);
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* **merge**
|
|
445
|
+
*
|
|
446
|
+
* Deep-merges one or more source objects into the wrapped object.
|
|
447
|
+
* Plain object values are merged recursively; arrays and primitives
|
|
448
|
+
* are overwritten by the last source that defines them.
|
|
449
|
+
*
|
|
450
|
+
* @param sources - One or more partial objects to merge in.
|
|
451
|
+
* @returns `this`, now wrapping the merged result.
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```ts
|
|
455
|
+
* __sys__.utils.obj.of({ a: 1, nested: { x: 1 } })
|
|
456
|
+
* .merge({ nested: { y: 2 } })
|
|
457
|
+
* .value();
|
|
458
|
+
* // { a: 1, nested: { x: 1, y: 2 } }
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
merge(...sources) {
|
|
462
|
+
const isPlainObject = (val) => !!val && typeof val === "object" && !Array.isArray(val);
|
|
463
|
+
const deepMerge = (target, source) => {
|
|
464
|
+
for (const key of Object.keys(source)) {
|
|
465
|
+
if (isPlainObject(source[key]) && isPlainObject(target[key])) {
|
|
466
|
+
deepMerge(target[key], source[key]);
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
target[key] = source[key];
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return target;
|
|
473
|
+
};
|
|
474
|
+
this.current = sources.reduce((acc, src) => deepMerge(acc, src), this.current);
|
|
475
|
+
return this;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* **mapValues**
|
|
479
|
+
*
|
|
480
|
+
* Transforms every value of the wrapped object using `fn`, keeping
|
|
481
|
+
* the same keys.
|
|
482
|
+
*
|
|
483
|
+
* @param fn - Mapping function receiving `(value, key)`.
|
|
484
|
+
* @returns A new wrapper around the transformed object.
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* ```ts
|
|
488
|
+
* __sys__.utils.obj.of({ a: 1, b: 2 }).mapValues((v) => v * 10).value();
|
|
489
|
+
* // { a: 10, b: 20 }
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
mapValues(fn) {
|
|
493
|
+
const result = {};
|
|
494
|
+
for (const key of Object.keys(this.current)) {
|
|
495
|
+
result[key] = fn(this.current[key], key);
|
|
496
|
+
}
|
|
497
|
+
return new ObjectWrapper(result);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* **mapKeys**
|
|
501
|
+
*
|
|
502
|
+
* Transforms every key of the wrapped object using `fn`, keeping
|
|
503
|
+
* the same values.
|
|
504
|
+
*
|
|
505
|
+
* @param fn - Mapping function receiving `(key, value)`. Must return a string.
|
|
506
|
+
* @returns A new wrapper around the object with renamed keys.
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* ```ts
|
|
510
|
+
* __sys__.utils.obj.of({ a: 1, b: 2 })
|
|
511
|
+
* .mapKeys((k) => k.toUpperCase())
|
|
512
|
+
* .value();
|
|
513
|
+
* // { A: 1, B: 2 }
|
|
514
|
+
* ```
|
|
515
|
+
*/
|
|
516
|
+
mapKeys(fn) {
|
|
517
|
+
const result = {};
|
|
518
|
+
for (const key of Object.keys(this.current)) {
|
|
519
|
+
result[fn(key, this.current[key])] = this.current[key];
|
|
520
|
+
}
|
|
521
|
+
return new ObjectWrapper(result);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* **filter**
|
|
525
|
+
*
|
|
526
|
+
* Keeps only the key-value pairs for which `predicate` returns `true`.
|
|
527
|
+
*
|
|
528
|
+
* @param predicate - Function receiving `(value, key)`.
|
|
529
|
+
* @returns A new wrapper around the filtered object.
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* ```ts
|
|
533
|
+
* __sys__.utils.obj.of({ a: 1, b: 2, c: 3 })
|
|
534
|
+
* .filter((v) => v > 1)
|
|
535
|
+
* .value();
|
|
536
|
+
* // { b: 2, c: 3 }
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
filter(predicate) {
|
|
540
|
+
const result = {};
|
|
541
|
+
for (const key of Object.keys(this.current)) {
|
|
542
|
+
if (predicate(this.current[key], key)) {
|
|
543
|
+
result[key] = this.current[key];
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return new ObjectWrapper(result);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* **keys**
|
|
550
|
+
*
|
|
551
|
+
* Returns the own enumerable keys of the wrapped object.
|
|
552
|
+
* This is a terminal read.
|
|
553
|
+
*
|
|
554
|
+
* @returns Array of keys.
|
|
555
|
+
*/
|
|
556
|
+
keys() {
|
|
557
|
+
return Object.keys(this.current);
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* **values**
|
|
561
|
+
*
|
|
562
|
+
* Returns the own enumerable values of the wrapped object.
|
|
563
|
+
* This is a terminal read.
|
|
564
|
+
*
|
|
565
|
+
* @returns Array of values.
|
|
566
|
+
*/
|
|
567
|
+
values() {
|
|
568
|
+
return Object.values(this.current);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* **entries**
|
|
572
|
+
*
|
|
573
|
+
* Returns the own enumerable `[key, value]` pairs of the wrapped object.
|
|
574
|
+
* This is a terminal read.
|
|
575
|
+
*
|
|
576
|
+
* @returns Array of `[key, value]` tuples.
|
|
577
|
+
*/
|
|
578
|
+
entries() {
|
|
579
|
+
return Object.entries(this.current);
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* **has**
|
|
583
|
+
*
|
|
584
|
+
* Checks whether the wrapped object has the given own key.
|
|
585
|
+
* This is a terminal read.
|
|
586
|
+
*
|
|
587
|
+
* @param key - The key to check.
|
|
588
|
+
* @returns `true` if the key exists on the object.
|
|
589
|
+
*/
|
|
590
|
+
has(key) {
|
|
591
|
+
return Object.prototype.hasOwnProperty.call(this.current, key);
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* **get**
|
|
595
|
+
*
|
|
596
|
+
* Safely reads a possibly-nested value using dot-notation path,
|
|
597
|
+
* returning `fallback` if any part of the path is missing.
|
|
598
|
+
* This is a terminal read.
|
|
599
|
+
*
|
|
600
|
+
* @param path - Dot-notation path (e.g. `"a.b.c"`).
|
|
601
|
+
* @param fallback - Value returned if the path can't be resolved.
|
|
602
|
+
* @returns The resolved value or the fallback.
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* ```ts
|
|
606
|
+
* __sys__.utils.obj.of({ a: { b: { c: 42 } } }).get("a.b.c"); // 42
|
|
607
|
+
* __sys__.utils.obj.of({ a: {} }).get("a.b.c", "missing"); // "missing"
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
get(path, fallback = undefined) {
|
|
611
|
+
const parts = path.split(".");
|
|
612
|
+
let cursor = this.current;
|
|
613
|
+
for (const part of parts) {
|
|
614
|
+
if (cursor === null || cursor === undefined)
|
|
615
|
+
return fallback;
|
|
616
|
+
cursor = cursor[part];
|
|
617
|
+
}
|
|
618
|
+
return cursor === undefined ? fallback : cursor;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* **set**
|
|
622
|
+
*
|
|
623
|
+
* Sets a possibly-nested value using dot-notation path, creating
|
|
624
|
+
* intermediate objects as needed.
|
|
625
|
+
*
|
|
626
|
+
* @param path - Dot-notation path (e.g. `"a.b.c"`).
|
|
627
|
+
* @param value - The value to set.
|
|
628
|
+
* @returns `this`, with the value set at the given path.
|
|
629
|
+
*
|
|
630
|
+
* @example
|
|
631
|
+
* ```ts
|
|
632
|
+
* __sys__.utils.obj.of<any>({}).set("a.b.c", 42).value();
|
|
633
|
+
* // { a: { b: { c: 42 } } }
|
|
634
|
+
* ```
|
|
635
|
+
*/
|
|
636
|
+
set(path, value) {
|
|
637
|
+
const parts = path.split(".");
|
|
638
|
+
let cursor = this.current;
|
|
639
|
+
parts.forEach((part, i) => {
|
|
640
|
+
if (i === parts.length - 1) {
|
|
641
|
+
cursor[part] = value;
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
if (typeof cursor[part] !== "object" || cursor[part] === null) {
|
|
645
|
+
cursor[part] = {};
|
|
646
|
+
}
|
|
647
|
+
cursor = cursor[part];
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
return this;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* **equals**
|
|
654
|
+
*
|
|
655
|
+
* Performs a deep structural equality check between the wrapped
|
|
656
|
+
* object and `other`. This is a terminal read.
|
|
657
|
+
*
|
|
658
|
+
* @param other - The object to compare against.
|
|
659
|
+
* @returns `true` if both objects are deeply equal.
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```ts
|
|
663
|
+
* __sys__.utils.obj.of({ a: { b: 1 } }).equals({ a: { b: 1 } }); // true
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
equals(other) {
|
|
667
|
+
return __sys__.utils.obj.deepEqual(this.current, other);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
exports.ObjectWrapper = ObjectWrapper;
|
|
672
|
+
//# sourceMappingURL=ObjectWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectWrapper.js","sources":["../../../../../src/xhsc/utils/ObjectWrapper.ts"],"sourcesContent":[null],"names":["XStringify"],"mappings":";;;;AACA;MAKa,aAAa,CAAA;AAGtB,IAAA,WAAA,CAAY,GAAM,EAAA;AACd,QAAA,IAAI,CAAC,OAAO,GAAG,GAAG;IACtB;AAEA;;;;;;;;;;;;;AAaG;IACI,KAAK,GAAA;QACR,OAAO,IAAI,CAAC,OAAO;IACvB;AAEA;;;;;;AAMG;IACI,GAAG,GAAA;QACN,OAAO,IAAI,CAAC,OAAO;IACvB;AAEA;;;;;;;;;;;;;;;AAeG;IACI,KAAK,GAAA;AACR,QAAA,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAACA,0BAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACnD,QAAA,OAAO,IAAI;IACf;AAEA;;;;;;;;;;;;;AAaG;AACI,IAAA,IAAI,CAAoB,IAAS,EAAA;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CACtB,CAAC,GAAG,EAAE,GAAG,KAAI;AACT,YAAA,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO;gBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;AACrD,YAAA,OAAO,GAAG;QACd,CAAC,EACD,EAAgB,CACnB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