'use strict' ; import type DataConverter from '../DataConverter' ; import type DataEventEmitter from '../DataEventEmitter' ; import type JSON from '../../Core/JSON' ; import DataTable from '../DataTable.js' ; import U from '../../Core/Utilities.js' ; const { addEvent , fireEvent , uniqueKey } = U ; private abstract class DataParser < TEventObject extends DataParser . Event > implements DataEventEmitter < TEventObject > { /**
     * Default options
     */ protected static readonly defaultOptions : DataParser . Options = { startColumn : 0 , endColumn : Number . MAX_VALUE , startRow : 0 , endRow : Number . MAX_VALUE , firstRowAsNames : true , switchRowsAndColumns : false } ; param { Array < DataTable . Column > } columns param { Array < string > } headers return { DataTable } public static getTableFromColumns ( columns = [ ] , headers = [ ] ) { const table = new DataTable ( ) ; for ( let i = 0 , iEnd = Math . max ( headers . length , columns . length ) ; i < iEnd ; ++ i ) { table . setColumn ( headers [ i ] || `${ i }` , columns [ i ] ) ; } return table ; } return { DataTable } public abstract getTable ( ) ; param { DataParser . Event } e public emit < T extends DataEventEmitter . Event > ( e ) { fireEvent ( this , e . type , e ) ; } param { string } type param { DataEventEmitter . EventCallback } callback return { Function } public on < TEvent extends DataEventEmitter . Event > ( type , callback ) { return addEvent ( this , type , callback ) ; } param { DataParser . Options } options public abstract parse ( options ) ; /**
     * DataConverter for the parser.
     */ public abstract converter : DataConverter ; } /**
 * Additionally provided types for events and conversion.
 */ namespace DataParser { /**
     * The basic event object for a DataParser instance.
     * Valid types are `parse`, `afterParse`, and `parseError`
     */ export interface Event extends DataEventEmitter . Event { readonly type : ( 'parse' | 'afterParse' | 'parseError' ) ; readonly columns : Array < DataTable . Column > ; readonly error ? : ( string | Error ) ; readonly headers : string [ ] ; } /**
     * The shared options for all DataParser instances
     */ export interface Options extends JSON . Object { startRow : number ; endRow : number ; startColumn : number ; endColumn : number ; firstRowAsNames : boolean ; switchRowsAndColumns : boolean ; } } export default DataParser ;