# object-set

> Sets the value at path of object.

Latest version **1.0.1** (published 2016-04-15) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-04-15 |
| First published | 2016-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | bubkoo |
| Maintainers | bubkoo |
| Keywords | remove, delete, unset, set, key, value, property, path, object |

## Links

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

## Dependencies (4)

- [is-nil](https://npm.io/package/is-nil.md) ^1.0.0
- [to-path](https://npm.io/package/to-path.md) ^1.0.0
- [is-index](https://npm.io/package/is-index.md) ^1.0.0
- [is-object](https://npm.io/package/is-object.md) ^1.0.1

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-04-15
- 1.0.0 — 2016-04-13
- 0.0.0 — 2016-04-12

## README

# object-set

> Sets the value at path of object.


[![MIT License](https://img.shields.io/badge/license-MIT_License-green.svg?style=flat-square)](https://github.com/gearcase/object-set/blob/master/LICENSE)

[![build:?](https://img.shields.io/travis/gearcase/object-set/master.svg?style=flat-square)](https://travis-ci.org/gearcase/object-set)
[![coverage:?](https://img.shields.io/coveralls/gearcase/object-set/master.svg?style=flat-square)](https://coveralls.io/github/gearcase/object-set)


## Install

```
$ npm install --save object-set 
```

## Usage

> For more use-cases see the [tests](https://github.com/gearcase/object-set/blob/master/test/spec/index.js)

```js
var set    = require('object-set');
var object = { 'a': [{ 'b': { 'c': 3 } }] };

set(object, 'a[0].b.c', 4);
// => { 'a': [{ 'b': { 'c': 4 } }] }

set({ foo: { bar: 'baz' } }, 'foo.arr[0]', 3);
// => { foo: {bar: 'baz', arr: [3] } }

set({ foo: { bar: 'baz' } }, 'foo.arr[1]', 3);
// => { foo: {bar: 'baz', arr: [, 3] } }

set({ foo: { bar: 'baz' } }, 'foo.obj.key', 3);
// => { foo: {bar: 'baz', obj: { key: 3 } } }

set(null, 'foo.obj.key', 3);
// => null

set({ foo: 1 }, 'foo.obj.key', 3);
// => { foo: 1 }
```


## Related


- [object-unset](https://github.com/gearcase/object-unset) - Removes the property at path of object.
- [object-at](https://github.com/gearcase/object-at) - Get object's property according to the path.
- [object-has](https://github.com/gearcase/object-has) - Checks if path is a direct property of object.
- [to-path](https://github.com/gearcase/to-path) - Converts string to a property path array. 



## Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please [create an issue](https://github.com/gearcase/object-set/issues/new).

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