Papaparse: Fix NODE_STREAM_INPUT for TypeScript/next test (#36419)

* separate type and value for NODE_STREAM_INPUT

* add test for NODE_STREAM_INPUT

* format
This commit is contained in:
Lingkai Shen
2019-06-26 10:16:40 -07:00
committed by Benjamin Lichtman
parent 5cda518f79
commit 0385d7f65c
2 changed files with 13 additions and 10 deletions
+2 -1
View File
@@ -24,7 +24,7 @@ export function parse(file: File, config?: ParseConfig): ParseResult;
export function parse(stream: NodeJS.ReadableStream, config?: ParseConfig): ParseResult;
export function parse(stream: typeof NODE_STREAM_INPUT, config?: ParseConfig): NodeJS.ReadWriteStream;
export function parse(stream: NODE_STREAM_INPUT_TYPE, config?: ParseConfig): NodeJS.ReadWriteStream;
/**
* Unparses javascript data objects and returns a csv string
@@ -55,6 +55,7 @@ export const WORKERS_SUPPORTED: boolean;
export let SCRIPT_PATH: string;
// When passed to Papa Parse a Readable stream is returned.
declare type NODE_STREAM_INPUT_TYPE = 1;
export const NODE_STREAM_INPUT = 1;
/**
+11 -9
View File
@@ -33,26 +33,28 @@ Papa.parse("3,3,3", {
dynamicTyping: (field: string | number): boolean => /headerName/i.test(field.toString())
});
Papa.parse("3,3,3", {
dynamicTyping: {'headerName': true}
Papa.parse('3,3,3', {
dynamicTyping: { headerName: true },
});
Papa.parse("3,3,3", {
dynamicTyping: {5: true}
Papa.parse('3,3,3', {
dynamicTyping: { 5: true },
});
var file = new File(null, null, null);
Papa.parse(file, {
transform: function(value, field) {
},
complete: function (a, b) {
transform: function(value, field) {},
complete: function(a, b) {
a.meta.fields;
b.name;
}
},
});
// .pipe to make sure it returns a stream
Papa.parse(Papa.NODE_STREAM_INPUT, {
}).pipe
const readable = new Readable()
const rows = [
"1,2,3",