# deep-sync

> Recursively synchronizes two JS objects where the target becomes the source, without changing the target values for the keys that it has in common with the source.

Latest version **1.0.2** (published 2015-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install deep-sync
pnpm add deep-sync
yarn add deep-sync
bun add deep-sync
```

## 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 | 2015-09-15 |
| First published | 2015-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Maximilian Greschke |
| Maintainers | mgreschke |
| Keywords | Merge, javascript, objects, sync, json, objects |

## Links

- npm: https://www.npmjs.com/package/deep-sync
- Repository: https://www.github.com/veyo-care/deep-sync
- npm.io page: https://npm.io/package/deep-sync

## 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

- 1.0.2 (latest) — 2015-09-15
- 1.0.1 — 2015-09-11
- 1.0.0 — 2015-09-11

## README

# deep-sync

Recursively synchronizes two JSON / Javascript objects where the target becomes the source, without changing the target values for the keys that it has in common with the source.
If overwrite option is passed, existent keys will be overwritten as well.
Keys that exist in the target but not in the source will be removed from the dict.

# method

```
var deepSync = require('deep-sync')
deepSync(target, source, overwrite)
```

# example

```
var baseObj = {a: 1, b:2, c:3, d: { e:4 }}
var target = {a:1, b:1}

deepSync(target, baseObj, false)
// {a:1, b:1, c:3, d: { e:4 }}

deepSync(target, baseObj, true)
// {a:1, b:2, c:3, d: { e:4 }}
```

# error handling
Throws an error of instance TypeError for invalid input

```
try {
deepSync(a,b)
} catch (e) {
  if (e instanceof TypeError) {
    console.log('Invalid objects')
  }
}
```

# install

With npm do:

```
npm install deep-sync
```

# test

With npm do:

```
npm test
```

# license

MIT.

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