Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • LoDashStatic

Index

Properties

each

each: forEach

eachRight

eachRight: forEachRight

Methods

countBy

  • Creates an object composed of keys generated from the results of running each element of collection through iteratee. The corresponding value of each key is the number of times the key was returned by iteratee. The iteratee is invoked with one argument: (value).

    Type parameters

    • T

    Parameters

    • collection: List<T> | null | undefined

      The collection to iterate over.

    • Optional iteratee: ValueIteratee<T>

      The function invoked per iteration.

    Returns Dictionary<number>

    Returns the composed aggregate object.

  • see

    _.countBy

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined
    • Optional iteratee: ValueIteratee<T[keyof T]>

    Returns Dictionary<number>

every

  • Checks if predicate returns truthy for all elements of collection. Iteration is stopped once predicate returns falsey. The predicate is invoked with three arguments: (value, index|key, collection).

    Type parameters

    • T

    Parameters

    • collection: List<T> | null | undefined

      The collection to iterate over.

    • Optional predicate: ListIterateeCustom<T, boolean>

      The function invoked per iteration.

    Returns boolean

    Returns true if all elements pass the predicate check, else false.

  • see

    _.every

    Type parameters

    • T: object

    Parameters

    Returns boolean

filter

  • Iterates over elements of collection, returning an array of all elements predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).

    Parameters

    • collection: string | null | undefined

      The collection to iterate over.

    • Optional predicate: StringIterator<boolean>

      The function invoked per iteration.

    Returns string[]

    Returns the new filtered array.

  • see

    _.filter

    Type parameters

    • T

    • S: T

    Parameters

    Returns S[]

  • see

    _.filter

    Type parameters

    • T

    Parameters

    Returns T[]

  • see

    _.filter

    Type parameters

    • T: object

    • S: T[keyof T]

    Parameters

    Returns S[]

  • see

    _.filter

    Type parameters

    • T: object

    Parameters

    Returns Array<T[keyof T]>

find

  • find<T, S>(collection: List<T> | null | undefined, predicate: ListIteratorTypeGuard<T, S>, fromIndex?: undefined | number): S | undefined
  • find<T>(collection: List<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: undefined | number): T | undefined
  • find<T, S>(collection: T | null | undefined, predicate: ObjectIteratorTypeGuard<T, S>, fromIndex?: undefined | number): S | undefined
  • find<T>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>, fromIndex?: undefined | number): T[keyof T] | undefined
  • Iterates over elements of collection, returning the first element predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).

    Type parameters

    • T

    • S: T

    Parameters

    • collection: List<T> | null | undefined

      The collection to search.

    • predicate: ListIteratorTypeGuard<T, S>

      The function invoked per iteration.

    • Optional fromIndex: undefined | number

      The index to search from.

    Returns S | undefined

    Returns the matched element, else undefined.

  • see

    _.find

    Type parameters

    • T

    Parameters

    • collection: List<T> | null | undefined
    • Optional predicate: ListIterateeCustom<T, boolean>
    • Optional fromIndex: undefined | number

    Returns T | undefined

  • see

    _.find

    Type parameters

    • T: object

    • S: T[keyof T]

    Parameters

    Returns S | undefined

  • see

    _.find

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined
    • Optional predicate: ObjectIterateeCustom<T, boolean>
    • Optional fromIndex: undefined | number

    Returns T[keyof T] | undefined

