data-view-byte-length <sup>Version Badge</sup>

github actions coverage License Downloads

npm badge

Get the byteLength out of a DataView, robustly.

This will work in node <= 0.10 and < 0.11.4, where there's no prototype accessor, only a nonconfigurable own property. It will also work in modern engines where DataView.prototype.byteLength has been deleted after this module has loaded.

Example

const dataViewByteLength = require('data-view-byte-length');
const assert = require('assert');

const ab = new ArrayBuffer(42);
const dv = new DataView(ab);
assert.equal(dataViewByteLength(dv), 42);

Tests

Simply clone the repo, npm install, and run npm test

data-view-byte-length - Installation

To install data-view-byte-length via this registry, you'll need to install via the --registry parameter with your package manager.

n

NPM

npm install data-view-byte-length --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Yarn

yarn config set registry https://js.registry.sudovanilla.org
yarn install data-view-byte-length

Learn more about the config option.

PNPM

pnpm install data-view-byte-length --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Bun Logo

Bun

bun install data-view-byte-length --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Learn more about setting this up in your bunfig.toml configuration.


For Deno, add the following to your .npmrc file in your directory:

registry="https://js.registry.sudovanilla.org"

Then run the deno install command.

data-view-byte-length - Download

Download Tarball (v1.0.2)

Integrity sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ==
SHASUM 9e80f7ca52453ce3e93d25a35318767ea7704735
Tarball https://js.registry.sudovanilla.org/data-view-byte-length/-/data-view-byte-length-1.0.2.tgz