data to be formatted
key:valuePath, each key value is separated by comma
return modified object along with the provided object
"alterName:key" or "alterName:nested.key" or "nested.alterName:key" or "nested.alterName:nested.key"
const payload = {
id: "some-id",
data: {
theme: "dark"
},
portion: {
id: "portion-id",
data: {
name: "section-wrapper"
}
}
};
const a = dataFormatter(payload, "pid:id,theme:data.theme,prtn.id:portion.id,prtn.name:portion.data.name,something:block", { oldData: false });
console.log(a);
output:
{
pid: 'some-id',
theme: 'dark',
prtn: { id: 'portion-id', name: 'section' },
ERRORS: { block: 'not found' }
}
Generated using TypeDoc
Data formatter - rename/customise keyname and values as you require, even nested keys and nested values can be defined.