24c8a4d7483264969160a71f292caaa1aa0afa80d246339a0ef25a55aa688a572736550e806876f3040ddfb1d44f5454ba42d9ae97dbc9eed0a999834f5210 1.9 KB

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