Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • LoDashStatic

Index

Properties

first

first: head

Methods

chunk

  • chunk<T>(array: List<T> | null | undefined, size?: undefined | number): T[][]
  • Creates an array of elements split into groups the length of size. If collection can’t be split evenly, the final chunk will be the remaining elements.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to process.

    • Optional size: undefined | number

      The length of each chunk.

    Returns T[][]

    Returns the new array containing chunks.

compact

  • compact<T>(array: List<T | null | undefined | false | "" | 0> | null | undefined): T[]
  • Creates an array with all falsey values removed. The values false, null, 0, "", undefined, and NaN are falsey.

    Type parameters

    • T

    Parameters

    • array: List<T | null | undefined | false | "" | 0> | null | undefined

      The array to compact.

    Returns T[]

    Returns the new array of filtered values.

concat

  • concat<T>(array: Many<T>, ...values: Array<Many<T>>): T[]
  • Creates a new array concatenating array with any additional arrays and/or values.

    category

    Array

    example

    var array = [1]; var other = _.concat(array, 2, [3], [[4]]);

    console.log(other); // => [1, 2, 3, [4]]

    console.log(array); // => [1]

    Type parameters

    • T

    Parameters

    • array: Many<T>

      The array to concatenate.

    • Rest ...values: Array<Many<T>>

    Returns T[]

    Returns the new concatenated array.

difference

  • difference<T>(array: List<T> | null | undefined, ...values: Array<List<T>>): T[]
  • Creates an array of unique array values not included in the other provided arrays using SameValueZero for equality comparisons.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to inspect.

    • Rest ...values: Array<List<T>>

      The arrays of values to exclude.

    Returns T[]

    Returns the new array of filtered values.

differenceBy

  • differenceBy<T1, T2>(array: List<T1> | null | undefined, values: List<T2>, iteratee: ValueIteratee<T1 | T2>): T1[]
  • differenceBy<T1, T2, T3>(array: List<T1> | null | undefined, values1: List<T2>, values2: List<T3>, iteratee: ValueIteratee<T1 | T2 | T3>): T1[]
  • differenceBy<T1, T2, T3, T4>(array: List<T1> | null | undefined, values1: List<T2>, values2: List<T3>, values3: List<T4>, iteratee: ValueIteratee<T1 | T2 | T3 | T4>): T1[]
  • differenceBy<T1, T2, T3, T4, T5>(array: List<T1> | null | undefined, values1: List<T2>, values2: List<T3>, values3: List<T4>, values4: List<T5>, iteratee: ValueIteratee<T1 | T2 | T3 | T4 | T5>): T1[]
  • differenceBy<T1, T2, T3, T4, T5, T6>(array: List<T1> | null | undefined, values1: List<T2>, values2: List<T3>, values3: List<T4>, values4: List<T5>, values5: List<T6>, iteratee: ValueIteratee<T1 | T2 | T3 | T4 | T5 | T6>): T1[]
  • differenceBy<T1, T2, T3, T4, T5, T6, T7>(array: List<T1> | null | undefined, values1: List<T2>, values2: List<T3>, values3: List<T4>, values4: List<T5>, values5: List<T6>, ...values: Array<List<T7> | ValueIteratee<T1 | T2 | T3 | T4 | T5 | T6 | T7>>): T1[]
  • differenceBy<T>(array: List<T> | null | undefined, ...values: Array<List<T>>): T[]
  • This method is like _.difference except that it accepts iteratee which is invoked for each element of array and values to generate the criterion by which uniqueness is computed. The iteratee is invoked with one argument: (value).

    Type parameters

    • T1

    • T2

    Parameters

    • array: List<T1> | null | undefined

      The array to inspect.

    • values: List<T2>

      The values to exclude.

    • iteratee: ValueIteratee<T1 | T2>

      The iteratee invoked per element.

    Returns T1[]

    Returns the new array of filtered values.

  • see

    _.differenceBy

    Type parameters

    • T1

    • T2

    • T3

    Parameters

    Returns T1[]

  • see

    _.differenceBy

    Type parameters

    • T1

    • T2

    • T3

    • T4

    Parameters

    Returns T1[]

  • see

    _.differenceBy

    Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    Returns T1[]

  • see

    _.differenceBy

    Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    Parameters

    Returns T1[]

  • see

    _.differenceBy

    Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    Parameters

    • array: List<T1> | null | undefined
    • values1: List<T2>
    • values2: List<T3>
    • values3: List<T4>
    • values4: List<T5>
    • values5: List<T6>
    • Rest ...values: Array<List<T7> | ValueIteratee<T1 | T2 | T3 | T4 | T5 | T6 | T7>>

    Returns T1[]

  • see

    _.differenceBy

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined
    • Rest ...values: Array<List<T>>

    Returns T[]

