diff --git a/package.json b/package.json index f55dc15..bbacfde 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "bun-spreadsheets", + "name": "ts-spreadsheets", "type": "module", "version": "0.1.2", "description": "Easily generate spreadsheets, like CSVs and Excel files.", @@ -20,7 +20,8 @@ "export", "functional", "functions", - "bun" + "bun", + "node" ], "exports": { ".": { diff --git a/src/index.ts b/src/index.ts index 4887fad..4b80716 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,8 @@ import type { SpreadsheetType, } from './types' import { Buffer } from 'node:buffer' +import { writeFile } from 'node:fs/promises' +import { gzipSync } from 'node:zlib' export const spreadsheet: Spreadsheet = Object.assign( (data: Content) => ({ @@ -59,7 +61,7 @@ export const spreadsheet: Spreadsheet = Object.assign( store: async ({ content }: SpreadsheetContent, path: string): Promise => { try { - await Bun.write(path, content) + await writeFile(path, content) } catch (error) { throw new Error(`Failed to store spreadsheet: ${(error as Error).message}`) @@ -175,7 +177,7 @@ export function generateExcelContent(content: Content): Uint8Array { ] const zipData = files.map((file) => { - const compressedContent = new Uint8Array(Bun.gzipSync(file.content)) + const compressedContent = new Uint8Array(gzipSync(file.content)) const header = new Uint8Array(30 + file.name.length) const headerView = new DataView(header.buffer)