# @jcoreio/mutate

> a few immutable.js-like mutation functions for plain objects

Latest version **2.0.0** (published 2023-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jcoreio/mutate
pnpm add @jcoreio/mutate
yarn add @jcoreio/mutate
bun add @jcoreio/mutate
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-07-25 |
| First published | 2018-01-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16 |
| Dependencies | 2 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andy Edwards |
| Maintainers | avramdodson, forrest-keller, jrmclaurin, jedwards1211, eladendorf |
| Keywords | immutable, deep, json, mutations, update, update-in, set-in |

## Links

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

## Dependencies (2)

- [iterall](https://npm.io/package/iterall.md) ^1.1.3
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.18.6

## Recent versions

- 2.0.0 (latest) — 2023-07-25
- 1.0.8 — 2020-10-15
- 1.0.7 — 2020-10-10
- 1.0.6 — 2020-10-10
- 1.0.5 — 2019-12-05
- 1.0.4 — 2018-10-29
- 1.0.3 — 2018-10-29
- 1.0.2 — 2018-07-26
- 1.0.1 — 2018-02-22
- 1.0.0 — 2018-01-05

## README

# @jcoreio/mutate

[![Build Status](https://travis-ci.org/jcoreio/mutate.svg?branch=master)](https://travis-ci.org/jcoreio/mutate)
[![Coverage Status](https://codecov.io/gh/jcoreio/mutate/branch/master/graph/badge.svg)](https://codecov.io/gh/jcoreio/mutate)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

a few immutable.js-like mutation functions for plain objects

Beware of using Ramda.js! [It always returns a new object, even if nothing changed!](https://github.com/ramda/ramda/issues/2429)

# Usage

```sh
pnpm install --save @jcoreio/mutate
```

# API

## `setIn(obj: any, path: Iterable<any>, newValue: any): any`

```js
const { setIn } = require('@jcoreio/mutate')
```

Works just like [`setIn` from Immutable.js](https://facebook.github.io/immutable-js/docs/#/setIn)
but operates on nested JS Objects and Arrays.

## `updateIn(obj: any, path: Iterable<any>, [notSetValue: any], updater: (value: any) => any): any`

```js
const { updateIn } = require('@jcoreio/mutate')
```

Works just like [`updateIn` from Immutable.js](https://facebook.github.io/immutable-js/docs/#/setIn)
but operates on nested JS Objects and Arrays.

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