Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arr-filter

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arr-filter - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

benchmark/cb.js

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._
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc