You can use async-linq
which support both sync and async LINQ operations in JavaScript and feature on-par with C# version. You can get it by npm install async-linq
.
Sync operation
linq([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])
.where(function (v) { return v % 2 === 1; })
.select(function (v) { return v * 100; })
.run();
Async operation
linq(['abc.txt', 'def.txt', 'xyz.txt'])
.async
.select(function (filename, index, callback) {
fs.stat(filename, function (err, stat) {
callback(err, err ? null : {
filename: filename,
size: stat.size
});
});
})
.run(function (err, result) {
console.log(result);
});