Walks a given object and invokes a function on each iteration.
This method walks a given object and invokes a function on each iteration.
Kind: Exported function
Param | Type | Description |
---|---|---|
object | * |
The object to walk. |
props | function |
The function that returns an array of the properties of value to be walked, invoked per iteration. |
supplier | function |
The function invoked per iteration. |
[thisArg] | * |
The this binding of supplier . |
Example
const objectWalk from 'object-walk-x';
const subject = {
one: {
a: true,
b: true,
},
two: {
x: true,
y: true,
},
};
objectWalk(subject, Object.keys, function(value, prop, object, depth) {
object[prop + '_renamed'] = value;
delete object[prop];
});
// {
// one_renamed: {
// a_renamed: true,
// b_renamed: true
// },
// two_renamed: {
// x_renamed: true,
// y_renamed: true
// }
// }
Kind: static property of module.exports
Default: "break"
Kind: static property of module.exports
Default: "skip"
Kind: static property of module.exports
Default: "stop"