Page MenuHomeSealhub

transform-object.js
No OneTemporary

transform-object.js

function transformObject(obj, prop_tranformer, value_transformer) {
return Object.keys(obj).reduce((new_obj, prop) => {
let new_prop = prop_tranformer(prop);
new_obj[new_prop] =
obj[prop] instanceof Object
? transformObject(obj[prop], prop_tranformer, value_transformer)
: value_transformer(prop, obj[prop]);
return new_obj;
}, Array.isArray(obj) ? [] : {});
}
module.exports = transformObject;

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 21:56 (18 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
556973
Default Alt Text
transform-object.js (416 B)

Event Timeline