How to use the dropWhile function from lodash

Find comprehensive JavaScript lodash.dropWhile code examples handpicked from public code repositorys.

92
93
94
95
96
97
98
99
100
101
module.exports.divide              = _.divide;
module.exports.done                = _.done;
module.exports.drop                = _.drop;
module.exports.dropRight           = _.dropRight;
module.exports.dropRightWhile      = _.dropRightWhile;
module.exports.dropWhile           = _.dropWhile;
module.exports.each                = _.each;
module.exports.eachRight           = _.eachRight;
module.exports.endsWith            = _.endsWith;
module.exports.enforce             = _.enforce;
fork icon19
star icon122
watch icon0

+ 92 other calls in file

4440
4441
4442
4443
4444
4445
4446
4447
4448
4449

// Returns an array with two internal arrays built from
// taking an original array and spliting it at the index
// where a given function goes falsey.
splitWith: function(array, pred) {
  return [_.takeWhile(array, pred), _.dropWhile(array, pred)];
},

// Takes an array and partitions it as the given predicate changes
// truth sense.
fork icon3
star icon2
watch icon1

+ 58 other calls in file

27
28
29
30
31
32
33
34
35
36
37
38
39
console.log(dropRight); // => [1, 2]


const dropRightWhile = _.dropRightWhile([1, 2, 3, 4], n => n > 2);
console.log(dropRightWhile); // => [1, 2]


const dropWhile = _.dropWhile([1, 2, 3, 4], n => n < 3);
console.log(dropWhile); // => [3, 4]


const fill = _.fill([1, 2, 3], 'a');
console.log(fill); // => ['a', 'a', 'a']
fork icon0
star icon4
watch icon0

+ 15 other calls in file

107
108
109
110
111
112
113
114
115
116
117
118
119


// console.log(_.dropRightWhile(users,'active'));
// => objects for ['barney', 'fred', 'pebbles']




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

fork icon0
star icon0
watch icon1

+ 5 other calls in file

93
94
95
96
97
98
99
100
101
102
console.log(_.drop([1, 2, 3, 4, 5]));
console.log(_.drop([1, 2, 3, 4, 5], 2));
console.log(_.dropRight([1, 2, 3, 4, 5], 2));
console.log(_.dropRight([1, 2, 3, 4, 5], 2));
console.log(
  _.dropWhile(users, function (user) {
    return user.active !== true;
  })
);
console.log(
fork icon0
star icon0
watch icon0

+ 5 other calls in file

113
114
115
116
117
118
119
120
121
122
//dropWhile2---> [ { user: 'fred', active: false },
//  { user: 'pabbles', active: true } ]
let dropWhile3 = _.dropWhile(users2, ['active', false]);
console.log('dropWhile3--->', dropWhile3);
//dropWhile3---> [ { user: 'pabbles', active: true } ]
let dropWhile4 = _.dropWhile(users2, 'active');
console.log('dropWhile4--->', dropWhile4);
//dropWhile4---> [ { user: 'barney', active: false },
//   { user: 'fred', active: false },
//   { user: 'pabbles', active: true } ]
fork icon0
star icon0
watch icon0

+ 2 other calls in file

Other functions in lodash

Sorted by popularity

function icon

lodash.get is the most popular function in lodash (7670 examples)