# set-nested-prop

> Set nested object property (supports custom seperator, mutation, forcing creation & multi set)

Latest version **2.0.0** (published 2018-06-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install set-nested-prop
pnpm add set-nested-prop
yarn add set-nested-prop
bun add set-nested-prop
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-06-14 |
| First published | 2017-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tiaan du Plessis |
| Maintainers | tiaanduplessis |
| Keywords | object, property, set, dot-notation, set-nested-prop |

## Links

- npm: https://www.npmjs.com/package/set-nested-prop
- Repository: https://github.com/tiaanduplessis/set-nested-prop
- Issues: https://github.com/tiaanduplessis/set-nested-prop/issues
- npm.io page: https://npm.io/package/set-nested-prop

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2018-06-14
- 1.0.0 — 2017-05-28

## README

# set-nested-prop
[![package version](https://img.shields.io/npm/v/set-nested-prop.svg?style=flat-square)](https://npmjs.org/package/set-nested-prop)
[![package downloads](https://img.shields.io/npm/dm/set-nested-prop.svg?style=flat-square)](https://npmjs.org/package/set-nested-prop)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![package license](https://img.shields.io/npm/l/set-nested-prop.svg?style=flat-square)](https://npmjs.org/package/set-nested-prop)
[![make a pull request](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

> Set nested object property (supports custom seperator, mutation, forcing creation & multi set)

## Table of Contents

- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#License)

## Install

This project uses [node](https://nodejs.org) and [npm](https://www.npmjs.com). 

```sh
$ npm install set-nested-prop
$ # OR
$ yarn add set-nested-prop
```

## Usage

```js
import set from 'set-nested-prop'

// By default the original object is not modified and . is used as a seperator

const obj1 = {
  foo: {
    bar: {
      baz: 5
    }
  }
}

const newObj = set(obj1, 'foo.bar.baz', 6)
console.log(newObj) // { foo: { bar: { baz: 6 } } }
console.log(obj1) // { foo: { bar: { baz: 5 } } }

// You can opt in for mutating
const obj2 = {
  foo: 5
}

set(obj2, 'foo', 6, { mut: true })
console.log(obj2.foo) // 6

// A custom seperator can be used

const customObj = set(obj1, 'foo*bar*baz', 7, { sep: '*' })
console.log(customObj) // { foo: { bar: { baz: 7 } } }

const forceObj = {}
const forceObjResult = set(forceObj, 'foo.bar', 1, {force: true})
console.log(forceObjResult) // {foo: {bar: 1}}

```

## Contribute

1. Fork it and create your feature branch: git checkout -b my-new-feature
2. Commit your changes: git commit -am 'Add some feature'
3. Push to the branch: git push origin my-new-feature 
4. Submit a pull request

## License

MIT

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