Comparing version 0.1.0 to 1.0.0
25
index.js
/*! | ||
* arr-filter <https://github.com/jonschlinkert/arr-filter> | ||
* | ||
* Copyright (c) 2014 Jon Schlinkert, contributors. | ||
* Copyright (c) 2014-2015, Jon Schlinkert. | ||
* Licensed under the MIT License | ||
*/ | ||
var makeIterator = require('make-iterator'); | ||
'use strict'; | ||
module.exports = function filter(arr, cb, thisArg) { | ||
cb = makeIterator(cb, thisArg); | ||
var iterator = require('make-iterator'); | ||
var filter = module.exports = function filter(arr, cb, thisArg) { | ||
if (arr == null) { | ||
@@ -18,17 +17,17 @@ return []; | ||
if (typeof cb != 'function') { | ||
return new TypeError(); | ||
if (typeof cb !== 'function') { | ||
throw new TypeError('arr-filter expects a callback function.'); | ||
} | ||
var len = arr.length; | ||
var res = []; | ||
var res = arr.slice(); | ||
for (var i = 0; i < len; i++) { | ||
var ele = arr[i]; | ||
if (cb(ele, i, arr)) { | ||
res.push(ele); | ||
while (len--) { | ||
if (!cb(arr[len])) { | ||
res.splice(len, 1); | ||
} | ||
} | ||
return res; | ||
}; | ||
{ | ||
"name": "arr-filter", | ||
"description": "Faster alternative to javascript's native filter method and [array-filter](https://github.com/juliangruber/array-filter).", | ||
"version": "0.1.0", | ||
"description": "Faster alternative to javascript's native filter method.", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/jonschlinkert/arr-filter", | ||
@@ -17,8 +17,6 @@ "author": { | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/jonschlinkert/arr-filter/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"license": { | ||
"type": "MIT", | ||
"url": "https://github.com/jonschlinkert/arr-filter/blob/master/LICENSE-MIT" | ||
}, | ||
"main": "index.js", | ||
@@ -29,23 +27,23 @@ "engines": { | ||
"scripts": { | ||
"test": "mocha -R spec" | ||
"docs": "update && license && npmignore && deps && verb", | ||
"all": "npm run docs" | ||
}, | ||
"dependencies": { | ||
"make-iterator": "^0.1.0" | ||
}, | ||
"devDependencies": { | ||
"array-filter": "^0.2.0", | ||
"benchmarked": "^0.1.3", | ||
"chalk": "^0.5.1", | ||
"micromatch": "^1.0.1", | ||
"minimist": "^1.1.0", | ||
"mocha": "*", | ||
"should": "^4.0.4", | ||
"verb": ">= 0.2.6", | ||
"verb-tag-jscomments": ">= 0.2.0" | ||
"should": "*" | ||
}, | ||
"keywords": [ | ||
"arr", | ||
"array", | ||
"filter", | ||
"javascript", | ||
"method", | ||
"util", | ||
"utility", | ||
"utils" | ||
], | ||
"dependencies": { | ||
"make-iterator": "^0.1.0" | ||
} | ||
"collection", | ||
"util" | ||
] | ||
} |
# arr-filter [![NPM version](https://badge.fury.io/js/arr-filter.svg)](http://badge.fury.io/js/arr-filter) | ||
> Faster alternative to javascript's native filter method. | ||
> Faster alternative to javascript's native filter method and [array-filter](https://github.com/juliangruber/array-filter). | ||
[array-filter](https://github.com/juliangruber/array-filter) is pretty popular, but it's tuned to be used in older browsers and it falls back on native `.filter()` when available, which is much slower. See [jsperf results](http://jsperf.com/array-filter-while-vs-for/2). The functions used in the benchmarks are the top performers, reduced down from 10 or 11 additional functions. | ||
## Install | ||
#### Install with [npm](npmjs.org) | ||
## Install with [npm](npmjs.org) | ||
@@ -13,3 +11,3 @@ ```bash | ||
``` | ||
#### Install with [bower](https://github.com/bower/bower) | ||
### Install with [bower](https://github.com/bower/bower) | ||
@@ -75,3 +73,3 @@ ```bash | ||
## License | ||
Copyright (c) 2014 Jon Schlinkert, contributors. | ||
Copyright (c) 2015 Jon Schlinkert | ||
Released under the MIT license | ||
@@ -81,2 +79,2 @@ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 01, 2014._ | ||
_This file was generated by [verb](https://github.com/assemble/verb) on January 04, 2015._ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
591674
31
10997
0
7
77
3
1