Options
All
  • Public
  • Public/Protected
  • All
Menu

The interface to fulfill to qualify as a Value Object.

Hierarchy

Index

Methods

  • equals(other: unknown): boolean
  • True if this and the other Collection have value equality, as defined by Immutable.is().

    Note: This is equivalent to Immutable.is(this, other), but provided to allow for chained expressions.

    Parameters

    • other: unknown

    Returns boolean

  • hashCode(): number
  • Computes and returns the hashed identity for this Collection.

    The hashCode of a Collection is used to determine potential equality, and is used when adding this to a Set or as a key in a Map, enabling lookup via a different instance.

    const { List, Set } = require('immutable');
    const a = List([ 1, 2, 3 ]);
    const b = List([ 1, 2, 3 ]);
    assert.notStrictEqual(a, b); // different instances
    const set = Set([ a ]);
    assert.equal(set.has(b), true);

    Note: hashCode() MUST return a Uint32 number. The easiest way to guarantee this is to return myHash | 0 from a custom implementation.

    If two values have the same hashCode, they are not guaranteed to be equal. If two values have different hashCodes, they must not be equal.

    Note: hashCode() is not guaranteed to always be called before equals(). Most but not all Immutable.js collections use hash codes to organize their internal data structures, while all Immutable.js collections use equality during lookups.

    Returns number

Generated using TypeDoc