mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 14:27:04 +00:00
[PapaParse] Add delimitersToGuess to ParseConfig definition (#40803)
* Add delimitersToGuess to ParseConfig definition * [delimitersToGuess] GuessableDelimiters type and tests added following PR review
This commit is contained in:
Vendored
+9
-2
@@ -8,6 +8,7 @@
|
||||
// Behind The Math <https://github.com/BehindTheMath>
|
||||
// 3af <https://github.com/3af>
|
||||
// Janne Liuhtonen <https://github.com/jliuhtonen>
|
||||
// Raphaël Barbazza <https://github.com/rbarbazz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -35,10 +36,12 @@ export const unparse: (data: Array<Object> | Array<Array<any>> | UnparseObject,
|
||||
export const BAD_DELIMETERS: Array<string>;
|
||||
|
||||
// The true delimiter. Invisible. ASCII code 30. Should be doing the job we strangely rely upon commas and tabs for.
|
||||
export const RECORD_SEP: string;
|
||||
declare type RECORD_SEP_TYPE = '';
|
||||
export const RECORD_SEP = '';
|
||||
|
||||
// Also sometimes used as a delimiting character. ASCII code 31.
|
||||
export const UNIT_SEP: string;
|
||||
declare type UNIT_SEP_TYPE = '';
|
||||
export const UNIT_SEP = '';
|
||||
|
||||
// Whether or not the browser supports HTML5 Web Workers. If false, worker: true will have no effect.
|
||||
export const WORKERS_SUPPORTED: boolean;
|
||||
@@ -51,6 +54,9 @@ export let SCRIPT_PATH: string;
|
||||
declare type NODE_STREAM_INPUT_TYPE = 1;
|
||||
export const NODE_STREAM_INPUT = 1;
|
||||
|
||||
// The possible values for the ParseConfig property delimitersToGuess
|
||||
declare type GuessableDelimiters = ',' | '\t' | '|' | ';' | RECORD_SEP_TYPE | UNIT_SEP_TYPE;
|
||||
|
||||
/**
|
||||
* Configurable Properties
|
||||
*/
|
||||
@@ -104,6 +110,7 @@ export interface ParseConfig {
|
||||
skipEmptyLines?: boolean | 'greedy'; // default: false
|
||||
fastMode?: boolean; // default: undefined
|
||||
withCredentials?: boolean; // default: undefined
|
||||
delimitersToGuess?: GuessableDelimiters[]; // default: [',', '\t', '|', ';', Papa.RECORD_SEP, Papa.UNIT_SEP]
|
||||
|
||||
// Callbacks
|
||||
step?(results: ParseResult, parser: Parser): void; // default: undefined
|
||||
|
||||
@@ -41,6 +41,18 @@ Papa.parse('3,3,3', {
|
||||
dynamicTyping: { 5: true },
|
||||
});
|
||||
|
||||
Papa.parse('4,4,4', {
|
||||
delimitersToGuess: [';', ','],
|
||||
});
|
||||
|
||||
Papa.parse('4,4,4', {
|
||||
delimitersToGuess: [Papa.RECORD_SEP, '|', ',', ';'],
|
||||
});
|
||||
|
||||
Papa.parse('4;4;4', {
|
||||
delimitersToGuess: ['\t', Papa.UNIT_SEP],
|
||||
});
|
||||
|
||||
var file = new File(null, null, null);
|
||||
|
||||
Papa.parse(file, {
|
||||
|
||||
Reference in New Issue
Block a user