Sha256: bd79149e13a94500f560887d2865b5871a4f4ac976ab7985854f5815fe05c995
Contents?: true
Size: 758 Bytes
Versions: 57
Compression:
Stored size: 758 Bytes
Contents
/** * Convert a typed array to a Buffer without a copy * * Author: Feross Aboukhadijeh <https://feross.org> * License: MIT * * `npm install typedarray-to-buffer` */ var isTypedArray = require('is-typedarray').strict module.exports = function typedarrayToBuffer (arr) { if (isTypedArray(arr)) { // To avoid a copy, use the typed array's underlying ArrayBuffer to back new Buffer var buf = Buffer.from(arr.buffer) if (arr.byteLength !== arr.buffer.byteLength) { // Respect the "view", i.e. byteOffset and byteLength, without doing a copy buf = buf.slice(arr.byteOffset, arr.byteOffset + arr.byteLength) } return buf } else { // Pass through all other types to `Buffer.from` return Buffer.from(arr) } }
Version data entries
57 entries across 57 versions & 2 rubygems