@sqlrooms/utils 0.24.9 → 0.24.10

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/README.md CHANGED
@@ -69,7 +69,7 @@ console.log(result); // { name: 'John', age: 30 }
69
69
 
70
70
  // Handle invalid JSON gracefully
71
71
  const invalid = safeJsonParse('{"name": "John", age: 30}');
72
- console.log(invalid); // null
72
+ console.log(invalid); // undefined
73
73
  ```
74
74
 
75
75
  ### Formatting Utilities
package/dist/json.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Parse a JSON string and return the parsed object.
3
- * If the string is not valid JSON, return null.
3
+ * If the string is not valid JSON, return undefined.
4
4
  * @param json - The JSON string to parse.
5
- * @returns The parsed object or null if the string is not valid JSON.
5
+ * @returns The parsed object or undefined if the string is not valid JSON.
6
6
  */
7
- export declare function safeJsonParse<T>(json: string | undefined | null): T | null;
7
+ export declare function safeJsonParse<T>(json: string | undefined | null): T | undefined;
8
8
  //# sourceMappingURL=json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAQ1E"}
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAC9B,CAAC,GAAG,SAAS,CAOf"}
package/dist/json.js CHANGED
@@ -1,18 +1,17 @@
1
1
  /**
2
2
  * Parse a JSON string and return the parsed object.
3
- * If the string is not valid JSON, return null.
3
+ * If the string is not valid JSON, return undefined.
4
4
  * @param json - The JSON string to parse.
5
- * @returns The parsed object or null if the string is not valid JSON.
5
+ * @returns The parsed object or undefined if the string is not valid JSON.
6
6
  */
7
7
  export function safeJsonParse(json) {
8
8
  if (!json)
9
- return null;
9
+ return undefined;
10
10
  try {
11
11
  return JSON.parse(json);
12
12
  }
13
- catch (error) {
14
- console.error('Failed to parse JSON:', error);
15
- return null;
13
+ catch {
14
+ return undefined;
16
15
  }
17
16
  }
18
17
  //# sourceMappingURL=json.js.map
package/dist/json.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAI,IAA+B;IAC9D,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["/**\n * Parse a JSON string and return the parsed object.\n * If the string is not valid JSON, return null.\n * @param json - The JSON string to parse.\n * @returns The parsed object or null if the string is not valid JSON.\n */\nexport function safeJsonParse<T>(json: string | undefined | null): T | null {\n if (!json) return null;\n try {\n return JSON.parse(json) as T;\n } catch (error) {\n console.error('Failed to parse JSON:', error);\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,IAA+B;IAE/B,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Parse a JSON string and return the parsed object.\n * If the string is not valid JSON, return undefined.\n * @param json - The JSON string to parse.\n * @returns The parsed object or undefined if the string is not valid JSON.\n */\nexport function safeJsonParse<T>(\n json: string | undefined | null,\n): T | undefined {\n if (!json) return undefined;\n try {\n return JSON.parse(json) as T;\n } catch {\n return undefined;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqlrooms/utils",
3
- "version": "0.24.9",
3
+ "version": "0.24.10",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -44,5 +44,5 @@
44
44
  "react": ">=18",
45
45
  "react-dom": ">=18"
46
46
  },
47
- "gitHead": "2cbf51a0c14270bd02b73ea20d9684b7453cbdfe"
47
+ "gitHead": "3643e8b85da5780a328c531aa8e867524e688a61"
48
48
  }