# @strikeentco/set

> Set nested values on an object using a dot path or custom separator

Latest version **1.0.2** (published 2022-01-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @strikeentco/set
pnpm add @strikeentco/set
yarn add @strikeentco/set
bun add @strikeentco/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.2 |
| Published | 2022-01-27 |
| First published | 2018-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Alexey Bystrov |
| Maintainers | strikeentco |
| Keywords | obj, object, prop, property, dot, path, set, deep, create, notation, dotty, key, nested, paths, properties, props, segment, value, values, custom, separator, small, fast |

## Links

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

## 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.2 (latest) — 2022-01-27
- 1.0.1 — 2020-10-29
- 1.0.0 — 2018-03-18

## README

set [![License](https://img.shields.io/npm/l/@strikeentco/set.svg)](https://github.com/strikeentco/set/blob/master/LICENSE)  [![npm](https://img.shields.io/npm/v/@strikeentco/set.svg)](https://www.npmjs.com/package/@strikeentco/set)
==========
[![Build Status](https://travis-ci.org/strikeentco/set.svg)](https://travis-ci.org/strikeentco/set)  [![node](https://img.shields.io/node/v/@strikeentco/set.svg)](https://www.npmjs.com/package/@strikeentco/set) [![Test Coverage](https://api.codeclimate.com/v1/badges/450e530044d31f690dc5/test_coverage)](https://codeclimate.com/github/strikeentco/set/test_coverage)

One of the smallest (*31 sloc*) and most effective implementations of setting a nested value on an object.

# Usage

```sh
$ npm install @strikeentco/set --save
```

```javascript
const set = require('@strikeentco/set');

set({ a: { b: 'c' } }, 'a.b', 'd');
//=> { a: { b: 'd' } }

set({ a: { b: ['c', 'd'] } }, 'a.b.1', 'e');
//=> { a: { b: ['c', 'e'] } }

set({ a: { b: ['c', 'd'] } }, ['a', 'b'], 'c');
//=> { a: { b: 'c' } }

set({ a: { b: 'c' } }, 'a.b.c.d', 'e');
//=> { a: { b: { c: { d: 'e' } } } }

set({ a: { b: 'c' } }, 'a:b', 'd', ':');
//=> { a: { b: 'd' } }
```
## API

### set(obj, path, val, [separator])

#### Params:
* **obj** (*Object*) - Source object.
* **path** (*String|Array*) - String or array with path.
* **val** (*Any*) - Value to set.
* **[separator]** (*String*) - `.` by default.

## License

The MIT License (MIT)<br/>
Copyright (c) 2018-present Alexey Bystrov

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