findLast

  • findLast<T, S>(collection: List<T> | null | undefined, predicate: ListIteratorTypeGuard<T, S>, fromIndex?: undefined | number): S | undefined
  • findLast<T>(collection: List<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: undefined | number): T | undefined
  • findLast<T, S>(collection: T | null | undefined, predicate: ObjectIteratorTypeGuard<T, S>, fromIndex?: undefined | number): S | undefined
  • findLast<T>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>, fromIndex?: undefined | number): T[keyof T] | undefined
  • This method is like _.find except that it iterates over elements of a collection from right to left.

    Type parameters

    • T

    • S: T

    Parameters

    • collection: List<T> | null | undefined

      Searches for a value in this list.

    • predicate: ListIteratorTypeGuard<T, S>

      The function called per iteration.

    • Optional fromIndex: undefined | number

      The index to search from.

    Returns S | undefined

    The found element, else undefined.

  • see

    _.findLast

    Type parameters

    • T

    Parameters

    • collection: List<T> | null | undefined
    • Optional predicate: ListIterateeCustom<T, boolean>
    • Optional fromIndex: undefined | number

    Returns T | undefined

  • see

    _.findLast

    Type parameters

    • T: object

    • S: T[keyof T]

    Parameters

    Returns S | undefined

  • see

    _.findLast

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined
    • Optional predicate: ObjectIterateeCustom<T, boolean>
    • Optional fromIndex: undefined | number

    Returns T[keyof T] | undefined

flatMap

  • flatMap<T>(collection: List<Many<T>> | Dictionary<Many<T>> | NumericDictionary<Many<T>> | null | undefined): T[]
  • flatMap(collection: object | null | undefined): any[]
  • flatMap<T, TResult>(collection: List<T> | null | undefined, iteratee: ListIterator<T, Many<TResult>>): TResult[]
  • flatMap<T, TResult>(collection: T | null | undefined, iteratee: ObjectIterator<T, Many<TResult>>): TResult[]
  • flatMap(collection: object | null | undefined, iteratee: string): any[]
  • flatMap(collection: object | null | undefined, iteratee: object): boolean[]
  • Creates an array of flattened values by running each element in collection through iteratee and concating its result to the other mapped values. The iteratee is invoked with three arguments: (value, index|key, collection).

    Type parameters

    • T

    Parameters

    Returns T[]

    Returns the new flattened array.

  • see

    _.flatMap

    Parameters

    • collection: object | null | undefined

    Returns any[]

  • see

    _.flatMap

    Type parameters

    • T

    • TResult

    Parameters

    Returns TResult[]

  • see

    _.flatMap

    Type parameters

    • T: object

    • TResult

    Parameters

    Returns TResult[]

  • see

    _.flatMap

    Parameters

    • collection: object | null | undefined
    • iteratee: string

    Returns any[]

  • see

    _.flatMap

    Parameters

    • collection: object | null | undefined
    • iteratee: object

    Returns boolean[]

flatMapDeep

  • This method is like _.flatMap except that it recursively flattens the mapped results.

    since

    4.7.0

    category

    Collection

    example

    function duplicate(n) { return [[[n, n]]]; }

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

    Type parameters

    • T

    Parameters

    Returns T[]

    Returns the new flattened array.

  • see

    _.flatMapDeep

    Type parameters

    • T

    • TResult

    Parameters

    Returns TResult[]

  • see

    _.flatMapDeep

    Type parameters

    • T: object

    • TResult

    Parameters

    Returns TResult[]

  • see

    _.flatMapDeep

    Parameters

    • collection: object | null | undefined
    • iteratee: string

    Returns any[]

  • see

    _.flatMapDeep

    Parameters

    • collection: object | null | undefined
    • iteratee: object

    Returns boolean[]

flatMapDepth

  • This method is like _.flatMap except that it recursively flattens the mapped results up to depth times.

    since

    4.7.0

    category

    Collection

    example

    function duplicate(n) { return [[[n, n]]]; }

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

    Type parameters

    • T

    Parameters

    Returns T[]

    Returns the new flattened array.

  • see

    _.flatMapDepth

    Type parameters

    • T

    • TResult

    Parameters

    Returns TResult[]

  • see

    _.flatMapDepth

    Type parameters

    • T: object

    • TResult

    Parameters

    Returns TResult[]

  • see

    _.flatMapDepth

    Parameters

    • collection: object | null | undefined
    • iteratee: string
    • Optional depth: undefined | number

    Returns any[]

  • see

    _.flatMapDepth

    Parameters

    • collection: object | null | undefined
    • iteratee: object
    • Optional depth: undefined | number

    Returns boolean[]

