UNPKG

@carlosv2/glue

Version:

Dependency injection library that stays out of the way

21 lines (20 loc) 520 B
import { DeserialiseError, SerialiseError } from '../../error/format.js'; import { Loader } from '../loader.js'; export class JsonLoader extends Loader { serialise(path, data) { try { return JSON.stringify(data); } catch (_a) { throw new SerialiseError('JSON', path); } } deserialise(path, data) { try { return JSON.parse(data); } catch (_a) { throw new DeserialiseError('JSON', path); } } }