Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

  • defaults<A>(a: A): A
  • defaults<A, B>(a: A, b: B): A & B
  • defaults<A, B, C>(a: A, b: B, c: C): A & B & C
  • defaults<A, B, C, D>(a: A, b: B, c: C, d: D): A & B & C & D
  • defaults<A, R>(a: A, ...other: Record<string, unknown>[]): R
  • Returns a new object where any enumerable property from other are recursively applied to a. Once a property is set, it will not be overridden. This function is useful for constructing configs from a default config.

    example
    defaults({ 'a': [1] }, { 'b': 2 }, { 'a': [2] });
    // => { a: [1], b: 2 }

    Type Parameters

    • A

    Parameters

    • a: A

    Returns A

  • Type Parameters

    • A

    • B

    Parameters

    • a: A
    • b: B

    Returns A & B

  • Type Parameters

    • A

    • B

    • C

    Parameters

    • a: A
    • b: B
    • c: C

    Returns A & B & C

  • Type Parameters

    • A

    • B

    • C

    • D

    Parameters

    • a: A
    • b: B
    • c: C
    • d: D

    Returns A & B & C & D

  • Type Parameters

    • A

    • R

    Parameters

    • a: A
    • Rest ...other: Record<string, unknown>[]

    Returns R

  • fromPairs<T>(pairs: undefined | null | [string, T][]): Record<string, T>
  • fromPairs(pairs: undefined | null | unknown[][]): Record<string, unknown>
  • isEqual(a: unknown, b: unknown): boolean
  • Performs a deep comparison of two objects and returns true if they're equal.

    This method supports comparing arrays, array buffers, booleans, date objects, error objects, maps, numbers, Object objects, regexes, sets, strings, symbols, and typed arrays. Object objects are compared by their own, not inherited, enumerable properties. Functions and DOM nodes are compared by strict equality, i.e. ===.

    Parameters

    • a: unknown

      The object to compare with b.

    • b: unknown

      The object to compare with a.

    Returns boolean

    true if the two objects are equal. Otherwise false.

  • isPlainObject(obj: unknown): boolean
  • Returns true if this is a plain object, which is defined by a type created by the Object constructor. Returns false otherwise.

    example
    isPlainObject(Object.create({})); //=> true
    isPlainObject(Object.create(Object.prototype)); //=> true
    isPlainObject({foo: 'bar'}); //=> true
    isPlainObject({}); //=> true

    isPlainObject(1); //=> false
    isPlainObject(['foo', 'bar']); //=> false
    isPlainObject([]); //=> false
    isPlainObject(new Foo); //=> false
    isPlainObject(null); //=> false
    isPlainObject(Object.create(null)); //=> false

    Parameters

    • obj: unknown

    Returns boolean

  • toPairs<T>(obj: Record<string, T>): [string, T][]
  • toPairs<T>(obj: T[]): [string, T][]
  • toPairs(obj: undefined | null | object): [string, any][]
  • Returns an array of key-value pairs for each enumerable key in obj.

    example
    toPairs({a: 1, b: 2}); //=> [['a', 1], ['b', 2]]
    toPairs(['a', 'b']); //=> [['0', 'a'], ['1', 'b']]

    function Foo() {
      this.a = 1;
      this.b = 2;
    }
    toPairs(new Foo()); //=> [['a', 1], ['b', 2]]

    Type Parameters

    • T

    Parameters

    • obj: Record<string, T>

    Returns [string, T][]

  • Type Parameters

    • T

    Parameters

    • obj: T[]

    Returns [string, T][]

  • Parameters

    • obj: undefined | null | object

    Returns [string, any][]