From a610882055ca470278200e4be6f45279f339c8c3 Mon Sep 17 00:00:00 2001 From: Alberto Restifo Date: Fri, 15 Jun 2018 13:00:24 +0200 Subject: [PATCH 1/3] Add NODE_STREAM_INPUT support to Papa Parse --- types/papaparse/index.d.ts | 6 ++++++ types/papaparse/papaparse-tests.ts | 3 +++ 2 files changed, 9 insertions(+) diff --git a/types/papaparse/index.d.ts b/types/papaparse/index.d.ts index d97a25010b..3b9a479030 100644 --- a/types/papaparse/index.d.ts +++ b/types/papaparse/index.d.ts @@ -4,6 +4,7 @@ // Rain Shen // João Loff // John Reilly +// Alberto Restifo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -18,6 +19,8 @@ export function parse(file: File, config?: ParseConfig): ParseResult; export function parse(stream: ReadableStream, config?: ParseConfig): ParseResult; +export function parse(stream: 1, config?: ParseConfig): ReadableStream; + /** * Unparses javascript data objects and returns a csv string */ @@ -45,6 +48,9 @@ export const WORKERS_SUPPORTED: boolean; // The relative path to Papa Parse. This is automatically detected when Papa Parse is loaded synchronously. export const SCRIPT_PATH: string; +// When passed to Papa Parse a Readable stream is returned. +export const NODE_STREAM_INPUT = 1; + /** * Configurable Properties */ diff --git a/types/papaparse/papaparse-tests.ts b/types/papaparse/papaparse-tests.ts index 1e527c4c32..5edcf9a251 100644 --- a/types/papaparse/papaparse-tests.ts +++ b/types/papaparse/papaparse-tests.ts @@ -36,6 +36,9 @@ Papa.parse(file, { } }); + +Papa.parse(Papa.NODE_STREAM_INPUT); + /** * Unparsing */ From fc32ee0facfaf4321fc0fafd032cc367fd25a0f2 Mon Sep 17 00:00:00 2001 From: Alberto Restifo Date: Fri, 15 Jun 2018 13:03:57 +0200 Subject: [PATCH 2/3] Bump version in header --- types/papaparse/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/papaparse/index.d.ts b/types/papaparse/index.d.ts index 3b9a479030..eb634e52b4 100644 --- a/types/papaparse/index.d.ts +++ b/types/papaparse/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for PapaParse v4.1 +// Type definitions for PapaParse v4.5 // Project: https://github.com/mholt/PapaParse // Definitions by: Pedro Flemming // Rain Shen From 1a590067d90c72d9984c593518565f9744ed1e7f Mon Sep 17 00:00:00 2001 From: Alberto Restifo Date: Thu, 21 Jun 2018 10:14:21 +0200 Subject: [PATCH 3/3] fix: Use typeof instead of int --- types/papaparse/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/papaparse/index.d.ts b/types/papaparse/index.d.ts index eb634e52b4..49dcdfdd95 100644 --- a/types/papaparse/index.d.ts +++ b/types/papaparse/index.d.ts @@ -19,7 +19,7 @@ export function parse(file: File, config?: ParseConfig): ParseResult; export function parse(stream: ReadableStream, config?: ParseConfig): ParseResult; -export function parse(stream: 1, config?: ParseConfig): ReadableStream; +export function parse(stream: typeof NODE_STREAM_INPUT, config?: ParseConfig): ReadableStream; /** * Unparses javascript data objects and returns a csv string