streamich/memfs

readSync and others functions doesn't really supports uint8array

Opened this issue · 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.

In a browser environment, and with buffer@4.9.2, 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.