mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
Fix csv-stringify types (#13252)
This commit is contained in:
committed by
Masahiro Wakame
parent
2157d75e67
commit
a9156baa37
@@ -1,6 +1,8 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import stringify = require("csv-stringify");
|
||||
|
||||
let stream: stringify.Stringifier;
|
||||
|
||||
stringify([["1", "2", "3"], ["4", "5", "6"]], (error: Error, output: string): void => {
|
||||
// nothing
|
||||
@@ -13,9 +15,10 @@ stringify([["1", "2", "3"], ["4", "5", "6"]], {
|
||||
});
|
||||
|
||||
|
||||
var s = stringify({ delimiter: "," });
|
||||
s.write(["1", "2", "3"]);
|
||||
|
||||
stream = stringify({ delimiter: "," });
|
||||
|
||||
stream.write(["1", "2", "3"]);
|
||||
|
||||
let transform: NodeJS.ReadWriteStream = stream;
|
||||
|
||||
stream = stringify();
|
||||
|
||||
28
csv-stringify/index.d.ts
vendored
28
csv-stringify/index.d.ts
vendored
@@ -1,12 +1,10 @@
|
||||
// Type definitions for csv-stringify 0.0.6
|
||||
// Type definitions for csv-stringify 1.0
|
||||
// Project: https://github.com/wdavidw/node-csv-stringify
|
||||
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
|
||||
declare namespace stringify {
|
||||
interface StringifyOpts {
|
||||
/**
|
||||
@@ -57,26 +55,24 @@ declare namespace stringify {
|
||||
}
|
||||
|
||||
interface Stringifier extends NodeJS.ReadWriteStream {
|
||||
|
||||
// Stringifier stream takes array of strings or Object
|
||||
write(line: string[] | Object): boolean;
|
||||
// Stringifier stream takes array of strings or Object
|
||||
write(line: string[] | any): boolean;
|
||||
|
||||
// repeat declarations from NodeJS.WritableStream to avoid compile error
|
||||
write(buffer: Buffer, cb?: Function): boolean;
|
||||
write(str: string, cb?: Function): boolean;
|
||||
write(str: string, encoding?: string, cb?: Function): boolean;
|
||||
write(buffer: string | Buffer, cb?: () => void): boolean;
|
||||
write(str: string, encoding?: string, cb?: () => void): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback version: string in --> callback with string out
|
||||
*/
|
||||
declare function stringify(input: any[][], opts: stringify.StringifyOpts, callback: (error: Error, output: string) => void): void;
|
||||
declare function stringify(input: any[][], callback: (error: Error, output: string) => void): void;
|
||||
|
||||
/**
|
||||
* Streaming stringifier
|
||||
*/
|
||||
declare function stringify(opts: stringify.StringifyOpts): stringify.Stringifier;
|
||||
declare function stringify(opts?: stringify.StringifyOpts): stringify.Stringifier;
|
||||
|
||||
/**
|
||||
* Callback version: string in --> callback with string out
|
||||
*/
|
||||
declare function stringify(input: any[][], opts: stringify.StringifyOpts, callback: (error: Error | undefined, output: string) => void): void;
|
||||
declare function stringify(input: any[][], callback: (error: Error | undefined, output: string) => void): void;
|
||||
|
||||
export = stringify;
|
||||
|
||||
1
csv-stringify/tslint.json
Normal file
1
csv-stringify/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user