test-this-package-today
Version:
Event Inc is a fully managed event bus lets you send and receive data across mission-critical cloud apps, databases and warehouses.
5 lines (4 loc) • 556 B
text/typescript
export default {
csv: "function parseCSV (payload) { const [headerLine, ...dataLines] = payload.split('\\n'); const delimiter = ','; const headers = headerLine.split(delimiter); return dataLines.map((line) => { const cells = line.split(delimiter); return headers.reduce((obj, header, index) => { obj[header] = cells[index]; return obj; }, {}); }); };",
json: "function parseJSON (payload) { try { const parsedPayload = JSON.parse(payload); return Object.entries(parsedPayload).map(([key, value]) => ({ key, value })); } catch (e) { return []; } };"
};