Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
forEachAsync
Advanced tools
A node- and browser-ready async counterpart of Array.prototype.forEach
As I do every few years, I decided to rewrite FuturesJS. This year's remake is extremely lightweight.
v3.x - Diet Cola Edition (published on npm as beta, so you must use the @3.x - and don't worry, v2.x is still supported)
Analogous to [].forEach
, but handles items asynchronously with a final callback passed to then
.
This is the most essential piece of the ArrayAsync
package.
It's as simple as you could guess:
// waits for one request to finish before beginning the next
forEachAsync(['dogs', 'cats', 'octocats'], function (next, element, index, array) {
getPics(element, next);
// then after all of the elements have been handled
// the final callback fires to let you know it's all done
}).then(function () {
console.log('All requests have finished');
});
// where `getPics` might be an asynchronous web request such as this
function getPics(animal, cb) {
var flickerAPI = "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
$.getJSON(
flickerAPI
, { tags: thing
, tagmode: "any"
, format: "json"
, success: function (data) {
console.log('teh animals:', data);
}
, complete: cb
}
);
}
You can install from bower:
bower install forEachAsync
Or download the raw file from https://raw.github.com/FuturesJS/forEachAsync/master/forEachAsync.js:
wget https://raw.github.com/FuturesJS/forEachAsync/master/forEachAsync.js
(function () {
'use strict';
var forEachAsync = window.forEachAsync
;
// do stuff ...
}());
Or you can build it alongside other libraries:
npm install -g pakmanager
npm install forEachAsync --save
pakmanager -e browser build
<script src="pakmanaged.js"></script>
(function () {
'use strict';
var forEachAsync = require('forEachAsync').forEachAsync
;
// do stuff ...
}());
npm install --save forEachAsync@3.x
forEachAsync(array, callback[, thisArg])
Parameters
array
Array of elements to iterate overcallback
Function to execute for each element, takes 4 arguments
next
the function to call when the current element has been dealt withelement
a single element of the aforementioned arrayindex
the index of the current elementarray
the same array mentioned abovethisArg
Object to use as this
when executing callback
forEachAsync#then(done)
Parameters
then
is in the return value of forEachAsync
and accepts a final done
callback.
done
called after forEachAsync
is complete, takes no argumentsforEachAsync.__BREAK
This is used internally for the purposes of the ArrayAsync
library.
Please don't break
stuff; use someAsync
or everyAsync
instead.
FAQs
A node- and browser-ready async counterpart of Array.prototype.forEach
The npm package forEachAsync receives a total of 946 weekly downloads. As such, forEachAsync popularity was classified as not popular.
We found that forEachAsync 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.