You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
429 B
18 lines
429 B
var safeCb = require('./safeCb'); |
|
exports = function(arr, iterator, ctx) { |
|
var ret = []; |
|
iterator = safeCb(iterator, ctx); |
|
var i = -1; |
|
var len = arr.length; |
|
while (++i < len) { |
|
var realIdx = i - ret.length; |
|
var val = arr[realIdx]; |
|
if (iterator(val, i, arr)) { |
|
ret.push(val); |
|
arr.splice(realIdx, 1); |
|
} |
|
} |
|
return ret; |
|
}; |
|
|
|
module.exports = exports;
|
|
|