differenceWith

  • differenceWith<T1, T2>(array: List<T1> | null | undefined, values: List<T2>, comparator: Comparator2<T1, T2>): T1[]
  • differenceWith<T1, T2, T3>(array: List<T1> | null | undefined, values1: List<T2>, values2: List<T3>, comparator: Comparator2<T1, T2 | T3>): T1[]
  • differenceWith<T1, T2, T3, T4>(array: List<T1> | null | undefined, values1: List<T2>, values2: List<T3>, ...values: Array<List<T4> | Comparator2<T1, T2 | T3 | T4>>): T1[]
  • differenceWith<T>(array: List<T> | null | undefined, ...values: Array<List<T>>): T[]
  • Creates an array of unique array values not included in the other provided arrays using SameValueZero for equality comparisons.

    category

    Array

    example

    var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];

    _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); // => [{ 'x': 2, 'y': 1 }]

    Type parameters

    • T1

    • T2

    Parameters

    Returns T1[]

    Returns the new array of filtered values.

  • see

    _.differenceWith

    Type parameters

    • T1

    • T2

    • T3

    Parameters

    Returns T1[]

  • see

    _.differenceWith

    Type parameters

    • T1

    • T2

    • T3

    • T4

    Parameters

    • array: List<T1> | null | undefined
    • values1: List<T2>
    • values2: List<T3>
    • Rest ...values: Array<List<T4> | Comparator2<T1, T2 | T3 | T4>>

    Returns T1[]

  • see

    _.differenceWith

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined
    • Rest ...values: Array<List<T>>

    Returns T[]

drop

  • drop<T>(array: List<T> | null | undefined, n?: undefined | number): T[]
  • Creates a slice of array with n elements dropped from the beginning.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    • Optional n: undefined | number

      The number of elements to drop.

    Returns T[]

    Returns the slice of array.

dropRight

  • dropRight<T>(array: List<T> | null | undefined, n?: undefined | number): T[]
  • Creates a slice of array with n elements dropped from the end.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    • Optional n: undefined | number

      The number of elements to drop.

    Returns T[]

    Returns the slice of array.

dropRightWhile

  • dropRightWhile<T>(array: List<T> | null | undefined, predicate?: ListIteratee<T>): T[]
  • Creates a slice of array excluding elements dropped from the end. Elements are dropped until predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    • Optional predicate: ListIteratee<T>

      The function invoked per iteration.

    Returns T[]

    Returns the slice of array.

dropWhile

  • dropWhile<T>(array: List<T> | null | undefined, predicate?: ListIteratee<T>): T[]
  • Creates a slice of array excluding elements dropped from the beginning. Elements are dropped until predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    • Optional predicate: ListIteratee<T>

      The function invoked per iteration.

    Returns T[]

    Returns the slice of array.

fill

  • fill<T>(array: any[] | null | undefined, value: T): T[]
  • fill<T>(array: List<any> | null | undefined, value: T): List<T>
  • fill<T, U>(array: U[] | null | undefined, value: T, start?: undefined | number, end?: undefined | number): Array<T | U>
  • fill<T, U>(array: List<U> | null | undefined, value: T, start?: undefined | number, end?: undefined | number): List<T | U>
  • Fills elements of array with value from start up to, but not including, end.

    Note: This method mutates array.

    Type parameters

    • T

    Parameters

    • array: any[] | null | undefined

      The array to fill.

    • value: T

      The value to fill array with.

    Returns T[]

    Returns array.

  • see

    _.fill

    Type parameters

    • T

    Parameters

    • array: List<any> | null | undefined
    • value: T

    Returns List<T>

  • see

    _.fill

    Type parameters

    • T

    • U

    Parameters

    • array: U[] | null | undefined
    • value: T
    • Optional start: undefined | number
    • Optional end: undefined | number

    Returns Array<T | U>

  • see

    _.fill

    Type parameters

    • T

    • U

    Parameters

    • array: List<U> | null | undefined
    • value: T
    • Optional start: undefined | number
    • Optional end: undefined | number

    Returns List<T | U>

findIndex

  • findIndex<T>(array: List<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: undefined | number): number
  • This method is like _.find except that it returns the index of the first element predicate returns truthy for instead of the element itself.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to search.

    • Optional predicate: ListIterateeCustom<T, boolean>

      The function invoked per iteration.

    • Optional fromIndex: undefined | number

      The index to search from.

    Returns number

    Returns the index of the found element, else -1.

findLastIndex

  • findLastIndex<T>(array: List<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: undefined | number): number
  • This method is like _.findIndex except that it iterates over elements of collection from right to left.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to search.

    • Optional predicate: ListIterateeCustom<T, boolean>

      The function invoked per iteration.

    • Optional fromIndex: undefined | number

      The index to search from.

    Returns number

    Returns the index of the found element, else -1.

flatten

  • flatten<T>(array: List<Many<T>> | null | undefined): T[]
  • Flattens array a single level deep.

    Type parameters

    • T

    Parameters

    • array: List<Many<T>> | null | undefined

      The array to flatten.

    Returns T[]

    Returns the new flattened array.

flattenDeep

  • Recursively flattens a nested array.

    Type parameters

    • T

    Parameters

    Returns T[]

    Returns the new flattened array.

flattenDepth

  • Recursively flatten array up to depth times.

    Type parameters

    • T

    Parameters

    Returns T[]

    Returns the new flattened array.

fromPairs

  • The inverse of _.toPairs; this method returns an object composed from key-value pairs.

    category

    Array

    example

    _.fromPairs([['fred', 30], ['barney', 40]]); // => { 'fred': 30, 'barney': 40 }

    Type parameters

    • T

    Parameters

    Returns Dictionary<T>

    Returns the new object.

  • see

    _.fromPairs

    Parameters

    • pairs: List<any[]> | null | undefined

    Returns Dictionary<any>

