[d565449] | 1 | # array-buffer-byte-length <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
---|
| 2 |
|
---|
| 3 | [![github actions][actions-image]][actions-url]
|
---|
| 4 | [![coverage][codecov-image]][codecov-url]
|
---|
| 5 | [![License][license-image]][license-url]
|
---|
| 6 | [![Downloads][downloads-image]][downloads-url]
|
---|
| 7 |
|
---|
| 8 | [![npm badge][npm-badge-png]][package-url]
|
---|
| 9 |
|
---|
| 10 | Get the byte length of an ArrayBuffer, even in engines without a `.byteLength` method.
|
---|
| 11 |
|
---|
| 12 | ## Example
|
---|
| 13 |
|
---|
| 14 | ```js
|
---|
| 15 | const assert = require('assert');
|
---|
| 16 | const byteLength = require('array-buffer-byte-length');
|
---|
| 17 |
|
---|
| 18 | assert.equal(byteLength([]), NaN, 'an array is not an ArrayBuffer, yields NaN');
|
---|
| 19 |
|
---|
| 20 | assert.equal(byteLength(new ArrayBuffer(0)), 0, 'ArrayBuffer of byteLength 0, yields 0');
|
---|
| 21 | ```
|
---|
| 22 |
|
---|
| 23 | ## Tests
|
---|
| 24 | Simply clone the repo, `npm install`, and run `npm test`
|
---|
| 25 |
|
---|
| 26 | [package-url]: https://npmjs.org/package/array-buffer-byte-length
|
---|
| 27 | [npm-version-svg]: https://versionbadg.es/inspect-js/array-buffer-byte-length.svg
|
---|
| 28 | [deps-svg]: https://david-dm.org/inspect-js/array-buffer-byte-length.svg
|
---|
| 29 | [deps-url]: https://david-dm.org/inspect-js/array-buffer-byte-length
|
---|
| 30 | [dev-deps-svg]: https://david-dm.org/inspect-js/array-buffer-byte-length/dev-status.svg
|
---|
| 31 | [dev-deps-url]: https://david-dm.org/inspect-js/array-buffer-byte-length#info=devDependencies
|
---|
| 32 | [npm-badge-png]: https://nodei.co/npm/array-buffer-byte-length.png?downloads=true&stars=true
|
---|
| 33 | [license-image]: https://img.shields.io/npm/l/array-buffer-byte-length.svg
|
---|
| 34 | [license-url]: LICENSE
|
---|
| 35 | [downloads-image]: https://img.shields.io/npm/dm/array-buffer-byte-length.svg
|
---|
| 36 | [downloads-url]: https://npm-stat.com/charts.html?package=array-buffer-byte-length
|
---|
| 37 | [codecov-image]: https://codecov.io/gh/inspect-js/array-buffer-byte-length/branch/main/graphs/badge.svg
|
---|
| 38 | [codecov-url]: https://app.codecov.io/gh/inspect-js/array-buffer-byte-length/
|
---|
| 39 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/array-buffer-byte-length
|
---|
| 40 | [actions-url]: https://github.com/inspect-js/array-buffer-byte-length/actions
|
---|