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

array-each

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-each

Loop over each item in an array and call the given function on every element.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3M
increased by2.74%
Maintainers
1
Weekly downloads
 
Created

What is array-each?

The array-each npm package provides a simple utility for iterating over arrays and executing a function for each element. It is designed to be lightweight and efficient, making it suitable for scenarios where you need to perform operations on each item in an array.

What are array-each's main functionalities?

Basic Iteration

This feature allows you to iterate over each element in an array and execute a callback function. The callback receives the current value, the index, and the original array.

const each = require('array-each');
const array = [1, 2, 3, 4];
each(array, function(value, index, array) {
  console.log('Value:', value, 'Index:', index);
});

Early Exit

This feature allows you to exit the iteration early by returning `false` from the callback function. This can be useful for performance optimization when you find the element you are looking for.

const each = require('array-each');
const array = [1, 2, 3, 4];
each(array, function(value, index, array) {
  if (value === 3) return false; // Exit early
  console.log('Value:', value, 'Index:', index);
});

Other packages similar to array-each

FAQs

Package last updated on 28 Apr 2015

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