You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
940 B

4 years ago
  1. # to-arraybuffer [![Build Status](https://travis-ci.org/jhiesey/to-arraybuffer.svg?branch=master)](https://travis-ci.org/jhiesey/to-arraybuffer)
  2. [![Sauce Test Status](https://saucelabs.com/browser-matrix/to-arraybuffer.svg)](https://saucelabs.com/u/to-arraybuffer)
  3. Convert from a Buffer to an ArrayBuffer as fast as possible.
  4. Note that in some cases the returned ArrayBuffer is backed by the same memory as the original
  5. Buffer (but in other cases it is a copy), so **modifying the ArrayBuffer is not recommended**.
  6. This module is designed to work both in node.js and in all browsers with ArrayBuffer support
  7. when using [the Buffer implementation provided by Browserify](https://www.npmjs.com/package/buffer).
  8. ## Usage
  9. ``` js
  10. var toArrayBuffer = require('to-arraybuffer')
  11. var buffer = new Buffer(100)
  12. // Fill the buffer with some data
  13. var ab = toArrayBuffer(buffer)
  14. // `ab` now contains the same data as `buffer`
  15. ```
  16. ## License
  17. MIT