@twin.org/core 0.0.1-next.30 → 0.0.1-next.31
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/index.cjs +22 -0
- package/dist/esm/index.mjs +22 -0
- package/dist/types/helpers/jsonHelper.d.ts +2 -2
- package/dist/types/helpers/objectHelper.d.ts +12 -0
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/JsonHelper.md +3 -3
- package/docs/reference/classes/ObjectHelper.md +44 -0
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -2427,6 +2427,7 @@ class JsonHelper {
|
|
|
2427
2427
|
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
2428
2428
|
* @returns The stringified object.
|
|
2429
2429
|
*/
|
|
2430
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2430
2431
|
static stringifyEx(object, space) {
|
|
2431
2432
|
// We want to keep the 'this' intact for the replacer
|
|
2432
2433
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
@@ -2437,6 +2438,7 @@ class JsonHelper {
|
|
|
2437
2438
|
* @param json The object to pause.
|
|
2438
2439
|
* @returns The object.
|
|
2439
2440
|
*/
|
|
2441
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2440
2442
|
static parseEx(json) {
|
|
2441
2443
|
// We want to keep the 'this' intact for the reviver
|
|
2442
2444
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
@@ -2745,6 +2747,26 @@ class ObjectHelper {
|
|
|
2745
2747
|
}
|
|
2746
2748
|
return obj;
|
|
2747
2749
|
}
|
|
2750
|
+
/**
|
|
2751
|
+
* Converter the non JSON primitives to extended types.
|
|
2752
|
+
* @param obj The object to convert.
|
|
2753
|
+
* @returns The object with extended properties.
|
|
2754
|
+
*/
|
|
2755
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2756
|
+
static toExtended(obj) {
|
|
2757
|
+
const jsonExtended = JsonHelper.stringifyEx(obj);
|
|
2758
|
+
return JSON.parse(jsonExtended);
|
|
2759
|
+
}
|
|
2760
|
+
/**
|
|
2761
|
+
* Converter the extended types to non JSON primitives.
|
|
2762
|
+
* @param obj The object to convert.
|
|
2763
|
+
* @returns The object with regular properties.
|
|
2764
|
+
*/
|
|
2765
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2766
|
+
static fromExtended(obj) {
|
|
2767
|
+
const jsonExtended = JsonHelper.stringifyEx(obj);
|
|
2768
|
+
return JsonHelper.parseEx(jsonExtended);
|
|
2769
|
+
}
|
|
2748
2770
|
}
|
|
2749
2771
|
|
|
2750
2772
|
// Copyright 2024 IOTA Stiftung.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -2425,6 +2425,7 @@ class JsonHelper {
|
|
|
2425
2425
|
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
2426
2426
|
* @returns The stringified object.
|
|
2427
2427
|
*/
|
|
2428
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2428
2429
|
static stringifyEx(object, space) {
|
|
2429
2430
|
// We want to keep the 'this' intact for the replacer
|
|
2430
2431
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
@@ -2435,6 +2436,7 @@ class JsonHelper {
|
|
|
2435
2436
|
* @param json The object to pause.
|
|
2436
2437
|
* @returns The object.
|
|
2437
2438
|
*/
|
|
2439
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2438
2440
|
static parseEx(json) {
|
|
2439
2441
|
// We want to keep the 'this' intact for the reviver
|
|
2440
2442
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
@@ -2743,6 +2745,26 @@ class ObjectHelper {
|
|
|
2743
2745
|
}
|
|
2744
2746
|
return obj;
|
|
2745
2747
|
}
|
|
2748
|
+
/**
|
|
2749
|
+
* Converter the non JSON primitives to extended types.
|
|
2750
|
+
* @param obj The object to convert.
|
|
2751
|
+
* @returns The object with extended properties.
|
|
2752
|
+
*/
|
|
2753
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2754
|
+
static toExtended(obj) {
|
|
2755
|
+
const jsonExtended = JsonHelper.stringifyEx(obj);
|
|
2756
|
+
return JSON.parse(jsonExtended);
|
|
2757
|
+
}
|
|
2758
|
+
/**
|
|
2759
|
+
* Converter the extended types to non JSON primitives.
|
|
2760
|
+
* @param obj The object to convert.
|
|
2761
|
+
* @returns The object with regular properties.
|
|
2762
|
+
*/
|
|
2763
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2764
|
+
static fromExtended(obj) {
|
|
2765
|
+
const jsonExtended = JsonHelper.stringifyEx(obj);
|
|
2766
|
+
return JsonHelper.parseEx(jsonExtended);
|
|
2767
|
+
}
|
|
2746
2768
|
}
|
|
2747
2769
|
|
|
2748
2770
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -32,13 +32,13 @@ export declare class JsonHelper {
|
|
|
32
32
|
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
33
33
|
* @returns The stringified object.
|
|
34
34
|
*/
|
|
35
|
-
static stringifyEx(object:
|
|
35
|
+
static stringifyEx(object: any, space?: string | number): string;
|
|
36
36
|
/**
|
|
37
37
|
* Parse the JSON string with support for extended data types date/bigint/uint8array.
|
|
38
38
|
* @param json The object to pause.
|
|
39
39
|
* @returns The object.
|
|
40
40
|
*/
|
|
41
|
-
static parseEx(json: string):
|
|
41
|
+
static parseEx(json: string): any;
|
|
42
42
|
/**
|
|
43
43
|
* Replacer function to handle extended data types.
|
|
44
44
|
* @param this The object.
|
|
@@ -80,4 +80,16 @@ export declare class ObjectHelper {
|
|
|
80
80
|
* @returns The partial object.
|
|
81
81
|
*/
|
|
82
82
|
static omit<T>(obj: T | undefined, keys?: (keyof T)[]): Partial<T>;
|
|
83
|
+
/**
|
|
84
|
+
* Converter the non JSON primitives to extended types.
|
|
85
|
+
* @param obj The object to convert.
|
|
86
|
+
* @returns The object with extended properties.
|
|
87
|
+
*/
|
|
88
|
+
static toExtended(obj: any): any;
|
|
89
|
+
/**
|
|
90
|
+
* Converter the extended types to non JSON primitives.
|
|
91
|
+
* @param obj The object to convert.
|
|
92
|
+
* @returns The object with regular properties.
|
|
93
|
+
*/
|
|
94
|
+
static fromExtended(obj: any): any;
|
|
83
95
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -113,7 +113,7 @@ Stringify the JSON with support for extended data types date/bigint/uint8array.
|
|
|
113
113
|
|
|
114
114
|
##### object
|
|
115
115
|
|
|
116
|
-
`
|
|
116
|
+
`any`
|
|
117
117
|
|
|
118
118
|
The object to stringify.
|
|
119
119
|
|
|
@@ -133,7 +133,7 @@ The stringified object.
|
|
|
133
133
|
|
|
134
134
|
### parseEx()
|
|
135
135
|
|
|
136
|
-
> `static` **parseEx**(`json`): `
|
|
136
|
+
> `static` **parseEx**(`json`): `any`
|
|
137
137
|
|
|
138
138
|
Parse the JSON string with support for extended data types date/bigint/uint8array.
|
|
139
139
|
|
|
@@ -147,7 +147,7 @@ The object to pause.
|
|
|
147
147
|
|
|
148
148
|
#### Returns
|
|
149
149
|
|
|
150
|
-
`
|
|
150
|
+
`any`
|
|
151
151
|
|
|
152
152
|
The object.
|
|
153
153
|
|
|
@@ -367,3 +367,47 @@ The property keys to omit.
|
|
|
367
367
|
`Partial`\<`T`\>
|
|
368
368
|
|
|
369
369
|
The partial object.
|
|
370
|
+
|
|
371
|
+
***
|
|
372
|
+
|
|
373
|
+
### toExtended()
|
|
374
|
+
|
|
375
|
+
> `static` **toExtended**(`obj`): `any`
|
|
376
|
+
|
|
377
|
+
Converter the non JSON primitives to extended types.
|
|
378
|
+
|
|
379
|
+
#### Parameters
|
|
380
|
+
|
|
381
|
+
##### obj
|
|
382
|
+
|
|
383
|
+
`any`
|
|
384
|
+
|
|
385
|
+
The object to convert.
|
|
386
|
+
|
|
387
|
+
#### Returns
|
|
388
|
+
|
|
389
|
+
`any`
|
|
390
|
+
|
|
391
|
+
The object with extended properties.
|
|
392
|
+
|
|
393
|
+
***
|
|
394
|
+
|
|
395
|
+
### fromExtended()
|
|
396
|
+
|
|
397
|
+
> `static` **fromExtended**(`obj`): `any`
|
|
398
|
+
|
|
399
|
+
Converter the extended types to non JSON primitives.
|
|
400
|
+
|
|
401
|
+
#### Parameters
|
|
402
|
+
|
|
403
|
+
##### obj
|
|
404
|
+
|
|
405
|
+
`any`
|
|
406
|
+
|
|
407
|
+
The object to convert.
|
|
408
|
+
|
|
409
|
+
#### Returns
|
|
410
|
+
|
|
411
|
+
`any`
|
|
412
|
+
|
|
413
|
+
The object with regular properties.
|