Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
asynchronous query language, for the usual functional list processing functions: map, select, reduce, but async-friendly
What is zo?
Zo is a asynchronous query language providing the usual functional programming list operators like map
, select
and reduce
, but all in an async-friendly style, so they're ready to use while performing async IO operations in node.js.
npm install zo
var zo = require('zo').zo;
zo([1, 2, 3])
.map(function (item, mapTo) {
mapTo(item + 1);
})
.results(function (mappedItems) {
console.log(mappedItems);
});
Produces: [ 2, 3, 4 ]
zo([1, 2, 3])
.select(function (item, selectIf) {
selectIf(item > 1);
})
.results(function (selectedItems) {
console.log(selectedItems);
});
Produces: [ 2, 3 ]
zo([1, 2, 3])
.reduce(0, function (sum, item, reduceInto) {
reduceInto(sum + item);
})
.results(function (sum) {
console.log(sum);
});
Produces: 6
See also reduceRight
, which is a synonym for foldr
zo([1, 2, 3])
.each(function (item, done) {
console.log('item: ' + item);
done();
})
.results(function (items) {
console.log('count: ' + items.length);
});
Produces:
item: 1
item: 2
item: 3
count: 3
But the whole point is when you mix it with async IO:
var fs = require('fs');
var zo = require('zo').zo;
fs.readdir('.', function (err, filesAndDirectories) {
zo(filesAndDirectories)
.map(function (file, mapTo) {
fs.stat(file, function (err, stat) {
mapTo({file: file, stat: stat});
});
})
.select(function (fileAndStat, selectIf) {
selectIf(fileAndStat.stat.isFile() && !/^\./.test(fileAndStat.file));
})
.map(function (fileAndStat, mapTo) {
mapTo(fileAndStat.file + ': ' + fileAndStat.stat.size + ' bytes');
})
.each(function (fileWithSize, done) {
console.log(fileWithSize);
done();
})
.results(function (files) {
console.log();
console.log(files.length + ' files');
});
});
FAQs
asynchronous query language, for the usual functional list processing functions: map, select, reduce, but async-friendly
We found that zo 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.