sflow
Version:
sflow is a powerful and highly-extensible library designed for processing and manipulating streams of data effortlessly. Inspired by the functional programming paradigm, it provides a rich set of utilities for transforming streams, including chunking, fil
38 lines (36 loc) • 1.66 kB
JavaScript
import { t as __exportAll } from "../../chunk-BYypO7fO.js";
import { a as maps, n as lines, r as throughs, t as skips } from "../../skips-o3ebh_7B.js";
import { csvFormatBody, csvParse, tsvFormatBody, tsvParse } from "d3-dsv";
//#region src/lib/d3/xsvStreams.ts
var xsvStreams_exports = /* @__PURE__ */ __exportAll({
csvFormats: () => csvFormats,
csvParses: () => csvParses,
tsvFormats: () => tsvFormats,
tsvParses: () => tsvParses
});
function csvFormats(header) {
const _header = typeof header === "string" ? header.split(",") : header;
return new TransformStream({
start: (ctrl) => ctrl.enqueue(`${_header.join(",")}\n`),
transform: (chunk, ctrl) => ctrl.enqueue(`${csvFormatBody([chunk], _header)}\n`)
});
}
function csvParses(header) {
const _header = typeof header === "string" ? header.split(",") : header;
return throughs((r) => r.pipeThrough(lines({ EOL: "LF" })).pipeThrough(skips(1)).pipeThrough(maps((line) => csvParse(`${_header}\n${line}`)[0])));
}
function tsvFormats(header) {
const sep = " ";
const _header = typeof header === "string" ? header.split(sep) : header;
return new TransformStream({
start: (ctrl) => ctrl.enqueue(`${_header.join(sep)}\n`),
transform: (chunk, ctrl) => ctrl.enqueue(`${tsvFormatBody([chunk], _header)}\n`)
});
}
function tsvParses(header) {
const _header = typeof header === "string" ? header.split(" ") : header;
return throughs((r) => r.pipeThrough(lines({ EOL: "LF" })).pipeThrough(skips(1)).pipeThrough(maps((line) => tsvParse(`${_header}\n${line}`)[0])));
}
//#endregion
export { csvFormats, csvParses, xsvStreams_exports as sfd3, tsvFormats, tsvParses };
//# sourceMappingURL=index.js.map