From fe1bcc1989cc15f2c48e4e86329ea5757a470d8c Mon Sep 17 00:00:00 2001 From: Orion Kindel Date: Tue, 28 Nov 2023 14:28:58 -0600 Subject: [PATCH] fix: omit nulls --- src/Data/YAML/Foreign/Encode.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 })