forEach

  • forEach<T>(collection: T[], iteratee?: ArrayIterator<T, any>): T[]
  • forEach(collection: string, iteratee?: StringIterator<any>): string
  • forEach<T>(collection: List<T>, iteratee?: ListIterator<T, any>): List<T>
  • forEach<T>(collection: T, iteratee?: ObjectIterator<T, any>): T
  • forEach<T, TArray>(collection: TArray & undefined | null | T[], iteratee?: ArrayIterator<T, any>): TArray
  • forEach<TString>(collection: TString, iteratee?: StringIterator<any>): TString
  • forEach<T, TList>(collection: TList & undefined | null | ArrayLike<T>, iteratee?: ListIterator<T, any>): TList
  • forEach<T>(collection: T | null | undefined, iteratee?: ObjectIterator<T, any>): T | null | undefined
  • Iterates over elements of collection invoking iteratee for each element. The iteratee is invoked with three arguments: (value, index|key, collection). Iteratee functions may exit iteration early by explicitly returning false.

    Note: As with other "Collections" methods, objects with a "length" property are iterated like arrays. To avoid this behavior _.forIn or _.forOwn may be used for object iteration.

    alias

    _.each

    Type parameters

    • T

    Parameters

    • collection: T[]

      The collection to iterate over.

    • Optional iteratee: ArrayIterator<T, any>

      The function invoked per iteration.

    Returns T[]

  • see

    _.forEach

    Parameters

    Returns string

  • see

    _.forEach

    Type parameters

    • T

    Parameters

    Returns List<T>

  • see

    _.forEach

    Type parameters

    • T: object

    Parameters

    Returns T

  • see

    _.forEach

    Type parameters

    • T

    • TArray: T[] | null | undefined

    Parameters

    • collection: TArray & undefined | null | T[]
    • Optional iteratee: ArrayIterator<T, any>

    Returns TArray

  • see

    _.forEach

    Type parameters

    • TString: string | null | undefined

    Parameters

    Returns TString

  • see

    _.forEach

    Type parameters

    • T

    • TList: List<T> | null | undefined

    Parameters

    Returns TList

  • see

    _.forEach

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined
    • Optional iteratee: ObjectIterator<T, any>

    Returns T | null | undefined

forEachRight

  • forEachRight<T>(collection: T[], iteratee?: ArrayIterator<T, any>): T[]
  • forEachRight(collection: string, iteratee?: StringIterator<any>): string
  • forEachRight<T>(collection: List<T>, iteratee?: ListIterator<T, any>): List<T>
  • forEachRight<T>(collection: T, iteratee?: ObjectIterator<T, any>): T
  • forEachRight<T, TArray>(collection: TArray & undefined | null | T[], iteratee?: ArrayIterator<T, any>): TArray
  • forEachRight<TString>(collection: TString, iteratee?: StringIterator<any>): TString
  • forEachRight<T, TList>(collection: TList & undefined | null | ArrayLike<T>, iteratee?: ListIterator<T, any>): TList
  • forEachRight<T>(collection: T | null | undefined, iteratee?: ObjectIterator<T, any>): T | null | undefined
  • This method is like _.forEach except that it iterates over elements of collection from right to left.

    alias

    _.eachRight

    Type parameters

    • T

    Parameters

    • collection: T[]

      The collection to iterate over.

    • Optional iteratee: ArrayIterator<T, any>

      The function called per iteration.

    Returns T[]

  • see

    _.forEachRight

    Parameters

    Returns string

  • see

    _.forEachRight

    Type parameters

    • T

    Parameters

    Returns List<T>

  • see

    _.forEachRight

    Type parameters

    • T: object

    Parameters

    Returns T

  • see

    _.forEachRight

    Type parameters

    • T

    • TArray: T[] | null | undefined

    Parameters

    • collection: TArray & undefined | null | T[]
    • Optional iteratee: ArrayIterator<T, any>

    Returns TArray

  • see

    _.forEachRight

    Type parameters

    • TString: string | null | undefined

    Parameters

    Returns TString

  • see

    _.forEachRight

    Type parameters

    • T

    • TList: List<T> | null | undefined

    Parameters

    Returns TList

  • see

    _.forEachRight

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined
    • Optional iteratee: ObjectIterator<T, any>

    Returns T | null | undefined

