Options
All
  • Public
  • Public/Protected
  • All
Menu

Module takeWhile

Index

Functions Array

Array Functions

  • default(array: any, predicate: any): any[]
  • 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).

    since

    3.0.0

    example

    const users = [ { 'user': 'barney', 'active': true }, { 'user': 'fred', 'active': true }, { 'user': 'pebbles', 'active': false } ]

    takeWhile(users, ({ active }) => active) // => objects for ['barney', 'fred']

    Parameters

    • array: any

      The array to query.

    • predicate: any

      The function invoked per iteration.

    Returns any[]

    Returns the slice of array.