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.
blinq
Advanced tools
Readme
With the advent of javascript iterators and generators, its possible to pipe sequences through a bunch of transformations without materializing collections (arrays) for the intermediate steps. This library attempts to recreate the dotnet linq-to-objects api to provide a number of standard operations on iterable sequences.
The following operations are available, and the user can optionally supply their own EqualityComparer
(implementing equals
and getHashCode
) when using the set-based operations.
aggregate, all, any, append, average, concat, count, defaultIfEmpty, distinctBy, distinct, elementAt, except, firstOrDefault, first, flatten, forEach, fullOuterGroupJoin, fullOuterJoin, groupAdjacent, groupBy, groupJoin, intersect, isSubsetOf, isSupersetOf, join, lastOrDefault, last, leftOuterJoin, maxBy, max, minBy, min, orderBy / orderByDescending / thenBy / thenByDescending, preprend, reverse, selectMany, select, sequenceEqual, singleOrDefault, single, skip, skipWhile, sum, take, takeWhile, toArray, toLookup, toMap, toSet, union, where, zipAll, zip
NPM package can be downloaded here.
Generated documentation can be found at https://biggyspender.github.io/blinq/
Import blinq ES6 style:
import {
blinq,
range,
empty,
fromGenerator,
fromSingleValue,
repeatGenerate,
repeat,
EqualityComparer,
hashString
} from "blinq";
or nodejs style:
const {
blinq,
range,
empty,
fromGenerator,
fromSingleValue,
repeatGenerate,
repeat,
EqualityComparer,
hashString
} = require("blinq")
Now, just wrap your iterable with a call to blinq(myIterable)
, and start transforming your data:
const someNumbers = [1, 2, 3, 4];
const squares = blinq(someNumbers).select(n => n * n);
for(let v of squares){
console.log(v);
}
...or if you'd like an array of your results, you can materialize a blinq query with the .toArray()
method:
const someNumbers = range(1, 4);
const squaresBelowTen = someNumbers.select(n => n * n).where(n => n < 10);
const arr = squaresBelowTen.toArray();
console.log(arr);
or even spread your results into an array:
const arr2 = [...squaresBelowTen]
const names = ["zebra", "antelope", "ardvaark", "tortoise", "turtle", "dog", "frog"]
const comparer: EqualityComparer<string> = {
equals: (a, b) => a.toLowerCase() === b.toLowerCase(),
getHashCode: (x) => hashString(x.toLowerCase())
}
const set = blinq(names).toSet(comparer)
expect(set.has("DOg")).toBeTruthy()
Let's make a collection of cars:
const cars = [{
manufacturer:"Ford",
model:"Escort"
},{
manufacturer:"Ford",
model:"Cortina"
},{
manufacturer:"Renault",
model:"Clio"
},{
manufacturer:"Vauxhall",
model:"Corsa"
},{
manufacturer:"Ford",
model:"Fiesta"
},{
manufacturer:"Fiat",
model:"500"
}
];
...and sort them by manufacturer, and then by model:
const orderedCars = blinq(cars).orderBy(c => c.manufacturer).thenBy(c => c.model);
console.log(orderedCars.toArray());
Or we could count the number of cars for each manufacturer:
const carsPerManufacturer = blinq(cars)
.groupBy(c => c.manufacturer)
.select(g => ({
manufacturer:g.key,
count:g.count()
}))
.orderBy(c => c.manufacturer);
for(var c of carsPerManufacturer){
console.log(`${c.manufacturer} : ${c.count}`);
}
The tests for this project are kept up to date and are the best place to look for other examples.
Created using the wonderful https://github.com/alexjoverm/typescript-library-starter.
FAQs
With the advent of javascript iterators and generators, its possible to pipe sequences through a bunch of transformations without materializing collections (arrays) for the intermediate steps. This library attempts to recreate the dotnet linq-to-objects a
The npm package blinq receives a total of 82 weekly downloads. As such, blinq popularity was classified as not popular.
We found that blinq 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.