memfs icon indicating copy to clipboard operation
memfs copied to clipboard

readSync and others functions doesn't really supports uint8array

Open Mesteery opened this issue 4 years ago • 1 comments

Functions such as readSync do not really support Uint8Array. It would be nice to support a Uint8Array, or better yet, like Node.js, all Typed Array and DataView.

Mesteery avatar Aug 27 '21 22:08 Mesteery

In a browser environment, and with [email protected], it works by coincidence. But with newer versions of buffer, it generates this error:

> fd = mfs.openSync('/proj1/foo', 'r')
> mfs.readSync(fd, new Uint8Array(500), 0, 500)
Uncaught TypeError: argument should be a Buffer
    at Uint8Array.copy (index-13.js:1691)
    at Node.read (node-6.js:122)
    at File.read (node-6.js:380)
    at Volume.readBase (volume-3.js:878)
    at Volume.readSync (volume-3.js:882)
    at <anonymous>:1:5

I encountered the problem while using wasmer-js.

corwin-of-amber avatar Sep 11 '21 11:09 corwin-of-amber