# object-update

> update for deep nested object

Latest version **0.1.0** (published 2015-10-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install object-update
pnpm add object-update
yarn add object-update
bun add object-update
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2015-10-09 |
| First published | 2015-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | leozdgao |
| Maintainers | leozdgao |
| Keywords | update, object-update |

## Links

- npm: https://www.npmjs.com/package/object-update
- Repository: https://github.com/leozdgao/object-update
- Homepage: https://github.com/leozdgao/object-update#readme
- Issues: https://github.com/leozdgao/object-update/issues
- npm.io page: https://npm.io/package/object-update

## Recent versions

- 0.1.0 (latest) — 2015-10-09

## README

# object-update

Update a deep nested object with path, return the origin object if not change.

## Installation

Just use npm to install it. If you want to use it in frontend, use can use webpack or browserify to bundle it to your codebase

```javascript
npm install object-update
```

## How to use

```javascript
var update = require('object-update')
var obj = {
  foo: 'bar',
  nest: {
    cat: 'moew'
  },
  arr: [ 0, 1, 2 ]
}

var newObject = update(obj, {
  'foo': 'barrr',
  'arr.1': 100, // support array
  'nest.cat': { kitty: 'lol' }
})

console.log(newObject)
// {
//   foo: 'barrr',
//   nest: {
//     cat: { kitty: 'lol' }
//   },
//   arr: [ 0, 100, 2 ]
// }
//
```

It is very appreciate to do `PureRender` if you are using React.js like this:

```javascript
{
  handleClick () {
    const newObj = update(this.state.todos, {
      '1.text': 'new text'
    })

    this.setState(newObj)
  }

  shouldComponentUpdate (nextProps, nextState) {
    // pure render
    return !shallowEqual(this.props, nextProps) ||
           !shallowEqual(this.state, nextState)
  }
}
```

For more use case, check the lnode.spec.js in test folder.

---
_Source: https://npm.io/package/object-update · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