head

  • head<T>(array: List<T> | null | undefined): T | undefined
  • Gets the first element of array.

    alias

    _.first

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    Returns T | undefined

    Returns the first element of array.

indexOf

  • indexOf<T>(array: List<T> | null | undefined, value: T, fromIndex?: undefined | number): number
  • Gets the index at which the first occurrence of value is found in array using SameValueZero for equality comparisons. If fromIndex is negative, it's used as the offset from the end of array.

    category

    Array

    example

    _.indexOf([1, 2, 1, 2], 2); // => 1

    // using fromIndex _.indexOf([1, 2, 1, 2], 2, 2); // => 3

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to search.

    • value: T

      The value to search for.

    • Optional fromIndex: undefined | number

    Returns number

    Returns the index of the matched value, else -1.

initial

  • initial<T>(array: List<T> | null | undefined): T[]
  • Gets all but the last element of array.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    Returns T[]

    Returns the slice of array.

intersection

  • intersection<T>(...arrays: Array<List<T>>): T[]
  • Creates an array of unique values that are included in all of the provided arrays using SameValueZero for equality comparisons.

    Type parameters

    • T

    Parameters

    • Rest ...arrays: Array<List<T>>

      The arrays to inspect.

    Returns T[]

    Returns the new array of shared values.

intersectionBy

  • intersectionBy<T1, T2>(array: List<T1> | null, values: List<T2>, iteratee: ValueIteratee<T1 | T2>): T1[]
  • intersectionBy<T1, T2, T3>(array: List<T1> | null, values1: List<T2>, values2: List<T3>, iteratee: ValueIteratee<T1 | T2 | T3>): T1[]
  • intersectionBy<T1, T2, T3, T4>(array: List<T1> | null | undefined, values1: List<T2>, values2: List<T3>, ...values: Array<List<T4> | ValueIteratee<T1 | T2 | T3 | T4>>): T1[]
  • intersectionBy<T>(array?: List<T> | null, ...values: Array<List<T>>): T[]
  • This method is like _.intersection except that it accepts iteratee which is invoked for each element of each arrays to generate the criterion by which uniqueness is computed. The iteratee is invoked with one argument: (value).

    category

    Array

    example

    _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor); // => [2.1]

    // using the _.property iteratee shorthand _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); // => [{ 'x': 1 }]

    Type parameters

    • T1

    • T2

    Parameters

    Returns T1[]

    Returns the new array of shared values.

  • see

    _.intersectionBy

    Type parameters

    • T1

    • T2

    • T3

    Parameters

    Returns T1[]

  • see

    _.intersectionBy

    Type parameters

    • T1

    • T2

    • T3

    • T4

    Parameters

    Returns T1[]

  • see

    _.intersectionBy

    Type parameters

    • T

    Parameters

    • Optional array: List<T> | null
    • Rest ...values: Array<List<T>>

    Returns T[]

intersectionWith

  • intersectionWith<T1, T2>(array: List<T1> | null | undefined, values: List<T2>, comparator: Comparator2<T1, T2>): T1[]
  • intersectionWith<T1, T2, T3>(array: List<T1> | null | undefined, values1: List<T2>, values2: List<T3>, comparator: Comparator2<T1, T2 | T3>): T1[]
  • intersectionWith<T1, T2, T3, T4>(array: List<T1> | null | undefined, values1: List<T2>, values2: List<T3>, ...values: Array<List<T4> | Comparator2<T1, T2 | T3 | T4>>): T1[]
  • intersectionWith<T>(array?: List<T> | null, ...values: Array<List<T>>): T[]
  • Creates an array of unique array values not included in the other provided arrays using SameValueZero for equality comparisons.

    category

    Array

    example

    var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];

    _.intersectionWith(objects, others, _.isEqual); // => [{ 'x': 1, 'y': 2 }]

    Type parameters

    • T1

    • T2

    Parameters

    Returns T1[]

    Returns the new array of filtered values.

  • see

    _.intersectionWith

    Type parameters

    • T1

    • T2

    • T3

    Parameters

    Returns T1[]

  • see

    _.intersectionWith

    Type parameters

    • T1

    • T2

    • T3

    • T4

    Parameters

    • array: List<T1> | null | undefined
    • values1: List<T2>
    • values2: List<T3>
    • Rest ...values: Array<List<T4> | Comparator2<T1, T2 | T3 | T4>>

    Returns T1[]

  • see

    _.intersectionWith

    Type parameters

    • T

    Parameters

    • Optional array: List<T> | null
    • Rest ...values: Array<List<T>>

    Returns T[]

join

  • join(array: List<any> | null | undefined, separator?: undefined | string): string
  • Converts all elements in array into a string separated by separator.

    Parameters

    • array: List<any> | null | undefined

      The array to convert.

    • Optional separator: undefined | string

      The element separator.

    Returns string

    Returns the joined string.

last

  • last<T>(array: List<T> | null | undefined): T | undefined
  • Gets the last element of array.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    Returns T | undefined

    Returns the last element of array.

lastIndexOf

  • lastIndexOf<T>(array: List<T> | null | undefined, value: T, fromIndex?: true | number): number
  • This method is like _.indexOf except that it iterates over elements of array from right to left.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to search.

    • value: T

      The value to search for.

    • Optional fromIndex: true | number

      The index to search from or true to perform a binary search on a sorted array.

    Returns number

    Returns the index of the matched value, else -1.

