1.0.4 • Published 1 year ago

@marcm/shallow-equal v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@marcm/shallow-equal

Mighty fast shallow equals (~524 bytes gzipped)

Install

npm install @marcm/shallow-equal
yarn add @marcm/shallow-equal

Supports

  • Object
  • Array
  • TypedArray
  • RegExp
  • Promise
  • Date
  • NaN
  • Set
  • Map

Benchmark^1 (from fast-equals)

^1: showing benchmark 'overall averages'. Ran on an M1 Pro (macOS 13.1). Run yourself by adding @marcm/shallow-equal to the fast-equals benchmark

PackageOps / sec
@marcm/shallow-equal13,079.405
fast-equals (shallowEqual)8,437.492
shallow-equal (shallowEqualObjects)6,777.645
shallowequal6,335.283
fast-shallow-equal5,659.316

Passes the full test suite of fast-equals

Usage

const { shallowEqual } = require('@marcm/shallow-equal')
// or
import { shallowEqual } from '@marcm/shallow-equal'

// Typed Arrays
shallowEqual(new Float32Array([3, 4, 6]), new Float32Array([3, 4, 6])) // true
shallowEqual(new Float32Array([3, 4, 6]), new Float32Array([3, 4, 8])) // false
// Objects and array
shallowEqual({ a: 'a', b: 'b' }, { a: 'a', b: 'b' }) // true
shallowEqual([{ a: 'a' }, { b: 'b' }], [{ a: 'a' }, { b: 'b' }]) // false
// Dates
shallowEqual(new Date('2017-06-16T21:36:48.362Z'), new Date('2016-06-16T21:36:48.362Z')) // false
shallowEqual(new Date('2017-06-16T21:36:48.362Z'), new Date('2017-06-16T21:36:48.362Z')) // true
1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago