Skip to the content

Capsid menu

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

The functions of yaml-plain.mjs
FunctionLinesComplexityCoveredCRAPMutation
yamlPlain7 to 125100%OkCRAP 5No data: no mutants in this code
<anonymous:10>10 to 101100%OkCRAP 1No 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;
}