UNPKG

renovate

Version:

Automated dependency updates. Flexible so you don't need to be.

32 lines (31 loc) 831 B
import { isNonEmptyString } from "@sindresorhus/is"; import JSON5 from "json5"; //#region lib/workers/global/config/parse/coersions.ts const coersions = { boolean: (val) => { if (val === "true" || val === "") return true; if (val === "false") return false; throw new Error(`Invalid boolean value: expected 'true' or 'false', but got '${val}'`); }, array: (val) => { if (val === "") return []; try { return JSON5.parse(val); } catch { return val.split(",").map((el) => el.trim()).filter(isNonEmptyString); } }, object: (val) => { if (val === "") return {}; try { return JSON5.parse(val); } catch { throw new Error(`Invalid JSON value: '${val}'`); } }, string: (val) => val.replace(/\\n/g, "\n"), integer: parseInt }; //#endregion export { coersions }; //# sourceMappingURL=coersions.js.map