Socket
Socket
Sign inDemoInstall

array.prototype.filter

Package Overview
Dependencies
66
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    array.prototype.filter

An ES5 spec-compliant `Array.prototype.filter` shim/polyfill/replacement that works as far down as ES3.


Version published
Weekly downloads
3.3M
decreased by-4.46%
Maintainers
2
Install size
3.61 MB
Created
Weekly downloads
 

Changelog

Source

v1.0.4 - 2024-03-18

Commits

  • [Deps] update call-bind, define-properties, es-abstract 817a2ab
  • [actions] remove redundant finisher 50ec4d9
  • [Refactor] use es-object-atoms where possible f3e8ef6
  • [Dev Deps] update aud, npmignore, tape 02c6ae2

Readme

Source

array.prototype.filter Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES5 spec-compliant Array.prototype.filter shim/polyfill/replacement that works as far down as ES3.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.

Because Array.prototype.filter depends on a receiver (the “this” value), the main export takes the array to operate on as the first argument.

Example

var filter = require('array.prototype.filter');
var assert = require('assert');

assert.deepEqual(filter([1, 2, 3], function (x) { return x >= 2; }), [2, 3]);
assert.deepEqual(filter([1, 2, 3], function (x) { return x <= 2; }), [1, 2]);
var filter = require('array.prototype.filter');
var assert = require('assert');
/* when Array#filter is not present */
delete Array.prototype.filter;
var shimmedFilter = filter.shim();
assert.equal(shimmedFilter, filter.getPolyfill());
var arr = [1, 2, 3];
var isOdd = function (x) { return x % 2 !== 0; };
assert.deepEqual(arr.filter(isOdd), filter(arr, isOdd));
var filter = require('array.prototype.filter');
var assert = require('assert');
/* when Array#filter is present */
var shimmedFilter = filter.shim();
assert.equal(shimmedFilter, Array.prototype.filter);
assert.deepEqual(arr.filter(isOdd), filter(arr, isOdd));

Tests

Simply clone the repo, npm install, and run npm test

Keywords

FAQs

Last updated on 19 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc