UNPKG

1.91 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Transform, TransformOptions, Readable } from "stream";
3import { CSVParseParam } from "./Parameters";
4import { ParseRuntime } from "./ParseRuntime";
5import CSVError from "./CSVError";
6export declare class Converter extends Transform implements PromiseLike<any[]> {
7 options: TransformOptions;
8 preRawData(onRawData: PreRawDataCallback): Converter;
9 preFileLine(onFileLine: PreFileLineCallback): Converter;
10 subscribe(onNext?: (data: any, lineNumber: number) => void | PromiseLike<void>, onError?: (err: CSVError) => void, onCompleted?: () => void): Converter;
11 fromFile(filePath: string, options?: string | CreateReadStreamOption | undefined): Converter;
12 fromStream(readStream: Readable): Converter;
13 fromString(csvString: string): Converter;
14 then<TResult1 = any[], TResult2 = never>(onfulfilled?: (value: any[]) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>;
15 readonly parseParam: CSVParseParam;
16 readonly parseRuntime: ParseRuntime;
17 private params;
18 private runtime;
19 private processor;
20 private result;
21 constructor(param?: Partial<CSVParseParam>, options?: TransformOptions);
22 _transform(chunk: any, encoding: string, cb: Function): void;
23 _flush(cb: Function): void;
24 private processEnd(cb);
25 readonly parsedLineNumber: number;
26}
27export interface CreateReadStreamOption {
28 flags?: string;
29 encoding?: string;
30 fd?: number;
31 mode?: number;
32 autoClose?: boolean;
33 start?: number;
34 end?: number;
35 highWaterMark?: number;
36}
37export declare type CallBack = (err: Error, data: Array<any>) => void;
38export declare type PreFileLineCallback = (line: string, lineNumber: number) => string | PromiseLike<string>;
39export declare type PreRawDataCallback = (csvString: string) => string | PromiseLike<string>;