Skip to content

Commit

Permalink
feat: create node compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Dec 20, 2024
1 parent b3e8ecd commit eca2390
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand All @@ -20,7 +20,8 @@
"export",
"functional",
"functions",
"bun"
"bun",
"node"
],
"exports": {
".": {
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down Expand Up @@ -59,7 +61,7 @@ export const spreadsheet: Spreadsheet = Object.assign(

store: async ({ content }: SpreadsheetContent, path: string): Promise<void> => {
try {
await Bun.write(path, content)
await writeFile(path, content)
}
catch (error) {
throw new Error(`Failed to store spreadsheet: ${(error as Error).message}`)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit eca2390

Please sign in to comment.