groupBy

  • Creates an object composed of keys generated from the results of running each element of collection through iteratee. The corresponding value of each key is an array of the elements responsible for generating the key. The iteratee is invoked with one argument: (value).

    Type parameters

    • T

    Parameters

    • collection: List<T> | null | undefined

      The collection to iterate over.

    • Optional iteratee: ValueIteratee<T>

      The function invoked per iteration.

    Returns Dictionary<T[]>

    Returns the composed aggregate object.

  • see

    _.groupBy

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined
    • Optional iteratee: ValueIteratee<T[keyof T]>

    Returns Dictionary<Array<T[keyof T]>>

includes

  • Checks if target is in collection using SameValueZero for equality comparisons. If fromIndex is negative, it’s used as the offset from the end of collection.

    Type parameters

    • T

    Parameters

    • collection: List<T> | Dictionary<T> | NumericDictionary<T> | null | undefined

      The collection to search.

    • target: T

      The value to search for.

    • Optional fromIndex: undefined | number

      The index to search from.

    Returns boolean

    True if the target element is found, else false.

invokeMap

  • invokeMap(collection: object | null | undefined, methodName: string, ...args: any[]): any[]
  • invokeMap<TResult>(collection: object | null | undefined, method: function, ...args: any[]): TResult[]
  • Invokes the method named by methodName on each element in the collection returning an array of the results of each invoked method. Additional arguments will be provided to each invoked method. If methodName is a function it will be invoked for, and this bound to, each element in the collection.

    Parameters

    • collection: object | null | undefined

      The collection to iterate over.

    • methodName: string

      The name of the method to invoke.

    • Rest ...args: any[]

      Arguments to invoke the method with.

    Returns any[]

  • see

    _.invokeMap

    Type parameters

    • TResult

    Parameters

    • collection: object | null | undefined
    • method: function
        • (...args: any[]): TResult
        • Parameters

          • Rest ...args: any[]

          Returns TResult

    • Rest ...args: any[]

    Returns TResult[]

keyBy

  • Creates an object composed of keys generated from the results of running each element of collection through iteratee. The corresponding value of each key is the last element responsible for generating the key. The iteratee function is invoked with one argument: (value).

    Type parameters

    • T

    Parameters

    Returns Dictionary<T>

    Returns the composed aggregate object.

  • see

    _.keyBy

    Type parameters

    • T: object

    Parameters

    Returns Dictionary<T[keyof T]>

map

  • Creates an array of values by running each element in collection through iteratee. The iteratee is invoked with three arguments: (value, index|key, collection).

    Many lodash methods are guarded to work as iteratees for methods like _.every, _.filter, _.map, _.mapValues, _.reject, and _.some.

    The guarded methods are: ary, callback, chunk, clone, create, curry, curryRight, drop, dropRight, every, fill, flatten, invert, max, min, parseInt, slice, sortBy, take, takeRight, template, trim, trimLeft, trimRight, trunc, random, range, sample, some, sum, uniq, and words

    Type parameters

    • T

    • TResult

    Parameters

    • collection: T[] | null | undefined

      The collection to iterate over.

    • iteratee: ArrayIterator<T, TResult>

      The function invoked per iteration.

    Returns TResult[]

    Returns the new mapped array.

  • see

    _.map

    Type parameters

    • T

    • TResult

    Parameters

    Returns TResult[]

  • see

    _.map

    Type parameters

    • T

    Parameters

    Returns T[]

  • see

    _.map

    Type parameters

    • T: object

    • TResult

    Parameters

    • collection: T | null | undefined
    • iteratee: ObjectIterator<T, TResult>

    Returns TResult[]

  • see

    _.map

    Type parameters

    • T

    • K: keyof T

    Parameters

    Returns Array<T[K]>

  • see

    _.map

    Type parameters

    • T

    Parameters

    Returns any[]

  • see

    _.map

    Type parameters

    • T

    Parameters

    Returns boolean[]