nth

  • nth<T>(array: List<T> | null | undefined, n?: undefined | number): T | undefined
  • Gets the element at index n of array. If n is negative, the nth element from the end is returned.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      array The array to query.

    • Optional n: undefined | number

    Returns T | undefined

    Returns the nth element of array.

pull

  • pull<T>(array: T[], ...values: T[]): T[]
  • pull<T>(array: List<T>, ...values: T[]): List<T>
  • Removes all provided values from array using SameValueZero for equality comparisons.

    Note: Unlike _.without, this method mutates array.

    Type parameters

    • T

    Parameters

    • array: T[]

      The array to modify.

    • Rest ...values: T[]

      The values to remove.

    Returns T[]

    Returns array.

  • see

    _.pull

    Type parameters

    • T

    Parameters

    • array: List<T>
    • Rest ...values: T[]

    Returns List<T>

pullAll

  • pullAll<T>(array: T[], values?: List<T>): T[]
  • pullAll<T>(array: List<T>, values?: List<T>): List<T>
  • This method is like _.pull except that it accepts an array of values to remove.

    Note: Unlike _.difference, this method mutates array.

    category

    Array

    example

    var array = [1, 2, 3, 1, 2, 3];

    _.pull(array, [2, 3]); console.log(array); // => [1, 1]

    Type parameters

    • T

    Parameters

    • array: T[]

      The array to modify.

    • Optional values: List<T>

      The values to remove.

    Returns T[]

    Returns array.

  • see

    _.pullAll

    Type parameters

    • T

    Parameters

    • array: List<T>
    • Optional values: List<T>

    Returns List<T>

pullAllBy

  • This method is like _.pullAll except that it accepts iteratee which is invoked for each element of array and values to to generate the criterion by which uniqueness is computed. The iteratee is invoked with one argument: (value).

    Note: Unlike _.differenceBy, this method mutates array.

    category

    Array

    example

    var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];

    _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); console.log(array); // => [{ 'x': 2 }]

    Type parameters

    • T

    Parameters

    • array: T[]

      The array to modify.

    • Optional values: List<T>

      The values to remove.

    • Optional iteratee: ValueIteratee<T>

    Returns T[]

    Returns array.

  • see

    _.pullAllBy

    Type parameters

    • T

    Parameters

    Returns List<T>

  • see

    _.pullAllBy

    Type parameters

    • T1

    • T2

    Parameters

    Returns T1[]

  • see

    _.pullAllBy

    Type parameters

    • T1

    • T2

    Parameters

    Returns List<T1>

pullAllWith

  • This method is like _.pullAll except that it accepts comparator which is invoked to compare elements of array to values. The comparator is invoked with two arguments: (arrVal, othVal).

    Note: Unlike _.differenceWith, this method mutates array.

    category

    Array

    example

    var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];

    _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); console.log(array); // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]

    Type parameters

    • T

    Parameters

    • array: T[]

      The array to modify.

    • Optional values: List<T>

      The values to remove.

    • Optional comparator: Comparator<T>

    Returns T[]

    Returns array.

  • see

    _.pullAllWith

    Type parameters

    • T

    Parameters

    Returns List<T>

  • see

    _.pullAllWith

    Type parameters

    • T1

    • T2

    Parameters

    Returns T1[]

  • see

    _.pullAllWith

    Type parameters

    • T1

    • T2

    Parameters

    Returns List<T1>

pullAt

  • pullAt<T>(array: T[], ...indexes: Array<Many<number>>): T[]
  • pullAt<T>(array: List<T>, ...indexes: Array<Many<number>>): List<T>
  • Removes elements from array corresponding to the given indexes and returns an array of the removed elements. Indexes may be specified as an array of indexes or as individual arguments.

    Note: Unlike _.at, this method mutates array.

    Type parameters

    • T

    Parameters

    • array: T[]

      The array to modify.

    • Rest ...indexes: Array<Many<number>>

      The indexes of elements to remove, specified as individual indexes or arrays of indexes.

    Returns T[]

    Returns the new array of removed elements.

  • see

    _.pullAt

    Type parameters

    • T

    Parameters

    • array: List<T>
    • Rest ...indexes: Array<Many<number>>

    Returns List<T>

remove

  • Removes all elements from array that predicate returns truthy for and returns an array of the removed elements. The predicate is invoked with three arguments: (value, index, array).

    Note: Unlike _.filter, this method mutates array.

    Type parameters

    • T

    Parameters

    • array: List<T>

      The array to modify.

    • Optional predicate: ListIteratee<T>

      The function invoked per iteration.

    Returns T[]

    Returns the new array of removed elements.

reverse

  • reverse<TList>(array: TList): TList
  • Reverses array so that the first element becomes the last, the second element becomes the second to last, and so on.

    Note: This method mutates array and is based on Array#reverse.

    category

    Array

    example

    var array = [1, 2, 3];

    _.reverse(array); // => [3, 2, 1]

    console.log(array); // => [3, 2, 1]

    Type parameters

    Parameters

    • array: TList

    Returns TList

    Returns array.

slice

  • slice<T>(array: List<T> | null | undefined, start?: undefined | number, end?: undefined | number): T[]
  • Creates a slice of array from start up to, but not including, end.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to slice.

    • Optional start: undefined | number

      The start position.

    • Optional end: undefined | number

      The end position.

    Returns T[]

    Returns the slice of array.

