Skip to content

Commit

Permalink
fix type changes on deflate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nexxkinn committed Sep 14, 2021
1 parent fc1e802 commit 5eb058a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode/
test*.zip
test*.zip
.gitconfig
2 changes: 1 addition & 1 deletion _test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ await test.push(new TextEncoder().encode('Hello World'), 'hello.txt');
await test.close();

// edit file
const {insert, remove, entries, close} = await open_zip('test copy.zip');
const {insert, remove, entries, close} = await open_zip('test.zip');
console.log(entries());
await insert(await Deno.open('icon.png'),'icon3.png');
console.log(entries());
Expand Down
7 changes: 5 additions & 2 deletions lib/deflate.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { deflateRaw, inflateRaw } from 'https://esm.sh/pako';

export function deflate(data:Uint8Array) {
return deflateRaw(data)
return deflateRaw(data) || new Uint8Array();
}

export function inflate(data:Uint8Array) {
return inflateRaw(data);
const output = inflateRaw(data);
if (!output) return new Uint8Array();
if (typeof output === 'string') return new TextEncoder().encode(output);
else return output;
}

0 comments on commit 5eb058a

Please sign in to comment.