-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
readFileSync
should return a Buffer
instead of Uint8Array
#256
Comments
I realize that I maybe should not use |
Yep, I was able to work around this using an explicit encoding. |
Please remember to close this issue if you're good |
I think it would still be good to fix for Node compatibility?
On Wed, 6 Jul 2022 at 13:34, Degreat ***@***.***> wrote:
Please remember to close this issue if you're good
—
Reply to this email directly, view it on GitHub
<https://github.com/Jarred-Sumner/bun/issues/256#issuecomment-1176112951>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACFSBSI5BMTGWKGIZSVOLLVSVVNJANCNFSM52ZBLGGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
The underlying issue is that % cat > bun.mjs <<EOF
import { readFileSync } from 'fs';
console.log(Buffer.isBuffer(readFileSync('bun.mjs')));
EOF
% node bun.mjs
true
% bun bun.mjs
false Explicitly converting to a Buffer "just works" in Node and Bun: import { readFileSync } from 'fs';
const rFS = path => Buffer.from(readFileSync(path));
console.log(rFS('index.cljs').toString()); Looking at the roadmap https://github.com/Jarred-Sumner/bun/issues/159 , |
readFileSync
should return a Buffer
instead of Uint8Array
Yes we should fix this! Thanks @SheetJSDev and @borkdude for reproducing the issue, we're tracking it. |
This has been fixed |
Repro:
index.mjs
index.cljs:
On Node, this prints the contents of
index.mjs
as text. On bun it prints a bunch of numbers.See https://github.com/babashka/nbb/blob/main/doc/bun.md for more context on this.
The text was updated successfully, but these errors were encountered: