# epsitec-immutablediff

> Create RFC 6902 style patches between Immutable.JS data structures

Latest version **0.5.4** (published 2021-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install epsitec-immutablediff
pnpm add epsitec-immutablediff
yarn add epsitec-immutablediff
bun add epsitec-immutablediff
```

## 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.5.4 |
| Published | 2021-09-02 |
| First published | 2018-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 171.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Intelie |
| Maintainers | schroeterm, quarta, qjonny |
| Keywords | immutable.js, diff, jsondiff |

## Links

- npm: https://www.npmjs.com/package/epsitec-immutablediff
- Repository: https://github.com/epsitec-sa/immutable-js-diff
- Homepage: https://github.com/epsitec-sa/immutable-js-diff#readme
- Issues: https://github.com/epsitec-sa/immutable-js-diff/issues
- npm.io page: https://npm.io/package/epsitec-immutablediff

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.5.4 (latest) — 2021-09-02
- 0.5.3 — 2019-03-21
- 0.5.2 — 2018-10-08
- 0.5.1 — 2018-08-06
- 0.5.0 — 2018-08-06
- 0.4.4 — 2018-07-17

## README

# Immutable Diff

Create RFC 6902 style patches between Immutable.JS data structures, such as `Maps`, `Lists`, and `Sets`.

## Differences from original
Signature of diff function is
``` javascript
function diff(a, b, p, s)
```
where if s = true, then sequence diffs are ignored and a single block is generated.  
This can be usefull as an optimization.
If s is a string (identification key of all elements), an additional optimization will be performed, 
detecting if all elements of a list have changed (in this case a complete change),
or just some elements (in this case a granular diff)


## Getting Started

Install `immutablediff` using npm or yarn:

``` shell
# npm...
npm install --save immutablediff

# ...or yarn
yarn add immutablediff
```

You can then use it to get the diff ops between you Immutable.JS data structures.

``` javascript
var Immutable = require('immutable');
var diff = require('immutablediff');

var map1 = Immutable.Map({a:1, b:2, c:3});
var map2 = Immutable.Map({a:1, b:2, c:3, d: 4});

diff(map1, map2);
// List [ Map { op: "add", path: "/d", value: 4 } ]
```

The result of `diff` is an Immutable Sequence of operations

## Immutable Patch

If you want to use the resulting diff to apply patches to other Immutable data structures, you can use the package `immutablepatch`. Source code available [here](https://github.com/intelie/immutable-js-patch)

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