UNPKG

@polgubau/utils

Version:

A collection of utility functions for TypeScript

22 lines (20 loc) 665 B
/** * @name parseJSON * @description A wrapper for "JSON.parse()"" to support "undefined" value, if fails -> throw an error * @param value - string | null * @returns T | undefined * Author: Pol Gubau Amores */ declare function parseJSON<T>(value: string | null): T | undefined; declare function saveParseJson<T>(value: string | null): T | undefined; /** stringify * @param value - T * @returns string | undefined */ declare function stringify<T>(value: T): string | undefined; declare const json: { saveParse: typeof saveParseJson; parse: typeof parseJSON; stringify: typeof stringify; }; export { json, parseJSON, saveParseJson, stringify };