Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
csv-async-generator
Advanced tools
A tiny CSV library to serialize and deserialize in a performant way. You can take a look at the kind of memory problems it can solve at [serialize-async-generator.test.ts](src/__tests__/serialize-async-generator.test.ts).
A tiny CSV library to serialize and deserialize in a performant way. You can take a look at the kind of memory problems it can solve at serialize-async-generator.test.ts.
expect(
serialize(
[
{ propA: "A1", propB: "B1" },
{ propA: "A2", propB: "B2" },
],
[
{ header: "A", cell: (item) => item.propA },
{ header: "B", cell: (item) => item.propB },
],
),
).toBe("A;B\r\n" + "A1;B1\r\n" + "A2;B2\r\n");
const getPositiveNumbers = async function* () {
let number = 1;
while (true) {
yield Promise.resolve(number);
number++;
}
};
const limit = async function* <Item>(items: AsyncIterable<Item>, max: number) {
let count = 0;
for await (const item of items) {
if (count >= max) {
return;
}
yield item;
count++;
}
};
const filter = async function* <Item>(
items: AsyncIterable<Item>,
predicate: (item: Item) => any,
) {
for await (const item of items) {
if (predicate(item)) {
yield item;
}
}
};
const map = async function* <Input, Output>(
items: AsyncIterable<Input>,
mapper: (item: Input) => Output,
) {
for await (const item of items) {
yield mapper(item);
}
};
const getFirstFiveEvenPositiveNumbersAsItems = () =>
map(
limit(
filter(getPositiveNumbers(), (it) => it % 2),
5,
),
(it) => ({ value: String(it) }),
);
const lines: Array<string> = [];
for await (const line of serializeAsyncGenerator(
getFirstFiveEvenPositiveNumbersAsItems(),
[{ header: "Value", cell: (item) => item.value }],
)) {
lines.push(line);
}
expect(lines).toStrictEqual([
"Value\r\n",
"1\r\n",
"3\r\n",
"5\r\n",
"7\r\n",
"9\r\n",
]);
FAQs
A tiny CSV library to serialize and deserialize in a performant way. You can take a look at the kind of memory problems it can solve at [serialize-async-generator.test.ts](src/__tests__/serialize-async-generator.test.ts).
The npm package csv-async-generator receives a total of 1 weekly downloads. As such, csv-async-generator popularity was classified as not popular.
We found that csv-async-generator 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.