How to mix node.js's Buffers and Typed Arrays
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Simple examples/methods showing how to mix node.js's Buffers and standard Typed Arrays

This repo is deprecated now, see Ayms/abstract-tls for optimized functions.

Rationale :

Node.js has defined its own proprietary Buffers and does not use standard w3c ArrayBuffer and Typed Array ( ).

In some cases you might want to use the standards instead or at least be able to switch from one to another, or use both at the same time.

For different reasons : for example if you want to run your code in different environments (on server side and client side (browser), see )

Install :

npm install node-typedarray


git clone
cd node-typedarray
npm link

Details :

These are simple methods and examples showing how to mix both types of buffers. Probably it can be optimized, the intent here is just to give some ideas.

See the comments in the code, it is interesting to note that under certain conditions you can use both types of buffers together without needing any conversion at any time (in node.js environment for example)

TextEncoder and TextDecoder functions (based on ) can be retrieved here : (Joshua Bell) and integrated into the code or as a node.js module, it does include a very usefull option {stream:true} (which is absent from node.js's toString method, as well as modified toString method here, if you want to use it you must customize it yourself)

Tests :

Successfully tested with, mixing Buffers and Typed Arrays.

See simple tests in the code.

Related projects :