UNPKG

serde-fns

Version:

simple shapes and procedures for serde with a pit-of-success

21 lines 728 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deSerialJSON = exports.asSerialJSON = exports.isSerialJSON = void 0; const type_fns_1 = require("type-fns"); exports.isSerialJSON = (0, type_fns_1.withAssure)((input) => { if (typeof input !== 'string') return false; try { JSON.parse(input); return true; } catch (_a) { return false; } }); const asSerialJSON = (input) => exports.isSerialJSON.assure(JSON.stringify(input)); exports.asSerialJSON = asSerialJSON; const deSerialJSON = (input) => JSON.parse(input); exports.deSerialJSON = deSerialJSON; // todo: support TySON; https://github.com/jetify-com/tyson //# sourceMappingURL=json.js.map