set-object-props
v1.0.9
Published
A simple NodeJS lib, which allows you to set all of the object properties, including deep nested objects, to a custom value
Downloads
9
Maintainers
Readme
set-object-props
A simple NodeJS lib, which allows you to set all of the object properties, including deep nested objects, to a custom value
Install
Install with npm
$ npm install --save set-object-props
Usage
const setObjectProps = require("set-object-props");
let newObject = setObjectProps(object, value);
Params
object
{object}: The object to set props onvalue
{any}: The value to set on object properties
Examples
The functions creates a copy of an object passed, so it doesn't change it. Instead it returns a edited copy.
const object = {
a: 1,
b: 2,
c: {
d: 3,
e: {
f: 4
}
}
};
const result = setObjectProps(object, 0);
console.log(JSON.stringify(result));
//=> { a: 0, b: 0, c: { d: 0, e: { f: 0 } } }
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
okonek83
License
Copyright © 2018 okonek Licensed under the MIT license.
This file was generated by readme-generator on August 15, 2018.