@dynamic-entity/server 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/express.mjs CHANGED
@@ -651,13 +651,13 @@ function detectFormat(head) {
651
651
  }
652
652
  return "csv";
653
653
  }
654
- async function* csvRows(stream, limits, found) {
654
+ async function* csvRows(stream, limits, found, forced) {
655
655
  const decoder = new TextDecoder("utf-8");
656
656
  const maxHeader = limits.maxCellLength * limits.maxColumns + limits.maxColumns;
657
657
  let held = "";
658
658
  let reader = null;
659
659
  const open = (headerLine) => {
660
- found.delimiter = detectDelimiter(headerLine);
660
+ found.delimiter = forced ?? detectDelimiter(headerLine);
661
661
  return createCsvReader({ delimiter: found.delimiter });
662
662
  };
663
663
  for await (const chunk of stream) {
@@ -716,7 +716,8 @@ async function readSheet(options) {
716
716
  const { head, stream } = await peek(counted, MAGIC_BYTES);
717
717
  const format = detectFormat(head);
718
718
  const found = {};
719
- const rows = format === "xlsx" ? xlsxRows(stream, limits) : csvRows(stream, limits, found);
719
+ const forced = /\.tsv$/i.test(options.filename ?? "") ? " " : void 0;
720
+ const rows = format === "xlsx" ? xlsxRows(stream, limits) : csvRows(stream, limits, found, forced);
720
721
  const iterator = rows[Symbol.asyncIterator]();
721
722
  const first = await iterator.next();
722
723
  const headers = first.done ? [] : first.value.map(cellText);