UNPKG

@liplum/env

Version:

Reading and parsing environment variables from "process.env"

20 lines 654 B
import { EnvMixin } from "./shared.js"; const defaultArraySpliter = /\s|,|\r|\n|\r\n/; export class ArrayEnv extends EnvMixin { getOrNull = (splitter = defaultArraySpliter) => { const raw = this.env.getOrNull(); if (raw === undefined) { return this.getDefaultValue(); } const vars = raw.split(splitter); return vars.filter(v => Boolean(v)); }; get = (splitter = defaultArraySpliter) => { const result = this.getOrNull(splitter); if (result === undefined) { throw this.missingEnvError(); } return result; }; } //# sourceMappingURL=array.js.map