bytebuffer.js icon indicating copy to clipboard operation
bytebuffer.js copied to clipboard

toBuffer() docs wrong?

Open mprobst opened this issue 6 years ago • 3 comments

toBuffer() is documented as returning ArrayBuffer, but returns Buffer in nodejs in practice.

https://github.com/dcodeIO/bytebuffer.js/wiki/API#bytebuffertobufferforcecopy

Oversight, intentional?

mprobst avatar Feb 27 '18 16:02 mprobst

Iirc the docs have been generated from the browser version, where it's all ArrayBuffer.

dcodeIO avatar Feb 27 '18 16:02 dcodeIO

I ran into this because the TypeScript .d.ts has toBuffer return ArrayBuffer in node, which then causes incorrect compilation errors. Any ideas on how to avoid that?

Daniel Wirtz [email protected] schrieb am Di., 27. Feb. 2018 um 17:58 Uhr:

Iirc the docs have been generated from the browser version, where it's all ArrayBuffer.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dcodeIO/bytebuffer.js/issues/88#issuecomment-368948576, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcKHl8bReFL9RB58DlibPwox08N5J6ks5tZDQ1gaJpZM4SVPg9 .

mprobst avatar Feb 27 '18 21:02 mprobst

As a workaround, you could try to wrap the result of toBuffer() in a Buffer.from(...).

dcodeIO avatar Feb 27 '18 21:02 dcodeIO