import Pappa from "papaparse"; // Example usage: // const rows = fetchCSV( // "https://covid19.who.int/WHO-COVID-19-global-data.csv", // { // last: 100, // columns: ["New_cases", "Date_reported", "Country"], // } // ); export async function fetchCSV(callExpression) { console.time("fetchCSV Total"); const [ urlNode, { properties: { last: limit = 10, columns = [] }, }, ] = callExpression.arguments; const url = urlNode.get(); console.time("Fetch"); const response = await fetch(url); const csvText = await response.text(); console.timeEnd("Fetch"); console.time("Parse"); let rows = Pappa.parse(csvText, { fastMode: true }).data; console.timeEnd("Parse"); console.time("Render"); const columnIndices = new Array(columns.length); for (let i = 0; i < columns.length; i++) { columnIndices[i] = rows[0].indexOf(columns[i]); } rows = rows .slice(Math.max(limit, rows.length) - limit) .reverse() .filter((columns) => columns.every(Boolean)); const value = ( {rows.map((columns) => ( {columnIndices.map((columnIndex) => ( ))} ))} ); console.timeEnd("Render"); console.timeEnd("fetchCSV Total"); return value; } n value='benchmark2'>benchmark2 Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/packages (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2023-03-30Fix InferGetStaticParamsType and InferGetStaticPropsType not working with ↵Gravatar Erika 2-7/+16
sync getStaticPaths (#6711) * fix(types): Fix InferGetStaticParamsType (and its props equivalent) not working when getStaticPaths wasn't async * chore: changeset * fix: use type imports
2023-03-30Fix multiple images being generated for the same image (#6710)Gravatar Erika 6-15/+28
* fix(images): Fix multiple calls to same image generating multiple images * chore: changeset
2023-03-30[RSS] Fix: update `RSSFeedItem` type to comply with `strictest` tsconfig (#6614)Gravatar Aivars Liepa 2-1/+6
* fix RSSFeedItem type for `strictest` tsconfig * add .changeset --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
2023-03-29Update lit-ssr dependency (#6681)Gravatar Elliott Marquez 13-82/+107
* update lit-ssr dependency * delete unnecessary lit shim checks * delete another unused lit shim feature * fix sass build * bump lit and polyfill versions to match ssr req * shim HTMLElement in test * remove lit global shim workarounds * re-shim Astro's ce.define * remove fix window test and shim HTML Element * Update .changeset/gold-windows-fly.md Co-authored-by: Augustine Kim <ajk830@gmail.com> * fix window check test * implement suggestoins --------- Co-authored-by: Augustine Kim <ajk830@gmail.com>
2023-03-29fix(images): Improve error handling around the new assets feature (#6649)Gravatar Erika 17-21/+290
* fix(images): Improve error handling around the new assets feature * fix: add missing error message * fix(images): Fix schema preprocessing logic returning undefined when the file doesn't exist * test: add tests * chore: lockfile * chore: changeset * Apply suggestions from code review Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> * test: remove console.logs * fix(images): properly join with path * fix: attempt a fix * test: remove console.log * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * fix: add undefined test for global for SSR --------- Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-03-29Use debug option for debugDir (#6554)Gravatar Isaac 1-1/+1
Co-authored-by: Matthew Phillips <matthew@skypack.dev>