# shallow-equal

> Typescript-compatible minimalistic shallow equality check for arrays/objects

Latest version **3.1.0** (published 2023-02-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install shallow-equal
pnpm add shallow-equal
yarn add shallow-equal
bun add shallow-equal
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2023-02-15 |
| First published | 2016-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 78 |
| Author | Philip Su |
| Maintainers | moroshko, fivecar |
| Keywords | shallow, equality, compare, comparison, shallowequal, shallow-equal, shallowequals, shallow-equals, isshallowequal, is-shallow-equal, equal, equals, isequal, is-equal, object, array, check, test, typescript |

## Links

- npm: https://www.npmjs.com/package/shallow-equal
- Repository: https://github.com/moroshko/shallow-equal
- Homepage: https://github.com/moroshko/shallow-equal#readme
- Issues: https://github.com/moroshko/shallow-equal/issues
- npm.io page: https://npm.io/package/shallow-equal

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 3.1.0 (latest) — 2023-02-15
- 3.0.0 — 2023-01-26
- 1.2.1 — 2019-12-06
- 1.2.0 — 2019-06-12
- 1.1.0 — 2019-02-05
- 1.0.0 — 2016-08-12

## README

## Description

If you know you have two arrays or two objects in hand, and you want to know if they are shallowly equal or not, this library is for you.

## Features

- Super light
- No dependencies
- Thoroughly tested

## Installation

```shell
npm install shallow-equal --save
```
or
```shell
yarn add shallow-equal
```

## Usage

```js
import { shallowEqualArrays } from "shallow-equal";

shallowEqualArrays([1, 2, 3], [1, 2, 3]); // => true
shallowEqualArrays([{ a: 5 }], [{ a: 5 }]); // => false
```

```js
import { shallowEqualObjects } from "shallow-equal";

shallowEqualObjects({ a: 5, b: "abc" }, { a: 5, b: "abc" }); // => true
shallowEqualObjects({ a: 5, b: {} }, { a: 5, b: {} }); // => false
```

You can also use the generic form, `shallowEqual`. But note that it does runtime type checking in order to decide whether it's comparing arrays or objects, so the convenience comes with a runtime penalty.
```js
import { shallowEqual } from "shallow-equal";

shallowEqual([1, 2, 3], [1, 2, 3]); // => true
shallowEqual({ a: 5, b: {} }, { a: 5, b: {} }); // => false
```

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