@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/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
- * Parse JSON but return the original string if it fails
138
- *
139
- * @param {any} json JSON string to parse
140
- * @return {string | T} Object if successful, original string otherwise
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 JSONSanitize(obj: any, space?: number): string;
142
+ export declare function objectMap<T>(obj: any, fn: (key: string, value: any) => any): T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ztimson/utils",
3
- "version": "0.27.7",
3
+ "version": "0.27.9",
4
4
  "description": "Utility library",
5
5
  "author": "Zak Timson",
6
6
  "license": "MIT",