Skip to content

Commit

Permalink
Add types for TypeScript support
Browse files Browse the repository at this point in the history
  • Loading branch information
hossam-magdy committed Feb 29, 2020
1 parent c3bef08 commit 9fc76d6
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,93 @@
define module 'csv-string';
declare module "csv-string" {
import { Transform } from "stream";

namespace CsvString {
type rowElement = string | number | boolean;

type row = rowElement[];

type separator = "," | ";" | "|" | "\t";

function parse(input: string, separator?: separator, quote?: string): row;

function stringify(input: row, separator?: string): string;

function detect(input: string): separator;

function createStream(options?: {
separator: separator;
quote: string;
}): Transform;

type forEachCallback = (row: row, index: number) => undefined;

function forEach(
input: string,
separator: string,
quote: string,
callback: forEachCallback
): void;

function forEach(
input: string,
separator: string,
callback: forEachCallback
): void;

function forEach(input: string, callback: forEachCallback): void;

type readCallback = (row: row) => undefined;

function read(
input: string,
separator: string,
quote: string,
callback: readCallback
): number;

function read(
input: string,
separator: string,
callback: readCallback
): number;

function read(input: string, callback: readCallback): number;

type readAllCallback = readCallback;

function readAll(
input: string,
separator: string,
quote: string,
callback: readCallback
): number;

function readAll(
input: string,
separator: string,
callback: readCallback
): number;

function readAll(input: string, callback: readCallback): number;

type readChunkCallback = readCallback;

function readChunk(
input: string,
separator: string,
quote: string,
callback: readCallback
): number;

function readChunk(
input: string,
separator: string,
callback: readCallback
): number;

function readChunk(input: string, callback: readCallback): number;
}

export = CsvString;
}

0 comments on commit 9fc76d6

Please sign in to comment.