UNPKG

@chubbyts/chubbyts-decode-encode

Version:

A simple decode/encode solution for json / jsonx / url-encoded / xml / yaml.

22 lines (21 loc) 774 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createYamlTypeDecoder = void 0; const yaml_1 = require("yaml"); const throwable_to_error_1 = require("@chubbyts/chubbyts-throwable-to-error/dist/throwable-to-error"); const index_1 = require("./index.cjs"); const createYamlTypeDecoder = () => { return { decode: (encodedData) => { try { return (0, yaml_1.parse)(encodedData); } catch (e) { const error = (0, throwable_to_error_1.throwableToError)(e); throw new index_1.DecodeError(error.message, error.stack); } }, contentType: 'application/x-yaml', }; }; exports.createYamlTypeDecoder = createYamlTypeDecoder;