Skip to content

Commit

Permalink
removed dependency for json2Csv by accessing Json2CSVAsyncParser dire…
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiwerther committed Sep 12, 2022
1 parent 20c38b3 commit 61e3ef4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/datatable/InfineonDatatable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
import {
toRefs, computed, ref, onMounted, watch,
} from 'vue';
import json2Csv from 'json2csv';
import JSON2CSVAsyncParser from 'json2csv/lib/JSON2CSVAsyncParser';
import DatatableRow from './InfineonDatatableRow.vue';
import DatatablePager from './InfineonDatatablePager.vue';
import DatatableSortIcon from './InfineonDatatableSortIcon.vue';
Expand Down Expand Up @@ -249,7 +249,21 @@ async function exportCSV() {
const opts = { fields, transforms };
json2Csv.parseAsync(data.value, opts)
const parseAsync = async () => {
try {
const asyncParser = new JSON2CSVAsyncParser(opts);
const promise = asyncParser.promise();
data.value.forEach((item) => asyncParser.input.push(item));
asyncParser.input.push(null);
return promise;
} catch (err) {
return Promise.reject(err);
}
};
parseAsync()
.then((csv) => {
const sep = 'sep=,\r\n';
const BOM = new Uint8Array([0xEF, 0xBB, 0xBF]);
Expand Down

0 comments on commit 61e3ef4

Please sign in to comment.