# @guanghechen/equal

> The fastest deep equal with ES6 Map, Set and Typed arrays support.

Latest version **2.0.5** (published 2026-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @guanghechen/equal
pnpm add @guanghechen/equal
yarn add @guanghechen/equal
bun add @guanghechen/equal
```

## Health

**Score 70/100 (B)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.5 |
| Published | 2026-09-12 |
| First published | 2023-10-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | guanghechen |
| Maintainers | lemonclown |
| Keywords | equal, fast deep equal |

## Links

- npm: https://www.npmjs.com/package/@guanghechen/equal
- Repository: https://github.com/guanghechen/sora/tree/@guanghechen/equal@2.0.5
- Homepage: https://github.com/guanghechen/sora/tree/@guanghechen/equal@2.0.5/packages/equal#readme
- npm.io page: https://npm.io/package/@guanghechen/equal

## Recent versions

- 2.0.5 (latest) — 2026-09-12
- 2.0.4 — 2026-07-10
- 2.0.3 — 2026-06-27
- 2.0.2 — 2026-02-15
- 2.0.1 — 2026-02-07
- 2.0.0 — 2026-02-04
- 1.0.3 — 2024-10-03
- 1.0.2 — 2024-09-28
- 1.0.1 — 2024-09-25
- 1.0.0 — 2024-09-20
- 1.0.0-alpha.7 — 2024-09-18
- 1.0.0-alpha.6 — 2024-02-03
- 1.0.0-alpha.5 — 2023-12-03
- 1.0.0-alpha.4 — 2023-11-29
- 1.0.0-alpha.3 — 2023-11-18
- … 2 more at https://npm.io/package/@guanghechen/equal/versions

## README

<header>
  <h1 align="center">
    <a href="https://github.com/guanghechen/sora/tree/@guanghechen/equal@2.0.5/packages/equal#readme">@guanghechen/equal</a>
  </h1>
  <div align="center">
    <a href="https://www.npmjs.com/package/@guanghechen/equal">
      <img
        alt="Npm Version"
        src="https://img.shields.io/npm/v/@guanghechen/equal.svg"
      />
    </a>
    <a href="https://www.npmjs.com/package/@guanghechen/equal">
      <img
        alt="Npm Download"
        src="https://img.shields.io/npm/dm/@guanghechen/equal.svg"
      />
    </a>
    <a href="https://www.npmjs.com/package/@guanghechen/equal">
      <img
        alt="Npm License"
        src="https://img.shields.io/npm/l/@guanghechen/equal.svg"
      />
    </a>
    <a href="#install">
      <img
        alt="Module Formats: cjs, esm"
        src="https://img.shields.io/badge/module_formats-cjs%2C%20esm-green.svg"
      />
    </a>
    <a href="https://github.com/nodejs/node">
      <img
        alt="Node.js Version"
        src="https://img.shields.io/node/v/@guanghechen/equal"
      />
    </a>
    <a href="https://github.com/facebook/jest">
      <img
        alt="Tested with Jest"
        src="https://img.shields.io/badge/tested_with-jest-9c465e.svg"
      />
    </a>
    <a href="https://biomejs.dev/">
      <img
        alt="Code Style: Biome"
        src="https://img.shields.io/badge/code_style-biome-60a5fa.svg?style=flat-square"
      />
    </a>
  </div>
</header>
<br/>

The fastest deep equal with ES6 Map, Set and Typed arrays support. Inspired by
[fast-deep-equal](https://github.com/epoberezkin/fast-deep-equal), re-published with ESM support.

## Install

- npm

  ```bash
  npm install --save @guanghechen/equal
  ```

- yarn

  ```bash
  yarn add @guanghechen/equal
  ```

## Usage

### Basic Comparison

```typescript
import isEqual from '@guanghechen/equal'

// Primitives
isEqual(1, 1)           // true
isEqual('a', 'a')       // true
isEqual(null, null)     // true
isEqual(undefined, undefined) // true

// Objects
isEqual({ a: 1, b: 2 }, { a: 1, b: 2 })  // true
isEqual({ a: 1 }, { a: 2 })              // false

// Arrays
isEqual([1, 2, 3], [1, 2, 3])  // true
isEqual([1, 2], [1, 2, 3])     // false

// Nested structures
isEqual(
  { user: { name: 'John', tags: ['admin'] } },
  { user: { name: 'John', tags: ['admin'] } }
) // true
```

### Named Export

```typescript
import { isEqual } from '@guanghechen/equal'

isEqual({ foo: 'bar' }, { foo: 'bar' }) // true
```

### Special Types

```typescript
import isEqual from '@guanghechen/equal'

// RegExp
isEqual(/abc/gi, /abc/gi)  // true
isEqual(/abc/g, /abc/i)    // false

// Date
isEqual(new Date('2024-01-01'), new Date('2024-01-01'))  // true

// Map (keys matched by identity, values compared deeply)
isEqual(new Map([['a', 1]]), new Map([['a', 1]]))  // true
isEqual(new Map([['a', 1]]), new Map([['a', 2]]))  // false

// Set (elements matched by identity)
isEqual(new Set([1, 2, 3]), new Set([3, 2, 1]))  // true
isEqual(new Set([1, 2]), new Set([1, 2, 3]))     // false

// Typed arrays (element-wise)
isEqual(new Uint8Array([1, 2, 3]), new Uint8Array([1, 2, 3]))  // true
isEqual(new Uint8Array([1, 2, 3]), new Uint8Array([1, 2, 4]))  // false

// Custom valueOf/toString
class Point {
  constructor(public x: number, public y: number) {}
  valueOf() { return this.x * 1000 + this.y }
}
isEqual(new Point(1, 2), new Point(1, 2))  // true
```

## Reference

- [homepage][homepage]
- Inspired by [fast-deep-equal](https://github.com/epoberezkin/fast-deep-equal)

[homepage]:
  https://github.com/guanghechen/sora/tree/@guanghechen/equal@2.0.5/packages/equal#readme

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