Skip to content

Instantly share code, notes, and snippets.

@eidosam
Created July 26, 2022 18:34
Show Gist options
  • Save eidosam/e28c05aec39a6bb07cc82e29a3da71dd to your computer and use it in GitHub Desktop.
Save eidosam/e28c05aec39a6bb07cc82e29a3da71dd to your computer and use it in GitHub Desktop.
function newlineDelimitedKeyValue(obj, parentKey = '') {
return Object.entries(obj)
.map(([k, v]) => {
if (typeof v === 'object') {
return newlineDelimitedKeyValue(v, `${parentKey}${k}_`);
}
const kUpper = `${parentKey}${k}`.toUpperCase();
return `${kUpper}=${v}`;
})
.join('\n');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment