diff --git a/src/Data/YAML/Foreign/Encode.js b/src/Data/YAML/Foreign/Encode.js index 4b12a1c..8c42980 100644 --- a/src/Data/YAML/Foreign/Encode.js +++ b/src/Data/YAML/Foreign/Encode.js @@ -13,14 +13,15 @@ export function objToHash(valueToYAMLImpl, fst, snd, obj) { } export function toYAMLImpl(a) { - const replacer = (_, v) => { - if (typeof v === 'object') { - Object.keys(v).forEach(k => { - if (v[k] === null) { - delete v[k] + const replacer = (_, o) => { + if (typeof o === 'object') { + Object.entries(o).forEach(([k, v]) => { + if (typeof v === 'undefined' || v === null) { + delete o[k] } }) } + return o } return yaml.dump(a, { noCompatMode: true, replacer })