]> git.r.bdr.sh - rbdr/dotfiles/blob
b0116defce5021a6a45612682d262b86a5eb64e4
[rbdr/dotfiles] /
1 'use strict';
2
3 var isPlainArray = require('../../is-plain-array')
4 , callable = require('../../../object/valid-callable')
5
6 , isArray = Array.isArray, filter = Array.prototype.filter
7 , forEach = Array.prototype.forEach, call = Function.prototype.call;
8
9 module.exports = function (callbackFn/*, thisArg*/) {
10 var result, thisArg, i;
11 if (!this || !isArray(this) || isPlainArray(this)) {
12 return filter.apply(this, arguments);
13 }
14 callable(callbackFn);
15 thisArg = arguments[1];
16 result = new this.constructor();
17 i = 0;
18 forEach.call(this, function (val, j, self) {
19 if (call.call(callbackFn, thisArg, val, j, self)) result[i++] = val;
20 });
21 return result;
22 };