mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
[JSONStream] add stringify(false) overload
Package docs allow `false` as a parameter to `stringify`, in addition to `stringify(open, sep, close)`. This is useful for dumping a stream of objects separated by newlines, rather than creating a JSON array of the objects. from https://www.npmjs.com/package/JSONStream > If you call JSONStream.stringify(false) the elements will only be > seperated by a newline.
This commit is contained in:
Vendored
+18
@@ -14,7 +14,25 @@ export interface Options {
|
||||
export declare function parse(pattern: any): NodeJS.ReadWriteStream;
|
||||
export declare function parse(patterns: any[]): NodeJS.ReadWriteStream;
|
||||
|
||||
|
||||
/**
|
||||
* Create a writable stream.
|
||||
* you may pass in custom open, close, and seperator strings. But, by default,
|
||||
* JSONStream.stringify() will create an array,
|
||||
* (with default options open='[\n', sep='\n,\n', close='\n]\n')
|
||||
*/
|
||||
export declare function stringify(): NodeJS.ReadWriteStream;
|
||||
|
||||
/** If you call JSONStream.stringify(false) the elements will only be seperated by a newline. */
|
||||
export declare function stringify(newlineOnly: NewlineOnlyIndicator): NodeJS.ReadWriteStream;
|
||||
type NewlineOnlyIndicator = false
|
||||
|
||||
/**
|
||||
* Create a writable stream.
|
||||
* you may pass in custom open, close, and seperator strings. But, by default,
|
||||
* JSONStream.stringify() will create an array,
|
||||
* (with default options open='[\n', sep='\n,\n', close='\n]\n')
|
||||
*/
|
||||
export declare function stringify(open: string, sep: string, close: string): NodeJS.ReadWriteStream;
|
||||
|
||||
export declare function stringifyObject(): NodeJS.ReadWriteStream;
|
||||
|
||||
@@ -8,6 +8,7 @@ read = read.pipe(json.parse('*'));
|
||||
read = read.pipe(json.parse(['foo/*', 'bar/*']));
|
||||
|
||||
read = json.stringify();
|
||||
read = json.stringify(false);
|
||||
read = json.stringify('{', ',', '}');
|
||||
|
||||
read = json.stringifyObject();
|
||||
|
||||
Reference in New Issue
Block a user