- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert a binary NodeJS Buffer to JavaScript ArrayBuffer?
Access the buf.buffer property directly to convert a binary NodeJS Buffer to JavaScript ArrayBuffer. The write through the original Buffer instance writes the ArrayBufferView.
Keep in mind that the instances of Buffer are also instances of Uint8Array in node.js 4.x and higher versions.
Example
You can try the following code snippet to convert a NodeJS buffer to JavaScript ArrayBuffer −
function toArrayBuffer(myBuf) { var myBuffer = new ArrayBuffer(myBuf.length); var res = new Uint8Array(myBuffer); for (var i = 0; i < myBuf.length; ++i) { res[i] = myBuf[i]; } return myBuffer; }
- Related Articles
- Convert buffer to readable string in JavaScript?
- JavaScript ArrayBuffer Object
- How to convert Decimal to Binary in JavaScript?
- How to convert Binary to Decimal in JavaScript?
- How do I convert an integer to binary in JavaScript?
- How to Convert Binary to Decimal?
- How to Convert Decimal to Binary?
- How to Convert Binary to Octal?
- How to Convert Octal to Binary?
- How to Convert Binary to Hexadecimal?
- How do we convert binary to decimal and decimal to binary?
- How to convert a matrix to binary matrix in R?
- How to convert Decimal to Binary using C#?
- How to convert string to binary in Python?
- How to convert a binary matrix to logical matrix in R?

Advertisements