@ztimson/utils 0.27.7 → 0.27.9
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/index.cjs +24 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +24 -20
- package/dist/index.mjs.map +1 -1
- package/dist/json.d.ts +23 -0
- package/dist/objects.d.ts +5 -20
- package/package.json +1 -1
package/dist/json.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse JSON but return the original string if it fails
|
|
3
|
+
*
|
|
4
|
+
* @param {any} json JSON string to parse
|
|
5
|
+
* @param fallback Fallback value if unable to parse, defaults to original string
|
|
6
|
+
* @return {string | T} Object if successful, original string otherwise
|
|
7
|
+
*/
|
|
8
|
+
export declare function JSONAttemptParse<T1, T2>(json: T2, fallback?: T1): T1 | T2;
|
|
9
|
+
/**
|
|
10
|
+
* Stringifies objects & skips primitives
|
|
11
|
+
*
|
|
12
|
+
* @param {any} obj Object to convert to serializable value
|
|
13
|
+
* @return {string | T} Serialized value
|
|
14
|
+
*/
|
|
15
|
+
export declare function JSONSerialize<T1>(obj: T1): T1 | string;
|
|
16
|
+
/**
|
|
17
|
+
* Convert an object to a JSON string avoiding any circular references.
|
|
18
|
+
*
|
|
19
|
+
* @param obj Object to convert to JSON
|
|
20
|
+
* @param {number} space Format the JSON with spaces
|
|
21
|
+
* @return {string} JSON string
|
|
22
|
+
*/
|
|
23
|
+
export declare function JSONSanitize(obj: any, space?: number): string;
|
package/dist/objects.d.ts
CHANGED
|
@@ -134,24 +134,9 @@ export declare function isEqual(a: any, b: any, seen?: WeakMap<object, object>):
|
|
|
134
134
|
*/
|
|
135
135
|
export declare function mixin(target: any, constructors: any[]): void;
|
|
136
136
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* @param {any}
|
|
140
|
-
* @
|
|
141
|
-
*/
|
|
142
|
-
export declare function JSONAttemptParse<T1, T2>(json: T2): T1 | T2;
|
|
143
|
-
/**
|
|
144
|
-
* Stringifies objects & skips primitives
|
|
145
|
-
*
|
|
146
|
-
* @param {any} obj Object to convert to serializable value
|
|
147
|
-
* @return {string | T} Serialized value
|
|
148
|
-
*/
|
|
149
|
-
export declare function JSONSerialize<T1>(obj: T1): T1 | string;
|
|
150
|
-
/**
|
|
151
|
-
* Convert an object to a JSON string avoiding any circular references.
|
|
152
|
-
*
|
|
153
|
-
* @param obj Object to convert to JSON
|
|
154
|
-
* @param {number} space Format the JSON with spaces
|
|
155
|
-
* @return {string} JSON string
|
|
137
|
+
* Run a map function on each property
|
|
138
|
+
* @param obj Object that will be iterated
|
|
139
|
+
* @param {(key: string, value: any) => any} fn Transformer function - receives key & value
|
|
140
|
+
* @returns {{}}
|
|
156
141
|
*/
|
|
157
|
-
export declare function
|
|
142
|
+
export declare function objectMap<T>(obj: any, fn: (key: string, value: any) => any): T;
|