Skip to content

Commit 271794b

Browse files
committed
chore: fix fs_mem for updated typescript version
1 parent b2be25c commit 271794b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/fs_mem.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,26 @@ export class File extends Inode {
476476
readonly: boolean;
477477

478478
constructor(
479-
data: ArrayBuffer | SharedArrayBuffer | Uint8Array | Array<number>,
479+
data: ArrayBufferLike | ArrayLike<number>,
480480
options?: Partial<{
481481
readonly: boolean;
482482
}>,
483483
) {
484484
super();
485-
this.data = new Uint8Array(data);
485+
this.data = (() => {
486+
if (data instanceof ArrayBuffer) {
487+
return new Uint8Array(data);
488+
}
489+
490+
if (
491+
typeof SharedArrayBuffer !== "undefined" &&
492+
data instanceof SharedArrayBuffer
493+
) {
494+
return new Uint8Array(new Uint8Array(data));
495+
}
496+
497+
return new Uint8Array(data as ArrayLike<number>);
498+
})();
486499
this.readonly = !!options?.readonly;
487500
}
488501

0 commit comments

Comments
 (0)