Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
async-linq
Advanced tools
Readme
Asynchronous LINQ library for JavaScript, small, zero-dependency and strengthened by unit tests
We keep async-linq
on par with .NET version with minimal adjustments to fit JavaScript language. And referenced from Microsoft 101 LINQ Samples page.
Clauses implemented: aggregate
, all
, any
, average
, concat
, count
, distinct
, elementAt
, equalAll
, except
, first
, firstOrDefault
, groupBy
, groupJoin
, intersect
, join
, last
, lastOrDefault
, max
, min
, ofType
, orderBy
, orderByDescending
, range
, repeat
, reverse
, select
, selectMany
, skip
, skipWhile
, sum
, take
, takeWhile
, thenBy
, thenByDescending
, toArray
, toDictionary
, union
, where
, and zip
.
async-linq
We love async, functional programming, and mixing between array + map. We want to bring LINQ to JavaScript without losing all beautiful aspects of JavaScript:
If you are building new clauses, you only need to implement async version. All async clauses will be automatically converted to sync version. Additionally, you can implement sync version for better performance too 2. Both array and map are first-class citizen 3. Maintain code clarity by chaining clauses 4. Every clause is backed by unit tests, with over 500 unit tests passing 5. Small in size, 6 KB after gzip 6. JSHint-friendly
There are some key differences between common practices of C# and JavaScript.
linq([0, 1, 2]).first(function (v) { return v % 2; })
will return the index to the first odd number, i.e. 1
, missing values will be returned as undefined
This is to bring clauses on map to be on-par with array. because linq({ abc: 123, def: 456, xyz: 789 }).first(...).run()
should returns the name of the map, instead of value
2. Predicate signature is usually function (value, indexOrName, callback)
(callback is only required for async)
3. Comparison signature is usually function (value1, indexOrName1, value2, indexOrName2, callback)
4. Selector signature is usually function (value, indexOrName, callback)
5. Callback signature is usually callback(err, result)
6. this
keyword will always reference to the array/map or intermediates
7. run()
is required to execute the query
To list files and their file sizes
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);
});
Clauses chaining
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();
Will return [100, 300, 500, 700, 900]
Please file bugs to issues. To include your bug as regression test, you are recommended to provide a minimal failing test case.
FAQs
Asynchronous LINQ library for JavaScript
The npm package async-linq receives a total of 5 weekly downloads. As such, async-linq popularity was classified as not popular.
We found that async-linq 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.