Create a `DataView` over an `ArrayBuffer`/8-bit typed array (commonly used in the browsers) or a `Buffer` (commonly used in Node.js).
npm install to-data-viewCreate a DataView over an ArrayBuffer/8-bit typed array (commonly used in the browsers) or a Buffer (commonly used in Node.js).
Supported inputs:
- ArrayBuffer
- Buffer
- Int8Array
- Uint8Array
- Uint8ClampedArray
``sh`
npm install --save to-data-view
`js
import toDataView from 'to-data-view'
// This function will accept both ArrayBuffer and Buffer as input
function awesomeParser (source) {
const view = toDataView(source)
// ...
}
`
- data (ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray, required)DataView
- returns
Return a DataView instance that uses the same memory as the provided ArrayBuffer, 8-bit typed array or Buffer`.