Options
All
  • Public
  • Public/Protected
  • All
Menu

External module @corpuscule/utils/lib/shallowEqual

This module provides tools to compare object shallowly.

Usage

import shallowEqual from '@corpuscule/utils/lib/shallowEqual'

Index

Functions

Functions

shallowEqual

  • shallowEqual<T, U>(objA: T, objB: U): boolean
  • Compares two objects following the idea that one object is shallowly equal to another if each property of this object is equal to each property of another.

    Type parameters

    • T: any

    • U: any

    Parameters

    • objA: T

      the first object to compare

    • objB: U

      the second object to compare

    Returns boolean

    result of the comparison

    Example

    const objA = {foo: 1, bar: 2};
    const objB = {foo: 1, bar: 2};
    const objC = {foo: 1, baz: 2};
    
    shallowEqual(objA, objB); // true
    shallowEqual(objA, objC); // false

Generated using TypeDoc