[csv-stringify] Allow .write to write array with optional encoding and callback

This commit is contained in:
Arjen van der Ende
2017-07-11 16:15:23 +02:00
parent 9045ee35eb
commit 646d56fd35
2 changed files with 6 additions and 4 deletions
@@ -25,6 +25,9 @@ stringify([["1", true, new Date()], ["4", false, new Date()]], {
stream = stringify({ delimiter: "," });
stream.write(["1", "2", "3"]);
stream.write(["4", true, new Date()], 'utf8', (err: Error, output: string): void => {
// nothing
});
const transform: NodeJS.ReadWriteStream = stream;
+3 -4
View File
@@ -69,12 +69,11 @@ declare namespace stringify {
}
interface Stringifier extends NodeJS.ReadWriteStream {
// Stringifier stream takes array of strings or Object
write(line: string[] | any): boolean;
// Stringifier stream takes array of strings or Object, and optional encoding and callback
write(line: string[] | any, encoding?: string, cb?: (error: Error | undefined, output: string) => void): boolean;
// repeat declarations from NodeJS.WritableStream to avoid compile error
write(buffer: string | Buffer, cb?: () => void): boolean;
write(str: string, encoding?: string, cb?: () => void): boolean;
write(buffer: string | Buffer, cb?: (error: Error | undefined, output: string) => void): boolean;
}
}