sortedIndex

  • sortedIndex<T>(array: List<T> | null | undefined, value: T): number
  • sortedIndex<T>(array: List<T> | null | undefined, value: T): number
  • Uses a binary search to determine the lowest index at which value should be inserted into array in order to maintain its sort order.

    category

    Array

    example

    _.sortedIndex([30, 50], 40); // => 1

    _.sortedIndex([4, 5], 4); // => 0

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The sorted array to inspect.

    • value: T

      The value to evaluate.

    Returns number

    Returns the index at which value should be inserted into array.

  • Uses a binary search to determine the lowest index at which value should be inserted into array in order to maintain its sort order.

    category

    Array

    example

    _.sortedIndex([30, 50], 40); // => 1

    _.sortedIndex([4, 5], 4); // => 0

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The sorted array to inspect.

    • value: T

      The value to evaluate.

    Returns number

    Returns the index at which value should be inserted into array.

sortedIndexBy

  • sortedIndexBy<T>(array: List<T> | null | undefined, value: T, iteratee?: ValueIteratee<T>): number
  • This method is like _.sortedIndex except that it accepts iteratee which is invoked for value and each element of array to compute their sort ranking. The iteratee is invoked with one argument: (value).

    category

    Array

    example

    var dict = { 'thirty': 30, 'forty': 40, 'fifty': 50 };

    _.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict)); // => 1

    // using the _.property iteratee shorthand _.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); // => 0

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The sorted array to inspect.

    • value: T

      The value to evaluate.

    • Optional iteratee: ValueIteratee<T>

    Returns number

    Returns the index at which value should be inserted into array.

sortedIndexOf

  • sortedIndexOf<T>(array: List<T> | null | undefined, value: T): number
  • This method is like _.indexOf except that it performs a binary search on a sorted array.

    category

    Array

    example

    _.sortedIndexOf([1, 1, 2, 2], 2); // => 2

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to search.

    • value: T

      The value to search for.

    Returns number

    Returns the index of the matched value, else -1.

sortedLastIndex

  • sortedLastIndex<T>(array: List<T> | null | undefined, value: T): number
  • This method is like _.sortedIndex except that it returns the highest index at which value should be inserted into array in order to maintain its sort order.

    category

    Array

    example

    _.sortedLastIndex([4, 5], 4); // => 1

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The sorted array to inspect.

    • value: T

      The value to evaluate.

    Returns number

    Returns the index at which value should be inserted into array.

sortedLastIndexBy

  • sortedLastIndexBy<T>(array: List<T> | null | undefined, value: T, iteratee: ValueIteratee<T>): number
  • This method is like _.sortedLastIndex except that it accepts iteratee which is invoked for value and each element of array to compute their sort ranking. The iteratee is invoked with one argument: (value).

    category

    Array

    example

    // using the _.property iteratee shorthand _.sortedLastIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); // => 1

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The sorted array to inspect.

    • value: T

      The value to evaluate.

    • iteratee: ValueIteratee<T>

    Returns number

    Returns the index at which value should be inserted into array.

sortedLastIndexOf

  • sortedLastIndexOf<T>(array: List<T> | null | undefined, value: T): number
  • This method is like _.lastIndexOf except that it performs a binary search on a sorted array.

    category

    Array

    example

    _.sortedLastIndexOf([1, 1, 2, 2], 2); // => 3

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to search.

    • value: T

      The value to search for.

    Returns number

    Returns the index of the matched value, else -1.

sortedUniq

  • sortedUniq<T>(array: List<T> | null | undefined): T[]
  • This method is like _.uniq except that it's designed and optimized for sorted arrays.

    category

    Array

    example

    _.sortedUniq([1, 1, 2]); // => [1, 2]

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to inspect.

    Returns T[]

    Returns the new duplicate free array.

sortedUniqBy

  • sortedUniqBy<T>(array: List<T> | null | undefined, iteratee: ValueIteratee<T>): T[]
  • This method is like _.uniqBy except that it's designed and optimized for sorted arrays.

    category

    Array

    example

    _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); // => [1.1, 2.2]

    Type parameters

    • T

    Parameters

    Returns T[]

    Returns the new duplicate free array.

tail

  • tail<T>(array: List<T> | null | undefined): T[]
  • Gets all but the first element of array.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    Returns T[]

    Returns the slice of array.

take

  • take<T>(array: List<T> | null | undefined, n?: undefined | number): T[]
  • Creates a slice of array with n elements taken from the beginning.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    • Optional n: undefined | number

      The number of elements to take.

    Returns T[]

    Returns the slice of array.

takeRight

  • takeRight<T>(array: List<T> | null | undefined, n?: undefined | number): T[]
  • Creates a slice of array with n elements taken from the end.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    • Optional n: undefined | number

      The number of elements to take.

    Returns T[]

    Returns the slice of array.

takeRightWhile

  • takeRightWhile<T>(array: List<T> | null | undefined, predicate?: ListIteratee<T>): T[]
  • Creates a slice of array with elements taken from the end. Elements are taken until predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    • Optional predicate: ListIteratee<T>

      The function invoked per iteration.

    Returns T[]

    Returns the slice of array.

takeWhile

  • takeWhile<T>(array: List<T> | null | undefined, predicate?: ListIteratee<T>): T[]
  • Creates a slice of array with elements taken from the beginning. Elements are taken until predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to query.

    • Optional predicate: ListIteratee<T>

      The function invoked per iteration.

    Returns T[]

    Returns the slice of array.

