UNPKG

@naturalcycles/js-lib

Version:

Standard library for universal (browser + Node.js) javascript

19 lines (18 loc) 709 B
import type { Reviver } from '../types.js'; /** * Attempts to parse object as JSON. * Returns original object if JSON parse failed (silently). */ export declare function _jsonParseIfPossible(obj: any, reviver?: Reviver): any; /** * Convenience function that does JSON.parse, but doesn't throw on error, * instead - safely returns `undefined`. */ export declare function _jsonParseOrUndefined<T = unknown>(obj: any, reviver?: Reviver): T | undefined; /** * Same as JSON.parse, but throws JsonParseError: * * 1. It's message includes a piece of source text (truncated) * 2. It's data.text contains full source text */ export declare function _jsonParse<T = unknown>(s: string, reviver?: Reviver): T;