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.
web-csv-toolbox
Advanced tools
Changelog
Readme
string
s, ReadableStream
s, or Response
objects.,
and "
respectively.This package can then be installed using a package manager.
# Install with npm
$ npm install web-csv-toolbox
# Or Yarn
$ yarn add web-csv-toolbox
# Or pnpm
$ pnpm add web-csv-toolbox
<script src="https://unpkg.com/web-csv-toolbox"></script>
<script>
const csv = `name,age
Alice,42
Bob,69`;
(async function () {
for await (const record of CSV.parse(csv)) {
console.log(record);
}
})();
</script>
<script type="module">
import { parse } from 'https://unpkg.com/web-csv-toolbox?module';
const csv = `name,age
Alice,42
Bob,69`;
for await (const record of parse(csv)) {
console.log(record);
}
</script>
You can install and use the package by specifying the following:
import { parse } from "npm:web-csv-toolbox";
import { parse } from 'web-csv-toolbox';
const csv = `name,age
Alice,42
Bob,69`;
for await (const record of parse(csv)) {
console.log(record);
}
// Prints:
// { name: 'Alice', age: '42' }
// { name: 'Bob', age: '69' }
ReadableStream
simport { parse } from 'web-csv-toolbox';
const csv = `name,age
Alice,42
Bob,69`;
const stream = new ReadableStream({
start(controller) {
controller.enqueue(csv);
controller.close();
},
});
for await (const record of parse(stream)) {
console.log(record);
}
// Prints:
// { name: 'Alice', age: '42' }
// { name: 'Bob', age: '69' }
Response
objectsimport { parse } from 'web-csv-toolbox';
const response = await fetch('https://example.com/data.csv');
for await (const record of parse(response)) {
console.log(record);
}
// Prints:
// { name: 'Alice', age: '42' }
// { name: 'Bob', age: '69' }
import { parse } from 'web-csv-toolbox';
const csv = `name\tage
Alice\t42
Bob\t69`;
for await (const record of parse(csv, { delimiter: '\t' })) {
console.log(record);
}
// Prints:
// { name: 'Alice', age: '42' }
// { name: 'Bob', age: '69' }
import { parse } from 'web-csv-toolbox';
const csv = `Alice,42
Bob,69`;
for await (const record of parse(csv, { headers: ['name', 'age'] })) {
console.log(record);
}
// Prints:
// { name: 'Alice', age: '42' }
// { name: 'Bob', age: '69' }
Versions | Status |
---|---|
20.x | β |
18.x | β |
OS | Chrome | FireFox | Default |
---|---|---|---|
Windows | β | β | β (Edge) |
macos | β | β | β¬ (Safari *) |
Linux | β | β | - |
* To Be Tested: I couldn't launch Safari in headless mode on GitHub Actions, so I couldn't verify it, but it probably works.
These APIs are designed for Simplicity and Ease of Use, providing an intuitive and straightforward experience for users.
function parse(input[, options]): AsyncIterableIterator<CSVRecord>
: π
function parse.toArray(input[, options]): Promise<CSVRecord[]>
: π
The input
paramater can be a string
, a ReadableStream
of string
s or Uint8Arrays,
or a Uint8Array object,
or a ArrayBuffer object,
or a Response object.
These APIs are optimized for Enhanced Performance and Control, catering to users who need more detailed and fine-tuned functionality.
function parseString(string[, options])
: π
function parseBinary(buffer[, options])
: π
function parseResponse(response[, options])
: π
Response
objects.function parseStream(stream[, options])
: π
function parseStringStream(stream[, options])
: π
function parseUint8ArrayStream(stream[, options])
: π
These APIs are built for Advanced Customization and Pipeline Design, ideal for developers looking for in-depth control and flexibility.
class LexerTransformer
: π
class RecordAssemblerTransformer
: π
These APIs are experimental and may change in the future.
You can use WebAssembly to parse CSV data for high performance.
"
. (Double quotation mark)
import { loadWASM, parseStringWASM } from "web-csv-toolbox";
// load WebAssembly module
await loadWASM();
const csv = "a,b,c\n1,2,3";
// parse CSV string
const result = parseStringToArraySyncWASM(csv);
console.log(result);
// Prints:
// [{ a: "1", b: "2", c: "3" }]
function loadWASM(): Promise<void>
: π
function parseStringToArraySyncWASM(string[, options]): CSVRecord[]
: π
Option | Description | Default | Notes |
---|---|---|---|
delimiter | Character to separate fields | , | |
quotation | Character used for quoting fields | " | |
headers | Custom headers for the parsed records | First row | If not provided, the first row is used as headers |
Option | Description | Default | Notes |
---|---|---|---|
charset | Character encoding for binary CSV inputs | utf-8 | See Encoding API Compatibility for the encoding formats that can be specified. |
decompression | Decompression algorithm for compressed CSV inputs | See DecompressionStream Compatibility. | |
ignoreBOM | Whether to ignore Byte Order Mark (BOM) | false | See TextDecoderOptions.ignoreBOM for more information about the BOM. |
fatal | Throw an error on invalid characters | false | See TextDecoderOptions.fatal for more information. |
The easiest way to contribute is to use the library and star repository.
Feel free to ask questions on GitHub Discussions.
Please register at GitHub Issues.
Please support kamiazya.
Even just a dollar is enough motivation to develop π
This software is released under the MIT License, see LICENSE.
FAQs
A CSV Toolbox utilizing Web Standard APIs.
The npm package web-csv-toolbox receives a total of 197 weekly downloads. As such, web-csv-toolbox popularity was classified as not popular.
We found that web-csv-toolbox demonstrated a healthy version release cadence and project activity because the last version was released less than 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.