orderBy

  • orderBy<T>(collection: List<T> | null | undefined, iteratees?: Many<ListIterator<T, NotVoid>>, orders?: Many<boolean | "asc" | "desc">): T[]
  • orderBy<T>(collection: List<T> | null | undefined, iteratees?: Many<ListIteratee<T>>, orders?: Many<boolean | "asc" | "desc">): T[]
  • orderBy<T>(collection: T | null | undefined, iteratees?: Many<ObjectIterator<T, NotVoid>>, orders?: Many<boolean | "asc" | "desc">): Array<T[keyof T]>
  • orderBy<T>(collection: T | null | undefined, iteratees?: Many<ObjectIteratee<T>>, orders?: Many<boolean | "asc" | "desc">): Array<T[keyof T]>
  • This method is like _.sortBy except that it allows specifying the sort orders of the iteratees to sort by. If orders is unspecified, all values are sorted in ascending order. Otherwise, specify an order of "desc" for descending or "asc" for ascending sort order of corresponding values.

    category

    Collection

    param-

    {Object} [guard] Enables use as an iteratee for functions like _.reduce.

    example

    var users = [ { 'user': 'fred', 'age': 48 }, { 'user': 'barney', 'age': 34 }, { 'user': 'fred', 'age': 42 }, { 'user': 'barney', 'age': 36 } ];

    // sort by user in ascending order and by age in descending order _.orderBy(users, ['user', 'age'], ['asc', 'desc']); // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]

    Type parameters

    • T

    Parameters

    • collection: List<T> | null | undefined

      The collection to iterate over.

    • Optional iteratees: Many<ListIterator<T, NotVoid>>
    • Optional orders: Many<boolean | "asc" | "desc">

    Returns T[]

    Returns the new sorted array.

  • see

    _.orderBy

    Type parameters

    • T

    Parameters

    • collection: List<T> | null | undefined
    • Optional iteratees: Many<ListIteratee<T>>
    • Optional orders: Many<boolean | "asc" | "desc">

    Returns T[]

  • see

    _.orderBy

    Type parameters

    • T: object

    Parameters

    Returns Array<T[keyof T]>

  • see

    _.orderBy

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined
    • Optional iteratees: Many<ObjectIteratee<T>>
    • Optional orders: Many<boolean | "asc" | "desc">

    Returns Array<T[keyof T]>

partition

  • partition<T>(collection: List<T> | null | undefined, callback: ValueIteratee<T>): [T[], T[]]
  • partition<T>(collection: T | null | undefined, callback: ValueIteratee<T[keyof T]>): [Array<T[keyof T]>, Array<T[keyof T]>]
  • Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for, while the second of which contains elements predicate returns falsey for. The predicate is invoked with three arguments: (value, index|key, collection).

    Type parameters

    • T

    Parameters

    • collection: List<T> | null | undefined

      The collection to iterate over.

    • callback: ValueIteratee<T>

      The function called per iteration.

    Returns [T[], T[]]

    Returns the array of grouped elements.

  • see

    _.partition

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined
    • callback: ValueIteratee<T[keyof T]>

    Returns [Array<T[keyof T]>, Array<T[keyof T]>]

