Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
foreach
Advanced tools
foreach component + npm package
Weekly downloads
Package description
The 'foreach' npm package provides a utility for iterating over arrays and objects in a concise and consistent manner. It allows developers to execute a function for each element in an array or each property in an object, similar to the native forEach method available on arrays in JavaScript.
Iterating over arrays
This feature allows you to iterate over each item in an array and execute a function that has access to the item value, index, and the original array.
foreach([1, 2, 3], function(value, index, array) {
console.log(value);
});
Iterating over object properties
This feature allows you to iterate over each key-value pair in an object and execute a function that has access to the value, key, and the original object.
foreach({ a: 1, b: 2, c: 3 }, function(value, key, object) {
console.log(key + ': ' + value);
});
Lodash provides a 'foreach' function that offers similar functionality to the 'foreach' npm package. It is part of a larger utility library, which means it comes with additional utility functions that may be beneficial for more complex projects.
The 'array-foreach' package is a minimalistic alternative that focuses solely on array iteration. It is similar to the 'foreach' package but does not include object iteration, making it a lighter choice if only array iteration is needed.
Readme
Iterate over the key value pairs of either an array-like object or a dictionary like object.
var each = require('foreach');
each([1,2,3], function (value, key, array) {
// value === 1, 2, 3
// key === 0, 1, 2
// array === [1, 2, 3]
});
each({0:1,1:2,2:3}, function (value, key, object) {
// value === 1, 2, 3
// key === 0, 1, 2
// object === {0:1,1:2,2:3}
});
FAQs
foreach component + npm package
The npm package foreach receives a total of 1,862,525 weekly downloads. As such, foreach popularity was classified as popular.
We found that foreach demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.