npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@a11d/equals

v0.2.3

Published

A value equality utility library.

Readme

@a11d/equals

Value equality for JavaScript. Compares objects, arrays, maps, sets, and functions by structure instead of reference.

import '@a11d/equals'
import { equals } from '@a11d/equals'

const obj1 = { a: 1, b: [1, 2, 3] }
const obj2 = { a: 1, b: [1, 2, 3] }

Object[equals](obj1, obj2) // true
obj1 === obj2 // false

Installation

npm install @a11d/equals

Usage

Two APIs available:

Symbol-based (recommended):

import { equals } from '@a11d/equals'
obj[equals](other)

Global methods (for .equals() syntax or when the symbol conflicts with other libraries):

import '@a11d/equals/global'
obj.equals(other)

Built-in types

Objects with valueOf()

Compared by their primitive values:

const a = { valueOf: () => 1 }
const b = { valueOf: () => 1 }

Object[equals](a, b) // true

undefined vs absence

Missing properties and undefined values are treated as equal, but null is different:

const obj1 = { a: 1, b: undefined }
const obj2 = { a: 1 }
const obj3 = { a: 1, b: null }

Object[equals](obj1, obj2) // true
Object[equals](obj1, obj3) // false

Prototype-less objects

Objects created with Object.create(null) work fine:

const a = Object.create(null)
a.prop = 'value'

const b = { prop: 'value' }

Object[equals](a, b) // true

Nested structures are compared deeply:

const arr1 = [1, 2, { key: 'value' }]
const arr2 = [1, 2, { key: 'value' }]

Object[equals](arr1, arr2) // true

Values and elements are compared deeply. Note that Map keys are compared by identity:

const map1 = new Map([['a', { id: 1 }], ['b', { id: 2 }]])
const map2 = new Map([['a', { id: 1 }], ['b', { id: 2 }]])

const set1 = new Set([1, { key: 'value' }])
const set2 = new Set([1, { key: 'value' }])

Object[equals](map1, map2) // true
Object[equals](set1, set2) // true
const fn1 = () => 42
const fn2 = () => 42

Object[equals](fn1, fn2) // true

Note: This compares the .toString() output, so functions with the same code but different names or closures may differ.

Custom equality

Implement the equals symbol (or .equals() method with global API):

import { equals } from '@a11d/equals'

class Person {
	constructor(public name: string, public age: number) {}

	[equals](other: unknown): boolean {
		return other instanceof Person
			&& this.name === other.name
			&& this.age === other.age
	}
}

Lit integration

Use hasChanged to trigger re-renders only on structural changes:

import { hasChanged } from '@a11d/equals'

class MyComponent extends Component {
	@property({ type: Object, hasChanged })
	data = { name: 'John', items: [1, 2, 3] }
}

Without this, Lit re-renders whenever you assign a new object reference, even if the content is identical.