Création d'un script séparé pour déclarer les interfaces correspondant aux options de Papa Parse

This commit is contained in:
Fabrice PENHOËT 2021-10-18 10:52:04 +02:00
parent d90e38d5dc
commit d980412b0f
2 changed files with 25 additions and 25 deletions

View File

@ -3,36 +3,14 @@ const errors= require("./errors.js");
import { RemoteSource } from "./freeDatas2HTMLRemoteSource"; import { RemoteSource } from "./freeDatas2HTMLRemoteSource";
import { ParseResults, Parsers, RemoteSources, RemoteSourceSettings } from "./interfaces"; import { ParseResults, Parsers, RemoteSources, RemoteSourceSettings } from "./interfaces";
import { PublicPapaParseOptions, PrivatePapaParseOptions } from "./interfacesPapaParse";
// Options de Papa Parse
// cf. https://www.papaparse.com/docs#config
interface PublicPapaParseOptions
{
delimiter: string;
newline: string;
quoteChar: string;
escapeChar: string;
transformHeader?(field: string, index: number): string;
preview: number;
comments: false|string;
fastMode: boolean|undefined;
transform?(value: string): string;
}
interface PrivatePapaParseOptions
{
header: boolean;
download: boolean;
downloadRequestHeaders: undefined| { [index: string]:string };
skipEmptyLines: string;
withCredentials: boolean|undefined;
}
export class ParserForCSV implements Parsers export class ParserForCSV implements Parsers
{ {
private _datasRemoteSource: RemoteSources; private _datasRemoteSource: RemoteSources;
private _datas2Parse:string=""; private _datas2Parse:string="";
private _parseResults:ParseResults|undefined=undefined; private _parseResults:ParseResults|undefined=undefined;
public options: PublicPapaParseOptions = public options: PublicPapaParseOptions=
{ {
delimiter:"", delimiter:"",
newline:"", newline:"",
@ -44,7 +22,7 @@ export class ParserForCSV implements Parsers
fastMode:undefined, fastMode:undefined,
transform:undefined transform:undefined
} }
private _privateOptions: PrivatePapaParseOptions = private _privateOptions: PrivatePapaParseOptions=
{ {
header:true, header:true,
download:false, download:false,

View File

@ -0,0 +1,22 @@
// Options de Papa Parse
// cf. https://www.papaparse.com/docs#config
interface PublicPapaParseOptions
{
delimiter: string;
newline: string;
quoteChar: string;
escapeChar: string;
transformHeader?(field: string, index: number): string;
preview: number;
comments: false|string;
fastMode: boolean|undefined;
transform?(value: string): string;
}
interface PrivatePapaParseOptions
{
header: boolean;
download: boolean;
downloadRequestHeaders: undefined| { [index: string]:string };
skipEmptyLines: string;
withCredentials: boolean|undefined;
}