- extracted boolean normalization - extracted null key removal - extracted internal key stripping - no behaviour change
29 lines
723 B
JavaScript
29 lines
723 B
JavaScript
export const normalizeYesNoBooleans = (updateBody) => {
|
|
updateBody = JSON.stringify(updateBody);
|
|
updateBody = updateBody.replace(/:\"Yes\"/gm, `:true`);
|
|
updateBody = updateBody.replace(/:\"No\"/gm, `:false`);
|
|
updateBody = JSON.parse(updateBody);
|
|
|
|
return updateBody;
|
|
};
|
|
|
|
export const removeNullKeys = (updateBody) => {
|
|
Object.keys(updateBody).forEach((key) => {
|
|
if (updateBody[key] === null) {
|
|
delete updateBody[key];
|
|
}
|
|
});
|
|
|
|
return updateBody;
|
|
};
|
|
|
|
export const stripInternalKeys = (updateBody) => {
|
|
Object.keys(updateBody).forEach((key) => {
|
|
if (key.indexOf("_") == 0) {
|
|
delete updateBody[key];
|
|
}
|
|
});
|
|
|
|
return updateBody;
|
|
};
|