UNPKG

tlojs

Version:

The Last One - The last npm package you'll need to install

30 lines (29 loc) 1.03 kB
"use strict"; var __spreadArray = (this && this.__spreadArray) || function (to, from) { for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i]; return to; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CsvExport = void 0; var CsvExport = /** @class */ (function () { function CsvExport() { } CsvExport.prototype.export = function (table) { var items = table.rows.select(function (x) { var o = {}; for (var _i = 0, _a = x.cells; _i < _a.length; _i++) { var cell = _a[_i]; o[cell.key] = cell.value; } return o; }); var headers = table.getHeaders(); var csv = __spreadArray([ headers.join(',') ], items.map(function (row) { return headers.map(function (fieldName) { return JSON.stringify(row[fieldName]); }).join(','); })); return csv.join('\r\n'); }; return CsvExport; }()); exports.CsvExport = CsvExport;