@js-data-tools/js-helpers
Version:
A set of JavaScript / TypeScript helper functions for parsing, converting, transforming and formatting data.
11 lines (10 loc) • 392 B
JavaScript
import { map, mapAsync } from "../iterable";
export function parseJsonLines(textLines, reviver) {
return map(textLines, (line) => JSON.parse(line, reviver));
}
export function parseJsonLinesAsync(textLines, reviver) {
return mapAsync(textLines, (line) => JSON.parse(line, reviver));
}
export function toJsonLine(value, replacer) {
return JSON.stringify(value, replacer) + "\n";
}