UNPKG

iterparse

Version:
49 lines 1.77 kB
import { ProgressReportOptions, WriteProgressReportOptions } from './helpers'; import { AnyIterable, FileReference, FileWriteMode, IX } from './types'; export interface JSONWriteOptions extends FileReference, FileWriteMode, WriteProgressReportOptions { } export interface JSONReadOptions extends ProgressReportOptions, FileReference { /** * JSON parsing pattern * @example * [{...}, {...}] => * * { a: [{...}, {...}] } => a.* * { a: { b: [{...}, {...}] } } => a.b.* */ pattern: string; } /** * Function will read big JSON files in memory efficient way. * @include ./JSONReadOptions.md * @example * import { jsonRead } from 'iterparse' * jsonRead({ filePath: "path/to/file.json" }) * .map((q)=> console.log(q)) * .count() * @example * import { jsonRead } from 'iterparse' * for await (const item of jsonRead({ filePath: "path/to/file.json" })) { * console.log(item) * } * @category JSON */ export declare function jsonRead<T>(options: JSONReadOptions): IX<T>; /** * Function will write iteratable in memory efficient way. * * @include ./JSONWriteOptions.md * @example * import { AsyncIterable } from 'ix' * import { jsonWrite } from 'iterparse' * AsyncIterable.from([1, 2, 3, 4, 5]) * .pipe(jsonWrite({ filePath: "path/to/file.json" })) * .count() * @example * import { jsonWrite } from 'iterparse' * jsonWrite([{ a: 1, b: 2 }, { a: 1, b: 2 }], { filePath: "/path/to/file" }) * .count() * @category JSON */ export declare function jsonWrite<T>(options: JSONWriteOptions): (data: AsyncIterable<T>) => AsyncIterable<T>; export declare function jsonWrite<T>(data: AnyIterable<T>, options: JSONWriteOptions): IX<T>; //# sourceMappingURL=json.d.ts.map