union

  • union<T>(...arrays: Array<List<T> | null | undefined>): T[]
  • Creates an array of unique values, in order, from all of the provided arrays using SameValueZero for equality comparisons.

    Type parameters

    • T

    Parameters

    • Rest ...arrays: Array<List<T> | null | undefined>

      The arrays to inspect.

    Returns T[]

    Returns the new array of combined values.

unionBy

  • unionBy<T>(arrays: List<T> | null | undefined, iteratee?: ValueIteratee<T>): T[]
  • unionBy<T>(arrays1: List<T> | null | undefined, arrays2: List<T> | null | undefined, iteratee?: ValueIteratee<T>): T[]
  • unionBy<T>(arrays1: List<T> | null | undefined, arrays2: List<T> | null | undefined, arrays3: List<T> | null | undefined, iteratee?: ValueIteratee<T>): T[]
  • unionBy<T>(arrays1: List<T> | null | undefined, arrays2: List<T> | null | undefined, arrays3: List<T> | null | undefined, arrays4: List<T> | null | undefined, iteratee?: ValueIteratee<T>): T[]
  • unionBy<T>(arrays1: List<T> | null | undefined, arrays2: List<T> | null | undefined, arrays3: List<T> | null | undefined, arrays4: List<T> | null | undefined, arrays5: List<T> | null | undefined, ...iteratee: Array<ValueIteratee<T> | List<T> | null | undefined>): T[]
  • This method is like _.union except that it accepts iteratee which is invoked for each element of each arrays to generate the criterion by which uniqueness is computed. The iteratee is invoked with one argument: (value).

    Type parameters

    • T

    Parameters

    • arrays: List<T> | null | undefined

      The arrays to inspect.

    • Optional iteratee: ValueIteratee<T>

      The iteratee invoked per element.

    Returns T[]

    Returns the new array of combined values.

  • see

    _.unionBy

    Type parameters

    • T

    Parameters

    • arrays1: List<T> | null | undefined
    • arrays2: List<T> | null | undefined
    • Optional iteratee: ValueIteratee<T>

    Returns T[]

  • see

    _.unionBy

    Type parameters

    • T

    Parameters

    • arrays1: List<T> | null | undefined
    • arrays2: List<T> | null | undefined
    • arrays3: List<T> | null | undefined
    • Optional iteratee: ValueIteratee<T>

    Returns T[]

  • see

    _.unionBy

    Type parameters

    • T

    Parameters

    • arrays1: List<T> | null | undefined
    • arrays2: List<T> | null | undefined
    • arrays3: List<T> | null | undefined
    • arrays4: List<T> | null | undefined
    • Optional iteratee: ValueIteratee<T>

    Returns T[]

  • see

    _.unionBy

    Type parameters

    • T

    Parameters

    • arrays1: List<T> | null | undefined
    • arrays2: List<T> | null | undefined
    • arrays3: List<T> | null | undefined
    • arrays4: List<T> | null | undefined
    • arrays5: List<T> | null | undefined
    • Rest ...iteratee: Array<ValueIteratee<T> | List<T> | null | undefined>

    Returns T[]

unionWith

  • unionWith<T>(arrays: List<T> | null | undefined, comparator?: Comparator<T>): T[]
  • unionWith<T>(arrays: List<T> | null | undefined, arrays2: List<T> | null | undefined, comparator?: Comparator<T>): T[]
  • unionWith<T>(arrays: List<T> | null | undefined, arrays2: List<T> | null | undefined, arrays3: List<T> | null | undefined, ...comparator: Array<Comparator<T> | List<T> | null | undefined>): T[]
  • This method is like _.union except that it accepts comparator which is invoked to compare elements of arrays. The comparator is invoked with two arguments: (arrVal, othVal).

    category

    Array

    example

    var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];

    _.unionWith(objects, others, _.isEqual); // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]

    Type parameters

    • T

    Parameters

    • arrays: List<T> | null | undefined
    • Optional comparator: Comparator<T>

    Returns T[]

    Returns the new array of combined values.

  • see

    _.unionBy

    Type parameters

    • T

    Parameters

    • arrays: List<T> | null | undefined
    • arrays2: List<T> | null | undefined
    • Optional comparator: Comparator<T>

    Returns T[]

  • see

    _.unionWith

    Type parameters

    • T

    Parameters

    • arrays: List<T> | null | undefined
    • arrays2: List<T> | null | undefined
    • arrays3: List<T> | null | undefined
    • Rest ...comparator: Array<Comparator<T> | List<T> | null | undefined>

    Returns T[]

uniq

  • uniq<T>(array: List<T> | null | undefined): T[]
  • Creates a duplicate-free version of an array, using SameValueZero for equality comparisons, in which only the first occurrence of each element is kept.

    category

    Array

    example

    _.uniq([2, 1, 2]); // => [2, 1]

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to inspect.

    Returns T[]

    Returns the new duplicate free array.

uniqBy

  • This method is like _.uniq except that it accepts iteratee which is invoked for each element in array to generate the criterion by which uniqueness is computed. The iteratee is invoked with one argument: (value).

    category

    Array

    example

    _.uniqBy([2.1, 1.2, 2.3], Math.floor); // => [2.1, 1.2]

    // using the _.property iteratee shorthand _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); // => [{ 'x': 1 }, { 'x': 2 }]

    Type parameters

    • T

    Parameters

    Returns T[]

    Returns the new duplicate free array.