reduce

  • reduce<T, TResult>(collection: T[] | null | undefined, callback: MemoListIterator<T, TResult, T[]>, accumulator: TResult): TResult
  • reduce<T, TResult>(collection: List<T> | null | undefined, callback: MemoListIterator<T, TResult, List<T>>, accumulator: TResult): TResult
  • reduce<T, TResult>(collection: T | null | undefined, callback: MemoObjectIterator<T[keyof T], TResult, T>, accumulator: TResult): TResult
  • reduce<T>(collection: T[] | null | undefined, callback: MemoListIterator<T, T, T[]>): T | undefined
  • reduce<T>(collection: List<T> | null | undefined, callback: MemoListIterator<T, T, List<T>>): T | undefined
  • reduce<T>(collection: T | null | undefined, callback: MemoObjectIterator<T[keyof T], T[keyof T], T>): T[keyof T] | undefined
  • Reduces a collection to a value which is the accumulated result of running each element in the collection through the callback, where each successive callback execution consumes the return value of the previous execution. If accumulator is not provided the first element of the collection will be used as the initial accumulator value. The callback is invoked with four arguments: (accumulator, value, index|key, collection).

    Type parameters

    • T

    • TResult

    Parameters

    • collection: T[] | null | undefined

      The collection to iterate over.

    • callback: MemoListIterator<T, TResult, T[]>

      The function called per iteration.

    • accumulator: TResult

      Initial value of the accumulator.

    Returns TResult

    Returns the accumulated value.

  • see

    _.reduce

    Type parameters

    • T

    • TResult

    Parameters

    Returns TResult

  • see

    _.reduce

    Type parameters

    • T: object

    • TResult

    Parameters

    • collection: T | null | undefined
    • callback: MemoObjectIterator<T[keyof T], TResult, T>
    • accumulator: TResult

    Returns TResult

  • see

    _.reduce

    Type parameters

    • T

    Parameters

    Returns T | undefined

  • see

    _.reduce

    Type parameters

    • T

    Parameters

    Returns T | undefined

  • see

    _.reduce

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined
    • callback: MemoObjectIterator<T[keyof T], T[keyof T], T>

    Returns T[keyof T] | undefined

reduceRight

  • reduceRight<T, TResult>(collection: T[] | null | undefined, callback: MemoListIterator<T, TResult, T[]>, accumulator: TResult): TResult
  • reduceRight<T, TResult>(collection: List<T> | null | undefined, callback: MemoListIterator<T, TResult, List<T>>, accumulator: TResult): TResult
  • reduceRight<T, TResult>(collection: T | null | undefined, callback: MemoObjectIterator<T[keyof T], TResult, T>, accumulator: TResult): TResult
  • reduceRight<T>(collection: T[] | null | undefined, callback: MemoListIterator<T, T, T[]>): T | undefined
  • reduceRight<T>(collection: List<T> | null | undefined, callback: MemoListIterator<T, T, List<T>>): T | undefined
  • reduceRight<T>(collection: T | null | undefined, callback: MemoObjectIterator<T[keyof T], T[keyof T], T>): T[keyof T] | undefined
  • This method is like _.reduce except that it iterates over elements of a collection from right to left.

    Type parameters

    • T

    • TResult

    Parameters

    • collection: T[] | null | undefined

      The collection to iterate over.

    • callback: MemoListIterator<T, TResult, T[]>

      The function called per iteration.

    • accumulator: TResult

      Initial value of the accumulator.

    Returns TResult

    The accumulated value.

  • see

    _.reduceRight

    Type parameters

    • T

    • TResult

    Parameters

    Returns TResult

  • see

    _.reduceRight

    Type parameters

    • T: object

    • TResult

    Parameters

    • collection: T | null | undefined
    • callback: MemoObjectIterator<T[keyof T], TResult, T>
    • accumulator: TResult

    Returns TResult

  • see

    _.reduceRight

    Type parameters

    • T

    Parameters

    Returns T | undefined

  • see

    _.reduceRight

    Type parameters

    • T

    Parameters

    Returns T | undefined

  • see

    _.reduceRight

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined
    • callback: MemoObjectIterator<T[keyof T], T[keyof T], T>

    Returns T[keyof T] | undefined

reject

  • reject(collection: string | null | undefined, predicate?: StringIterator<boolean>): string[]
  • reject<T>(collection: List<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>): T[]
  • reject<T>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>): Array<T[keyof T]>
  • The opposite of _.filter; this method returns the elements of collection that predicate does not return truthy for.

    Parameters

    • collection: string | null | undefined

      The collection to iterate over.

    • Optional predicate: StringIterator<boolean>

      The function invoked per iteration.

    Returns string[]

    Returns the new filtered array.

  • see

    _.reject

    Type parameters

    • T

    Parameters

    Returns T[]

  • see

    _.reject

    Type parameters

    • T: object

    Parameters

    Returns Array<T[keyof T]>

