Carga
This commit is contained in:
2025-04-17 00:35:33 -06:00
parent 4977462629
commit 67fc72aed5
1333 changed files with 1077639 additions and 0 deletions

View File

@@ -0,0 +1,402 @@
/* *
*
* (c) 2012-2021 Highsoft AS
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* Authors:
* - Torstein Hønsi
* - Christer Vasseng
* - Gøran Slettemark
* - Sophie Bremer
*
* */
'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import DataParser from './DataParser.js';
import DataConverter from '../DataConverter.js';
import U from '../../Core/Utilities.js';
var merge = U.merge;
/* eslint-disable no-invalid-this, require-jsdoc, valid-jsdoc */
/**
* Handles parsing and transforming CSV to a table.
*
* @private
*/
var CSVParser = /** @class */ (function (_super) {
__extends(CSVParser, _super);
/* *
*
* Constructor
*
* */
/**
* Constructs an instance of the CSV parser.
*
* @param {CSVParser.OptionsType} [options]
* Options for the CSV parser.
*
* @param {DataConverter} converter
* Parser data converter.
*/
function CSVParser(options, converter) {
var _this = _super.call(this) || this;
/* *
*
* Properties
*
* */
_this.columns = [];
_this.headers = [];
_this.dataTypes = [];
_this.options = merge(CSVParser.defaultOptions, options);
_this.converter = converter || new DataConverter();
return _this;
}
/**
* Initiates parsing of CSV
*
* @param {CSVParser.OptionsType}[options]
* Options for the parser
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*
* @emits CSVDataParser#parse
* @emits CSVDataParser#afterParse
*/
CSVParser.prototype.parse = function (options, eventDetail) {
var parser = this, dataTypes = parser.dataTypes, converter = parser.converter, parserOptions = merge(this.options, options), beforeParse = parserOptions.beforeParse, lineDelimiter = parserOptions.lineDelimiter, firstRowAsNames = parserOptions.firstRowAsNames, itemDelimiter = parserOptions.itemDelimiter;
var lines, rowIt = 0, csv = parserOptions.csv, startRow = parserOptions.startRow, endRow = parserOptions.endRow, column;
parser.columns = [];
parser.emit({
type: 'parse',
columns: parser.columns,
detail: eventDetail,
headers: parser.headers
});
if (csv && beforeParse) {
csv = beforeParse(csv);
}
if (csv) {
lines = csv
.replace(/\r\n/g, '\n') // Unix
.replace(/\r/g, '\n') // Mac
.split(lineDelimiter || '\n');
if (!startRow || startRow < 0) {
startRow = 0;
}
if (!endRow || endRow >= lines.length) {
endRow = lines.length - 1;
}
if (!itemDelimiter) {
parser.guessedItemDelimiter = parser.guessDelimiter(lines);
}
// If the first row contain names, add them to the
// headers array and skip the row.
if (firstRowAsNames) {
var headers = lines[0]
.split(itemDelimiter || parser.guessedItemDelimiter || ',');
// Remove ""s from the headers
for (var i = 0; i < headers.length; i++) {
headers[i] = headers[i].replace(/^["']|["']$/g, '');
}
parser.headers = headers;
startRow++;
}
var offset = 0;
for (rowIt = startRow; rowIt <= endRow; rowIt++) {
if (lines[rowIt][0] === '#') {
offset++;
}
else {
parser.parseCSVRow(lines[rowIt], rowIt - startRow - offset);
}
}
if (dataTypes.length &&
dataTypes[0].length &&
dataTypes[0][1] === 'date' && // format is a string date
!parser.converter.getDateFormat()) {
parser.converter.deduceDateFormat(parser.columns[0], null, true);
}
// Guess types.
for (var i = 0, iEnd = parser.columns.length; i < iEnd; ++i) {
column = parser.columns[i];
for (var j = 0, jEnd = column.length; j < jEnd; ++j) {
if (column[j] && typeof column[j] === 'string') {
var cellValue = converter.asGuessedType(column[j]);
if (cellValue instanceof Date) {
cellValue = cellValue.getTime();
}
parser.columns[i][j] = cellValue;
}
}
}
}
parser.emit({
type: 'afterParse',
columns: parser.columns,
detail: eventDetail,
headers: parser.headers
});
};
/**
* Internal method that parses a single CSV row
*/
CSVParser.prototype.parseCSVRow = function (columnStr, rowNumber) {
var parser = this, converter = this.converter, columns = parser.columns || [], dataTypes = parser.dataTypes, _a = parser.options, startColumn = _a.startColumn, endColumn = _a.endColumn, itemDelimiter = (parser.options.itemDelimiter ||
parser.guessedItemDelimiter);
var decimalPoint = parser.options.decimalPoint;
if (!decimalPoint || decimalPoint === itemDelimiter) {
decimalPoint = parser.guessedDecimalPoint || '.';
}
var i = 0, c = '', cl = '', cn = '', token = '', actualColumn = 0, column = 0;
/**
* @private
*/
function read(j) {
c = columnStr[j];
cl = columnStr[j - 1];
cn = columnStr[j + 1];
}
/**
* @private
*/
function pushType(type) {
if (dataTypes.length < column + 1) {
dataTypes.push([type]);
}
if (dataTypes[column][dataTypes[column].length - 1] !== type) {
dataTypes[column].push(type);
}
}
/**
* @private
*/
function push() {
if (startColumn > actualColumn || actualColumn > endColumn) {
// Skip this column, but increment the column count (#7272)
++actualColumn;
token = '';
return;
}
// Save the type of the token.
if (typeof token === 'string') {
if (!isNaN(parseFloat(token)) && isFinite(token)) {
token = parseFloat(token);
pushType('number');
}
else if (!isNaN(Date.parse(token))) {
token = token.replace(/\//g, '-');
pushType('date');
}
else {
pushType('string');
}
}
else {
pushType('number');
}
if (columns.length < column + 1) {
columns.push([]);
}
// Try to apply the decimal point, and check if the token then is a
// number. If not, reapply the initial value
if (typeof token !== 'number' &&
converter.guessType(token) !== 'number' &&
decimalPoint) {
var initialValue = token;
token = token.replace(decimalPoint, '.');
if (converter.guessType(token) !== 'number') {
token = initialValue;
}
}
columns[column][rowNumber] = token;
token = '';
++column;
++actualColumn;
}
if (!columnStr.trim().length) {
return;
}
if (columnStr.trim()[0] === '#') {
return;
}
for (; i < columnStr.length; i++) {
read(i);
if (c === '#') {
// If there are hexvalues remaining (#13283)
if (!/^#[0-F]{3,3}|[0-F]{6,6}/i.test(columnStr.substr(i))) {
// The rest of the row is a comment
push();
return;
}
}
// Quoted string
if (c === '"') {
read(++i);
while (i < columnStr.length) {
if (c === '"' && cl !== '"' && cn !== '"') {
break;
}
if (c !== '"' || (c === '"' && cl !== '"')) {
token += c;
}
read(++i);
}
}
else if (c === itemDelimiter) {
push();
// Actual column data
}
else {
token += c;
}
}
push();
};
/**
* Internal method that guesses the delimiter from the first
* 13 lines of the CSV
* @param {Array<string>} lines
* The CSV, split into lines
*/
CSVParser.prototype.guessDelimiter = function (lines) {
var points = 0, commas = 0, guessed;
var potDelimiters = {
',': 0,
';': 0,
'\t': 0
}, linesCount = lines.length;
for (var i = 0; i < linesCount; i++) {
var inStr = false, c = void 0, cn = void 0, cl = void 0, token = '';
// We should be able to detect dateformats within 13 rows
if (i > 13) {
break;
}
var columnStr = lines[i];
for (var j = 0; j < columnStr.length; j++) {
c = columnStr[j];
cn = columnStr[j + 1];
cl = columnStr[j - 1];
if (c === '#') {
// Skip the rest of the line - it's a comment
break;
}
if (c === '"') {
if (inStr) {
if (cl !== '"' && cn !== '"') {
while (cn === ' ' && j < columnStr.length) {
cn = columnStr[++j];
}
// After parsing a string, the next non-blank
// should be a delimiter if the CSV is properly
// formed.
if (typeof potDelimiters[cn] !== 'undefined') {
potDelimiters[cn]++;
}
inStr = false;
}
}
else {
inStr = true;
}
}
else if (typeof potDelimiters[c] !== 'undefined') {
token = token.trim();
if (!isNaN(Date.parse(token))) {
potDelimiters[c]++;
}
else if (isNaN(Number(token)) ||
!isFinite(Number(token))) {
potDelimiters[c]++;
}
token = '';
}
else {
token += c;
}
if (c === ',') {
commas++;
}
if (c === '.') {
points++;
}
}
}
// Count the potential delimiters.
// This could be improved by checking if the number of delimiters
// equals the number of columns - 1
if (potDelimiters[';'] > potDelimiters[',']) {
guessed = ';';
}
else if (potDelimiters[','] > potDelimiters[';']) {
guessed = ',';
}
else {
// No good guess could be made..
guessed = ',';
}
// Try to deduce the decimal point if it's not explicitly set.
// If both commas or points is > 0 there is likely an issue
if (points > commas) {
this.guessedDecimalPoint = '.';
}
else {
this.guessedDecimalPoint = ',';
}
return guessed;
};
/**
* Handles converting the parsed data to a table.
*
* @return {DataTable}
* Table from the parsed CSV.
*/
CSVParser.prototype.getTable = function () {
return DataParser.getTableFromColumns(this.columns, this.headers);
};
/* *
*
* Static Properties
*
* */
/**
* Default options
*/
CSVParser.defaultOptions = __assign(__assign({}, DataParser.defaultOptions), { lineDelimiter: '\n' });
return CSVParser;
}(DataParser));
/* *
*
* Export
*
* */
export default CSVParser;

View File

@@ -0,0 +1,101 @@
/* *
*
* (c) 2020-2022 Highsoft AS
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* Authors:
* - Sophie Bremer
* - Sebastian Bochan
* - Gøran Slettemark
*
* */
'use strict';
import DataTable from '../DataTable.js';
import U from '../../Core/Utilities.js';
var addEvent = U.addEvent, fireEvent = U.fireEvent, uniqueKey = U.uniqueKey;
/* *
*
* Class
*
* */
/**
* Abstract class providing an interface and basic methods for a DataParser
*
* @private
*/
var DataParser = /** @class */ (function () {
function DataParser() {
}
/* *
*
* Static Functions
*
* */
/**
* Converts an array of columns to a table instance. Second dimension of the
* array are the row cells.
*
* @param {Array<DataTable.Column>} [columns]
* Array to convert.
*
* @param {Array<string>} [headers]
* Column names to use.
*
* @return {DataTable}
* Table instance from the arrays.
*/
DataParser.getTableFromColumns = function (columns, headers) {
if (columns === void 0) { columns = []; }
if (headers === void 0) { headers = []; }
var table = new DataTable();
for (var i = 0, iEnd = Math.max(headers.length, columns.length); i < iEnd; ++i) {
table.setColumn(headers[i] || "".concat(i), columns[i]);
}
return table;
};
/**
* Emits an event on the DataParser instance.
*
* @param {DataParser.Event} [e]
* Event object containing additional event data
*/
DataParser.prototype.emit = function (e) {
fireEvent(this, e.type, e);
};
/**
* Registers a callback for a specific parser event.
*
* @param {string} type
* Event type as a string.
*
* @param {DataEventEmitter.EventCallback} callback
* Function to register for an modifier callback.
*
* @return {Function}
* Function to unregister callback from the modifier event.
*/
DataParser.prototype.on = function (type, callback) {
return addEvent(this, type, callback);
};
/* *
*
* Static Properties
*
* */
/**
* Default options
*/
DataParser.defaultOptions = {
startColumn: 0,
endColumn: Number.MAX_VALUE,
startRow: 0,
endRow: Number.MAX_VALUE,
firstRowAsNames: true,
switchRowsAndColumns: false
};
return DataParser;
}());
export default DataParser;

View File

@@ -0,0 +1,224 @@
/* *
*
* (c) 2012-2021 Highsoft AS
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* Authors:
* - Torstein Hønsi
* - Gøran Slettemark
* - Wojciech Chmiel
* - Sophie Bremer
*
* */
'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import DataParser from './DataParser.js';
import DataConverter from '../DataConverter.js';
import U from '../../Core/Utilities.js';
var merge = U.merge, uniqueKey = U.uniqueKey;
/* *
*
* Class
*
* */
/**
* Handles parsing and transformation of an Google Sheets to a table.
*
* @private
*/
var GoogleSheetsParser = /** @class */ (function (_super) {
__extends(GoogleSheetsParser, _super);
/* *
*
* Constructor
*
* */
/**
* Constructs an instance of the GoogleSheetsParser.
*
* @param {GoogleSheetsParser.OptionsType} [options]
* Options for the Google Sheets parser.
*
* @param {DataConverter} converter
* Parser data converter.
*/
function GoogleSheetsParser(options, converter) {
var _this = _super.call(this) || this;
_this.columns = [];
_this.headers = [];
_this.options = merge(GoogleSheetsParser.defaultOptions, options);
_this.converter = converter || new DataConverter();
return _this;
}
/* *
*
* Functions
*
* */
GoogleSheetsParser.prototype.getSheetColumns = function (json) {
var parser = this, _a = parser.options, startColumn = _a.startColumn, endColumn = _a.endColumn, startRow = _a.startRow, endRow = _a.endRow, columns = [], cells = json.feed.entry, cellCount = (cells || []).length;
var cell, colCount = 0, rowCount = 0, val, gr, gc, cellInner, i, j;
// First, find the total number of columns and rows that
// are actually filled with data
for (i = 0; i < cellCount; i++) {
cell = cells[i];
colCount = Math.max(colCount, cell.gs$cell.col);
rowCount = Math.max(rowCount, cell.gs$cell.row);
}
// Set up arrays containing the column data
for (i = 0; i < colCount; i++) {
if (i >= startColumn && i <= endColumn) {
// Create new columns with the length of either
// end-start or rowCount
columns[i - startColumn] = [];
}
}
// Loop over the cells and assign the value to the right
// place in the column arrays
for (i = 0; i < cellCount; i++) {
cell = cells[i];
gr = cell.gs$cell.row - 1; // rows start at 1
gc = cell.gs$cell.col - 1; // columns start at 1
// If both row and col falls inside start and end set the
// transposed cell value in the newly created columns
if (gc >= startColumn && gc <= endColumn &&
gr >= startRow && gr <= endRow) {
cellInner = cell.gs$cell || cell.content;
val = null;
if (cellInner.numericValue) {
if (cellInner.$t.indexOf('/') >= 0 || (cellInner.$t.indexOf('-') >= 0 &&
cellInner.$t.indexOf('.') === -1)) {
// This is a date - for future reference.
val = cellInner.$t;
}
else if (cellInner.$t.indexOf('%') > 0) {
// Percentage
val = parseFloat(cellInner.numericValue) * 100;
}
else {
val = parseFloat(cellInner.numericValue);
}
}
else if (cellInner.$t && cellInner.$t.length) {
val = cellInner.$t;
}
columns[gc - startColumn][gr - startRow] = val;
}
}
// Insert null for empty spreadsheet cells (#5298)
for (i = 0; i < colCount; i++) {
var column = columns[i];
// TODO: should this check be necessary?
if (column.length) {
for (i = 0; i < column.length; i++) {
if (typeof column[i] === 'undefined') {
column[i] = null;
}
}
}
}
return columns;
};
/**
* Initiates the parsing of the Google Sheet
*
* @param {GoogleSheetsParser.OptionsType}[options]
* Options for the parser
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*
* @emits GoogleSheetsParser#parse
* @emits GoogleSheetsParser#afterParse
*/
GoogleSheetsParser.prototype.parse = function (jsonProp, eventDetail) {
var parser = this, parserOptions = merge(true, parser.options, { json: jsonProp }), converter = parser.converter, json = parserOptions.json, cells = json.feed.entry, headers = parser.headers;
var column;
if (!cells || cells.length === 0) {
return false;
}
parser.headers = [];
parser.columns = [];
parser.emit({
type: 'parse',
columns: parser.columns,
detail: eventDetail,
headers: parser.headers
});
parser.columns = parser.getSheetColumns(json);
for (var i = 0, iEnd = parser.columns.length; i < iEnd; i++) {
column = parser.columns[i];
parser.headers[i] = parserOptions.firstRowAsNames ?
column.splice(0, 1).toString() :
uniqueKey();
for (var j = 0, jEnd = column.length; j < jEnd; ++j) {
if (column[j] && typeof column[j] === 'string') {
var cellValue = converter.asGuessedType(column[j]);
if (cellValue instanceof Date) {
cellValue = cellValue.getTime();
}
parser.columns[i][j] = cellValue;
}
}
}
parser.emit({
type: 'afterParse',
columns: parser.columns,
detail: eventDetail,
headers: parser.headers
});
};
/**
* Handles converting the parsed data to a table.
*
* @return {DataTable}
* Table from the parsed Google Sheet
*/
GoogleSheetsParser.prototype.getTable = function () {
return DataParser.getTableFromColumns(this.columns, this.headers);
};
/* *
*
* Static Properties
*
* */
/**
* Default options
*/
GoogleSheetsParser.defaultOptions = __assign(__assign({}, DataParser.defaultOptions), { json: {} });
return GoogleSheetsParser;
}(DataParser));
/* *
*
* Export
*
* */
export default GoogleSheetsParser;

View File

@@ -0,0 +1,215 @@
/* *
*
* (c) 2012-2021 Highsoft AS
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* Authors:
* - Torstein Hønsi
* - Gøran Slettemark
* - Wojciech Chmiel
* - Sophie Bremer
*
* */
'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import DataParser from './DataParser.js';
import DataConverter from '../DataConverter.js';
import U from '../../Core/Utilities.js';
var merge = U.merge;
/* *
*
* Class
*
* */
/**
* Handles parsing and transformation of an HTML table to a table.
*
* @private
*/
var HTMLTableParser = /** @class */ (function (_super) {
__extends(HTMLTableParser, _super);
/* *
*
* Constructor
*
* */
/**
* Constructs an instance of the HTML table parser.
*
* @param {HTMLTableParser.OptionsType} [options]
* Options for the CSV parser.
*
* @param {HTMLElement | null} tableElement
* The HTML table to parse
*
* @param {DataConverter} converter
* Parser data converter.
*/
function HTMLTableParser(options, tableElement, converter) {
if (tableElement === void 0) { tableElement = null; }
var _this = _super.call(this) || this;
_this.columns = [];
_this.headers = [];
_this.options = merge(HTMLTableParser.defaultOptions, options);
_this.converter = converter || new DataConverter();
if (tableElement) {
_this.tableElement = tableElement;
_this.tableElementID = tableElement.id;
}
else if (options && options.tableHTML) {
_this.tableElement = options.tableHTML;
_this.tableElementID = options.tableHTML.id;
}
return _this;
}
/* *
*
* Functions
*
* */
/**
* Initiates the parsing of the HTML table
*
* @param {HTMLTableParser.OptionsType}[options]
* Options for the parser
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*
* @emits CSVDataParser#parse
* @emits CSVDataParser#afterParse
* @emits HTMLTableParser#parseError
*/
HTMLTableParser.prototype.parse = function (options, eventDetail) {
var parser = this, converter = this.converter, columns = [], headers = [], parseOptions = merge(parser.options, options), endRow = parseOptions.endRow, startColumn = parseOptions.startColumn, endColumn = parseOptions.endColumn, firstRowAsNames = parseOptions.firstRowAsNames, tableHTML = parseOptions.tableHTML || this.tableElement;
if (!(tableHTML instanceof HTMLElement)) {
parser.emit({
type: 'parseError',
columns: columns,
detail: eventDetail,
headers: headers,
error: 'Not a valid HTML Table'
});
return;
}
parser.tableElement = this.tableElement;
parser.tableElementID = tableHTML.id;
this.emit({
type: 'parse',
columns: parser.columns,
detail: eventDetail,
headers: parser.headers
});
var rows = tableHTML.getElementsByTagName('tr'), rowsCount = rows.length;
var rowIndex = 0, item, startRow = parseOptions.startRow;
// Insert headers from the first row
if (firstRowAsNames && rowsCount) {
var items = rows[0].children, itemsLength = items.length;
for (var i = startColumn; i < itemsLength; i++) {
if (i > endColumn) {
break;
}
item = items[i];
if (item.tagName === 'TD' ||
item.tagName === 'TH') {
headers.push(item.innerHTML);
}
}
startRow++;
}
while (rowIndex < rowsCount) {
if (rowIndex >= startRow && rowIndex <= endRow) {
var columnsInRow = rows[rowIndex].children, columnsInRowLength = columnsInRow.length;
var columnIndex = 0;
while (columnIndex < columnsInRowLength) {
var relativeColumnIndex = columnIndex - startColumn, row = columns[relativeColumnIndex];
item = columnsInRow[columnIndex];
if ((item.tagName === 'TD' ||
item.tagName === 'TH') &&
(columnIndex >= startColumn &&
columnIndex <= endColumn)) {
if (!columns[relativeColumnIndex]) {
columns[relativeColumnIndex] = [];
}
var cellValue = converter.asGuessedType(item.innerHTML);
if (cellValue instanceof Date) {
cellValue = cellValue.getTime();
}
columns[relativeColumnIndex][rowIndex - startRow] = cellValue;
// Loop over all previous indices and make sure
// they are nulls, not undefined.
var i = 1;
while (rowIndex - startRow >= i &&
row[rowIndex - startRow - i] === void 0) {
row[rowIndex - startRow - i] = null;
i++;
}
}
columnIndex++;
}
}
rowIndex++;
}
this.columns = columns;
this.headers = headers;
this.emit({
type: 'afterParse',
columns: columns,
detail: eventDetail,
headers: headers
});
};
/**
* Handles converting the parsed data to a table.
*
* @return {DataTable}
* Table from the parsed HTML table
*/
HTMLTableParser.prototype.getTable = function () {
return DataParser.getTableFromColumns(this.columns, this.headers);
};
/* *
*
* Static Properties
*
* */
/**
* Default options
*/
HTMLTableParser.defaultOptions = __assign({}, DataParser.defaultOptions);
return HTMLTableParser;
}(DataParser));
/* *
*
* Export
*
* */
export default HTMLTableParser;