Skip to content

Commit

Permalink
This fixes #11, correct data type of file buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
xuri committed Jun 15, 2023
1 parent e9ceb74 commit 4681e3f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ declare module 'excelize-wasm' {
*/
export type Picture = {
Extension: string;
File: Uint8Array[];
File: Uint8Array;
Format: GraphicOptions;
};

Expand Down Expand Up @@ -905,7 +905,7 @@ declare module 'excelize-wasm' {
* @param r The contents buffer of the file
* @param opts The options for open and reading spreadsheet
*/
export function OpenReader(r: Uint8Array[], opts?: Options): NewFile;
export function OpenReader(r: Uint8Array, opts?: Options): NewFile;

/**
* @constructor
Expand Down Expand Up @@ -2428,7 +2428,7 @@ declare module 'excelize-wasm' {
* @param extension The extension name
* @param picture The contents buffer of the file
*/
SetSheetBackgroundFromBytes(sheet: string, extension: string, picture: Uint8Array[]): { error: string | null }
SetSheetBackgroundFromBytes(sheet: string, extension: string, picture: Uint8Array): { error: string | null }

/**
* SetSheetName provides a function to set the worksheet name by given
Expand Down
5 changes: 1 addition & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,13 +570,10 @@ export async function init(wasmPath) {
var buffer;
if (typeof window === 'undefined') {
global.excelize = {};
} else {
window.excelize = {};
}
if (typeof window === 'undefined') {
const fs = require('fs');
buffer = pako.ungzip(fs.readFileSync(wasmPath));
} else {
window.excelize = {};
buffer = pako.ungzip(await (await fetch(wasmPath)).arrayBuffer());
}
if (buffer[0] === 0x1f && buffer[1] === 0x8b) {
Expand Down

0 comments on commit 4681e3f

Please sign in to comment.