sample

  • sample<T>(collection: List<T> | Dictionary<T> | NumericDictionary<T> | null | undefined): T | undefined
  • sample<T>(collection: T | null | undefined): T[keyof T] | undefined
  • Gets a random element from collection.

    Type parameters

    • T

    Parameters

    Returns T | undefined

    Returns the random element.

  • see

    _.sample

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined

    Returns T[keyof T] | undefined

sampleSize

  • sampleSize<T>(collection: List<T> | Dictionary<T> | NumericDictionary<T> | null | undefined, n?: undefined | number): T[]
  • sampleSize<T>(collection: T | null | undefined, n?: undefined | number): Array<T[keyof T]>
  • Gets n random elements at unique keys from collection up to the size of collection.

    Type parameters

    • T

    Parameters

    • collection: List<T> | Dictionary<T> | NumericDictionary<T> | null | undefined

      The collection to sample.

    • Optional n: undefined | number

      The number of elements to sample.

    Returns T[]

    Returns the random elements.

  • see

    _.sampleSize

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined
    • Optional n: undefined | number

    Returns Array<T[keyof T]>

shuffle

  • shuffle<T>(collection: List<T> | null | undefined): T[]
  • shuffle<T>(collection: T | null | undefined): Array<T[keyof T]>
  • Creates an array of shuffled values, using a version of the Fisher-Yates shuffle.

    Type parameters

    • T

    Parameters

    • collection: List<T> | null | undefined

      The collection to shuffle.

    Returns T[]

    Returns the new shuffled array.

  • see

    _.shuffle

    Type parameters

    • T: object

    Parameters

    • collection: T | null | undefined

    Returns Array<T[keyof T]>

size

  • size(collection: object | string | null | undefined): number
  • Gets the size of collection by returning its length for array-like values or the number of own enumerable properties for objects.

    Parameters

    • collection: object | string | null | undefined

      The collection to inspect.

    Returns number

    Returns the size of collection.

some

  • Checks if predicate returns truthy for any element of collection. Iteration is stopped once predicate returns truthy. The predicate is invoked with three arguments: (value, index|key, collection).

    Type parameters

    • T

    Parameters

    • collection: List<T> | null | undefined

      The collection to iterate over.

    • Optional predicate: ListIterateeCustom<T, boolean>

      The function invoked per iteration.

    Returns boolean

    Returns true if any element passes the predicate check, else false.

  • see

    _.some

    Type parameters

    • T: object

    Parameters

    Returns boolean

sortBy

  • sortBy<T>(collection: List<T> | null | undefined, ...iteratees: Array<Many<ListIteratee<T>>>): T[]
  • sortBy<T>(collection: T | null | undefined, ...iteratees: Array<Many<ObjectIteratee<T>>>): Array<T[keyof T]>
  • Creates an array of elements, sorted in ascending order by the results of running each element in a collection through each iteratee. This method performs a stable sort, that is, it preserves the original sort order of equal elements. The iteratees are invoked with one argument: (value).

    category

    Collection

    example

    var users = [ { 'user': 'fred', 'age': 48 }, { 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 42 }, { 'user': 'barney', 'age': 34 } ];

    _.sortBy(users, function(o) { return o.user; }); // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]

    _.sortBy(users, ['user', 'age']); // => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]]

    _.sortBy(users, 'user', function(o) { return Math.floor(o.age / 10); }); // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]

    Type parameters

    • T

    Parameters

    • collection: List<T> | null | undefined

      The collection to iterate over.

    • Rest ...iteratees: Array<Many<ListIteratee<T>>>

    Returns T[]

    Returns the new sorted array.

  • see

    _.sortBy

    Type parameters

    • T: object

    Parameters

    Returns Array<T[keyof T]>

Generated using TypeDoc