@layerfig/config
Version:
Layer and runtime-validate type-safe configs for JavaScript apps.
1 lines • 1.3 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","names":["Source","object: T | PartialDeepUnknown<T>","#object"],"sources":["../../../src/sources/object.ts"],"sourcesContent":["import type { PartialDeepUnknown, Prettify } from \"../types\";\nimport { type LoadSourceOptions, Source } from \"./source\";\n\nexport class ObjectSource<\n\tT extends object = Record<string, unknown>,\n> extends Source<T> {\n\t#object: Prettify<PartialDeepUnknown<T>>;\n\n\tconstructor(object: T); // For when you pass the exact object (type inference)\n\tconstructor(object: PartialDeepUnknown<T>); // For when you explicitly specify the type with flexible input\n\tconstructor(object: T | PartialDeepUnknown<T>) {\n\t\tsuper();\n\t\tthis.#object = object;\n\t}\n\n\toverride loadSource({\n\t\tslotPrefix,\n\t\truntimeEnv,\n\t}: LoadSourceOptions): Prettify<T> {\n\t\tconst replacedObject = this.maybeReplaceSlotFromValue({\n\t\t\tvalue: JSON.stringify(this.#object),\n\t\t\tslotPrefix,\n\t\t\truntimeEnv,\n\t\t});\n\n\t\treturn JSON.parse(replacedObject) as Prettify<T>;\n\t}\n}\n"],"mappings":";;;AAGA,IAAa,eAAb,cAEUA,sBAAU;CACnB;CAIA,YAAYC,QAAmC;AAC9C,SAAO;AACP,OAAKC,UAAU;CACf;CAED,AAAS,WAAW,EACnB,YACA,YACmB,EAAe;EAClC,MAAM,iBAAiB,KAAK,0BAA0B;GACrD,OAAO,KAAK,UAAU,KAAKA,QAAQ;GACnC;GACA;EACA,EAAC;AAEF,SAAO,KAAK,MAAM,eAAe;CACjC;AACD"}