dropWhile source npm

_.dropWhile(array, [predicate=_.identity])

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).

Arguments

  1. array (Array)

    The array to query.

  2. [predicate=_.identity] (Function|Object|string)

    The function invoked per iteration.

Returns (Array)

Returns the slice of array.

Example

var resolve = _.partial(_.map, _, 'user');

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

resolve( _.dropWhile(users, function(o) { return !o.active; }) );
// => ['pebbles']

// using the `_.matches` callback shorthand
resolve( _.dropWhile(users, { 'user': 'barney', 'active': false }) );
// => ['fred', 'pebbles']

// using the `_.matchesProperty` callback shorthand
resolve( _.dropWhile(users, ['active', false]) );
// => ['pebbles']

// using the `_.property` callback shorthand
resolve( _.dropWhile(users, 'active') );
// => ['barney', 'fred', 'pebbles']