app/lib/yaml-plain.mjs
12 lines and 2 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| yamlPlain | 7 to 12 | 5 | 100% | OkCRAP 5 | No data: no mutants in this code |
| <anonymous:10> | 10 to 10 | 1 | 100% | OkCRAP 1 | No data: no mutants in this code |
Imports
It imports no other module of this repo. Imported by app/kb/form.mjs, app/kb/procedures/parse.mjs, app/lib/publications/parse.mjs.
Source
/**
* YAML dates arrive as Date objects; the record keeps the ISO day the file wrote.
*
* @param {unknown} value
* @returns {unknown}
*/
export function yamlPlain(value) {
if (value instanceof Date) return value.toISOString().slice(0, 10);
if (Array.isArray(value)) return value.map(yamlPlain);
if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, yamlPlain(v)]));
return value;
}