New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

array-filter-inplace

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-filter-inplace

Remove non-matching elements from a dense array.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

array-filter-inplace

Remove non-matching elements from a dense array.

API

This module exports one function:

filter(array, test[, offset])

Test array's items, starting at offset (default = 0) by calling the test function with arguments (value, index, array). If the test result isn't truthy, the item is removed¹ from the array.

Returns array.

¹ "Remove" means it's either replaced with the next value that passes the test, or cut off by setting array.length.

Usage

from test.usage.js:

var filter = require('array-filter-inplace'), a, b, offset,
  files = [ '.', '..', '.git', 'bin', 'README.md', 'package.json' ];

function notDotFile(s) { return (s.slice(0, 1) !== '.'); }
a = files.slice();
b = filter(a, notDotFile);
equal(a, [ 'bin', 'README.md', 'package.json' ]);
equal(a, b);

a = files.slice();
offset = 2;   // skip the first two items
b = filter(a, notDotFile, offset);
equal(a, [ '.', '..', 'bin', 'README.md', 'package.json' ]);
equal(a, b);

function isLower(s) { return (/[a-z]/.test(s) && (!/[A-Z]/.test(s))); }
a = files.slice();
b = filter(a, isLower);
equal(a, [ '.git', 'bin', 'package.json' ]);
equal(a, b);

 

License

ISC

Keywords

FAQs

Package last updated on 10 Oct 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc