Skip to content

isMapEqual

Compare two maps for deep equality

556 bytes
since v12.7.0

Usage

Returns true when two Map instances contain the same keys and each value is deeply equal.

import * as
import _
_
from 'radashi'
const
const left: Map<string, number | string[]>
left
= new
var Map: MapConstructor
new <string, number | string[]>(iterable?: Iterable<readonly [string, number | string[]]> | null | undefined) => Map<string, number | string[]> (+3 overloads)
Map
<string, number | string[]>([
['id', 1],
['tags', ['radashi', 'bench']],
])
const
const right: Map<string, number | string[]>
right
= new
var Map: MapConstructor
new <string, number | string[]>(iterable?: Iterable<readonly [string, number | string[]]> | null | undefined) => Map<string, number | string[]> (+3 overloads)
Map
<string, number | string[]>([
['tags', ['radashi', 'bench']],
['id', 1],
])
import _
_
.
function isMapEqual(x: Map<any, any>, y: Map<any, any>): boolean

Check if two maps are equal. Items are checked for deep equality using the isEqual function.

isMapEqual
(
const left: Map<string, number | string[]>
left
,
const right: Map<string, number | string[]>
right
) // => true
const
const different: Map<string, number | string[]>
different
= new
var Map: MapConstructor
new <string, number | string[]>(iterable?: Iterable<readonly [string, number | string[]]> | null | undefined) => Map<string, number | string[]> (+3 overloads)
Map
<string, number | string[]>([
['id', 1],
['tags', ['radashi']],
])
import _
_
.
function isMapEqual(x: Map<any, any>, y: Map<any, any>): boolean

Check if two maps are equal. Items are checked for deep equality using the isEqual function.

isMapEqual
(
const left: Map<string, number | string[]>
left
,
const different: Map<string, number | string[]>
different
) // => false

Values are compared with isEqual, so nested objects, arrays, and dates are handled recursively.