@naturalcycles/js-lib 14.153.0 → 14.153.1
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.
|
@@ -3,7 +3,7 @@ import { Reviver } from '../types';
|
|
|
3
3
|
* Attempts to parse object as JSON.
|
|
4
4
|
* Returns original object if JSON parse failed (silently).
|
|
5
5
|
*/
|
|
6
|
-
export declare function _jsonParseIfPossible(obj: any, reviver?: Reviver):
|
|
6
|
+
export declare function _jsonParseIfPossible(obj: any, reviver?: Reviver): any;
|
|
7
7
|
/**
|
|
8
8
|
* Convenience function that does JSON.parse, but doesn't throw on error,
|
|
9
9
|
* instead - safely returns `undefined`.
|
package/package.json
CHANGED
package/src/string/json.util.ts
CHANGED
|
@@ -8,7 +8,7 @@ const DETECT_JSON = /^\s*[{["\-\d]/
|
|
|
8
8
|
* Attempts to parse object as JSON.
|
|
9
9
|
* Returns original object if JSON parse failed (silently).
|
|
10
10
|
*/
|
|
11
|
-
export function _jsonParseIfPossible(obj: any, reviver?: Reviver):
|
|
11
|
+
export function _jsonParseIfPossible(obj: any, reviver?: Reviver): any {
|
|
12
12
|
// Optimization: only try to parse if it looks like JSON: starts with a json possible character
|
|
13
13
|
if (typeof obj === 'string' && obj && DETECT_JSON.test(obj)) {
|
|
14
14
|
try {
|