# js-object-compare

> A package that offers functions to help with object comparison (same keys, same keys and values, same content, in A but not in B). Includes tests to show it works.

Latest version **1.0.0** (published 2019-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-object-compare
pnpm add js-object-compare
yarn add js-object-compare
bun add js-object-compare
```

## 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.0 |
| Published | 2019-10-17 |
| First published | 2019-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ruud-Verhoef |
| Maintainers | ruud-verhoef |
| Keywords | javascript, object, objects, compare, comparing, comparison, json |

## Links

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

## Recent versions

- 1.0.0 (latest) — 2019-10-17

## README

A package that offers functions to help with object comparison (same keys, same key/values, same content, in A but not in B). Includes tests to show it works.

# Installation

```
$ npm install js-object-compare
```

# Usage

<br />
<div style="border: 1px solid black; padding: 10px; background-color: #ffdb99; color: black;">Objects are equal if: they contain the same key/value pairs. The order in which they appear does not matter.</div>
<br />

```javascript
const jsoc = require("js-object-compare");

const obj1 = { num: 1, block1: { num: 2 } };
const obj2 = { block1: { num: 2 }, num: 1 };
const obj3 = { num: 1, block1: {} };
const obj4 = { num: 1, char: "a", block1: { num: 3 } };

// returns true because both objects have the exact same key/value pairs (it does not matter they are not in the same order).
console.log(jsoc.sameContent(obj1, obj2));
// returns an object with block1 stripped away, because the object, at that location, does not contain anything.
console.log(jsoc.clearEmpties(obj3));
// returns all key/value pairs that are the same in both objects.
console.log(jsoc.equalKeyValue(obj1, obj4));
// returns all keys that exist in both objects (values may be different because of that they are undefined in the resulting object).
console.log(jsoc.equalKey(obj1, obj4));
// returns all key/value pairs that are part of param1 but do not exist in param2 (values may be different).
console.log(jsoc.in_A_ButNotIn_B(obj4, obj1));
```

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