uniqWith

  • uniqWith<T>(array: List<T> | null | undefined, comparator?: Comparator<T>): T[]
  • This method is like _.uniq except that it accepts comparator which is invoked to compare elements of array. The comparator is invoked with two arguments: (arrVal, othVal).

    category

    Array

    example

    var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];

    _.uniqWith(objects, _.isEqual); // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to inspect.

    • Optional comparator: Comparator<T>

    Returns T[]

    Returns the new duplicate free array.

unzip

  • unzip<T>(array: T[][] | List<List<T>> | null | undefined): T[][]
  • This method is like _.zip except that it accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.

    Type parameters

    • T

    Parameters

    • array: T[][] | List<List<T>> | null | undefined

      The array of grouped elements to process.

    Returns T[][]

    Returns the new array of regrouped elements.

unzipWith

  • unzipWith<T, TResult>(array: List<List<T>> | null | undefined, iteratee: function): TResult[]
  • unzipWith<T>(array: List<List<T>> | null | undefined): T[][]
  • This method is like _.unzip except that it accepts an iteratee to specify how regrouped values should be combined. The iteratee is invoked with four arguments: (accumulator, value, index, group).

    Type parameters

    • T

    • TResult

    Parameters

    • array: List<List<T>> | null | undefined

      The array of grouped elements to process.

    • iteratee: function

      The function to combine regrouped values.

        • (...values: T[]): TResult
        • Parameters

          • Rest ...values: T[]

          Returns TResult

    Returns TResult[]

    Returns the new array of regrouped elements.

  • see

    _.unzipWith

    Type parameters

    • T

    Parameters

    • array: List<List<T>> | null | undefined

    Returns T[][]

without

  • without<T>(array: List<T> | null | undefined, ...values: T[]): T[]
  • Creates an array excluding all provided values using SameValueZero for equality comparisons.

    Type parameters

    • T

    Parameters

    • array: List<T> | null | undefined

      The array to filter.

    • Rest ...values: T[]

      The values to exclude.

    Returns T[]

    Returns the new array of filtered values.

xor

  • xor<T>(...arrays: Array<List<T> | null | undefined>): T[]
  • Creates an array of unique values that is the symmetric difference of the provided arrays.

    Type parameters

    • T

    Parameters

    • Rest ...arrays: Array<List<T> | null | undefined>

      The arrays to inspect.

    Returns T[]

    Returns the new array of values.

xorBy

  • xorBy<T>(arrays: List<T> | null | undefined, iteratee?: ValueIteratee<T>): T[]
  • xorBy<T>(arrays: List<T> | null | undefined, arrays2: List<T> | null | undefined, iteratee?: ValueIteratee<T>): T[]
  • xorBy<T>(arrays: List<T> | null | undefined, arrays2: List<T> | null | undefined, arrays3: List<T> | null | undefined, ...iteratee: Array<ValueIteratee<T> | List<T> | null | undefined>): T[]
  • This method is like _.xor except that it accepts iteratee which is invoked for each element of each arrays to generate the criterion by which uniqueness is computed. The iteratee is invoked with one argument: (value).

    category

    Array

    example

    _.xorBy([2.1, 1.2], [4.3, 2.4], Math.floor); // => [1.2, 4.3]

    // using the _.property iteratee shorthand _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); // => [{ 'x': 2 }]

    Type parameters

    • T

    Parameters

    Returns T[]

    Returns the new array of values.

  • see

    _.xorBy

    Type parameters

    • T

    Parameters

    • arrays: List<T> | null | undefined
    • arrays2: List<T> | null | undefined
    • Optional iteratee: ValueIteratee<T>

    Returns T[]

  • see

    _.xorBy

    Type parameters

    • T

    Parameters

    • arrays: List<T> | null | undefined
    • arrays2: List<T> | null | undefined
    • arrays3: List<T> | null | undefined
    • Rest ...iteratee: Array<ValueIteratee<T> | List<T> | null | undefined>

    Returns T[]

xorWith

  • xorWith<T>(arrays: List<T> | null | undefined, comparator?: Comparator<T>): T[]
  • xorWith<T>(arrays: List<T> | null | undefined, arrays2: List<T> | null | undefined, comparator?: Comparator<T>): T[]
  • xorWith<T>(arrays: List<T> | null | undefined, arrays2: List<T> | null | undefined, arrays3: List<T> | null | undefined, ...comparator: Array<Comparator<T> | List<T> | null | undefined>): T[]
  • This method is like _.xor except that it accepts comparator which is invoked to compare elements of arrays. The comparator is invoked with two arguments: (arrVal, othVal).

    category

    Array

    example

    var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];

    _.xorWith(objects, others, _.isEqual); // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]

    Type parameters

    • T

    Parameters

    • arrays: List<T> | null | undefined
    • Optional comparator: Comparator<T>

    Returns T[]

    Returns the new array of values.

  • see

    _.xorWith

    Type parameters

    • T

    Parameters

    • arrays: List<T> | null | undefined
    • arrays2: List<T> | null | undefined
    • Optional comparator: Comparator<T>

    Returns T[]

  • see

    _.xorWith

    Type parameters

    • T

    Parameters

    • arrays: List<T> | null | undefined
    • arrays2: List<T> | null | undefined
    • arrays3: List<T> | null | undefined
    • Rest ...comparator: Array<Comparator<T> | List<T> | null | undefined>

    Returns T[]

