isomorphic-git / lightning-fs

A lean and fast 'fs' for the browser
MIT License
477 stars 47 forks source link

toString method on result of readFile #15

Closed jcubic closed 5 years ago

jcubic commented 5 years ago

With browserFS you can call toString and get the value as string. With Lighting-FS it don't work like this. In node you can also use toString not sure what object readFile give in node.

check https://stackoverflow.com/questions/8936984/uint8array-to-string-in-javascript

billiegoose commented 5 years ago

BrowserFS and Node both use Buffers, but the browser polyfill for Node buffers is quite large so I have started avoiding using Buffers in isomorphic JavaScript code.

Can I suggest you use readFile(filepath, 'utf8') instead of readFile(filepath).toString()? That should work with all 3 systems.