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

array-filter

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-filter - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

test/this.js

5

index.js

@@ -6,6 +6,7 @@ /**

* @param {Function} fn
* @param {Object=} self
* @return {Array}
*/
module.exports = function (arr, fn) {
module.exports = function (arr, fn, self) {
if (arr.filter) return arr.filter(fn);

@@ -15,3 +16,3 @@ var ret = [];

if (!hasOwn.call(arr, i)) continue;
if (fn(arr[i], i, arr)) ret.push(arr[i]);
if (fn.call(self, arr[i], i, arr)) ret.push(arr[i]);
}

@@ -18,0 +19,0 @@ return ret;

2

package.json
{
"name": "array-filter",
"description": "Array#filter for older browsers.",
"version": "0.0.1",
"version": "0.1.0",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

@@ -22,2 +22,14 @@

## API
### filter(arr, fn[, self])
Return an array with elements of `arr` for which `fn` returns a truthy value. `fn` is called with
* `el`: The current element
* `i`: The element's index
* `arr`: The whole array
Optionally pass in `self` as the `this` value for `fn`.
## Installation

@@ -24,0 +36,0 @@

@@ -6,3 +6,3 @@ var filter = require('..');

var arr = [1, 2, 3, 4, 5];
delete arr.filter;
arr.filter = undefined;
var even = filter(arr, function(el) {

@@ -9,0 +9,0 @@ return el % 2 == 0;

@@ -6,3 +6,3 @@ var filter = require('..');

var arr = new Array(5);
delete arr.filter;
arr.filter = undefined;
var res = filter(arr, function(el) {

@@ -9,0 +9,0 @@ return false;

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