set-object-props

1.0.9 • Public • Published

set-object-props

Build Status codecov npm version

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 on
  • value {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.

Package Sidebar

Install

npm i set-object-props

Weekly Downloads

1

Version

1.0.9

License

MIT

Unpacked Size

30.9 kB

Total Files

13

Last publish

Collaborators

  • okonek83