zip

  • zip<T1, T2>(arrays1: List<T1>, arrays2: List<T2>): Array<[T1 | undefined, T2 | undefined]>
  • zip<T1, T2, T3>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>): Array<[T1 | undefined, T2 | undefined, T3 | undefined]>
  • zip<T1, T2, T3, T4>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>, arrays4: List<T4>): Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined]>
  • zip<T1, T2, T3, T4, T5>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>, arrays4: List<T4>, arrays5: List<T5>): Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined, T5 | undefined]>
  • zip<T>(...arrays: Array<List<T> | null | undefined>): Array<Array<T | undefined>>
  • Creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on.

    Type parameters

    • T1

    • T2

    Parameters

    Returns Array<[T1 | undefined, T2 | undefined]>

    Returns the new array of grouped elements.

  • see

    _.zip

    Type parameters

    • T1

    • T2

    • T3

    Parameters

    Returns Array<[T1 | undefined, T2 | undefined, T3 | undefined]>

  • see

    _.zip

    Type parameters

    • T1

    • T2

    • T3

    • T4

    Parameters

    Returns Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined]>

  • see

    _.zip

    Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    Returns Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined, T5 | undefined]>

  • see

    _.zip

    Type parameters

    • T

    Parameters

    • Rest ...arrays: Array<List<T> | null | undefined>

    Returns Array<Array<T | undefined>>

zipObject

  • This method is like _.fromPairs except that it accepts two arrays, one of property identifiers and one of corresponding values.

    Type parameters

    • T

    Parameters

    Returns Dictionary<T>

    Returns the new object.

  • see

    _.zipObject

    Parameters

    Returns Dictionary<undefined>

zipObjectDeep

  • This method is like _.zipObject except that it supports property paths.

    Parameters

    • Optional paths: List<PropertyPath>

      The property names.

    • Optional values: List<any>

      The property values.

    Returns object

    Returns the new object.

zipWith

  • zipWith<T, TResult>(arrays: List<T>, iteratee: function): TResult[]
  • zipWith<T1, T2, TResult>(arrays1: List<T1>, arrays2: List<T2>, iteratee: function): TResult[]
  • zipWith<T1, T2, T3, TResult>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>, iteratee: function): TResult[]
  • zipWith<T1, T2, T3, T4, TResult>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>, arrays4: List<T4>, iteratee: function): TResult[]
  • zipWith<T1, T2, T3, T4, T5, TResult>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>, arrays4: List<T4>, arrays5: List<T5>, iteratee: function): TResult[]
  • zipWith<T, TResult>(...iteratee: Array<function | List<T> | null | undefined>): TResult[]
  • This method is like _.zip except that it accepts an iteratee to specify how grouped values should be combined. The iteratee is invoked with four arguments: (accumulator, value, index, group).

    Type parameters

    • T

    • TResult

    Parameters

    • arrays: List<T>

      The arrays to process.

    • iteratee: function

      The function to combine grouped values.

        • (value1: T): TResult
        • Parameters

          • value1: T

          Returns TResult

    Returns TResult[]

    Returns the new array of grouped elements.

  • see

    _.zipWith

    Type parameters

    • T1

    • T2

    • TResult

    Parameters

    • arrays1: List<T1>
    • arrays2: List<T2>
    • iteratee: function
        • (value1: T1, value2: T2): TResult
        • Parameters

          • value1: T1
          • value2: T2

          Returns TResult

    Returns TResult[]

  • see

    _.zipWith

    Type parameters

    • T1

    • T2

    • T3

    • TResult

    Parameters

    • arrays1: List<T1>
    • arrays2: List<T2>
    • arrays3: List<T3>
    • iteratee: function
        • (value1: T1, value2: T2, value3: T3): TResult
        • Parameters

          • value1: T1
          • value2: T2
          • value3: T3

          Returns TResult

    Returns TResult[]

  • see

    _.zipWith

    Type parameters

    • T1

    • T2

    • T3

    • T4

    • TResult

    Parameters

    • arrays1: List<T1>
    • arrays2: List<T2>
    • arrays3: List<T3>
    • arrays4: List<T4>
    • iteratee: function
        • (value1: T1, value2: T2, value3: T3, value4: T4): TResult
        • Parameters

          • value1: T1
          • value2: T2
          • value3: T3
          • value4: T4

          Returns TResult

    Returns TResult[]

  • see

    _.zipWith

    Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • TResult

    Parameters

    • arrays1: List<T1>
    • arrays2: List<T2>
    • arrays3: List<T3>
    • arrays4: List<T4>
    • arrays5: List<T5>
    • iteratee: function
        • (value1: T1, value2: T2, value3: T3, value4: T4, value5: T5): TResult
        • Parameters

          • value1: T1
          • value2: T2
          • value3: T3
          • value4: T4
          • value5: T5

          Returns TResult

    Returns TResult[]

  • see

    _.zipWith

    Type parameters

    • T

    • TResult

    Parameters

    • Rest ...iteratee: Array<function | List<T> | null | undefined>

    Returns TResult[]

Generated using TypeDoc