2300885064f3da5a89cd951dd36dab69b9181b10940ab92c411bd8aa367c3280dfa1ae64467869776c7bdb8bfca04f99556e94c17d54598c8a360f7b65cf09 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # data-view-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 `byteLength` out of a DataView, robustly.
  8. This will work in node <= 0.10 and < 0.11.4, where there's no prototype accessor, only a nonconfigurable own property.
  9. It will also work in modern engines where `DataView.prototype.byteLength` has been deleted after this module has loaded.
  10. ## Example
  11. ```js
  12. const dataViewByteLength = require('data-view-byte-length');
  13. const assert = require('assert');
  14. const ab = new ArrayBuffer(42);
  15. const dv = new DataView(ab);
  16. assert.equal(dataViewByteLength(dv), 42);
  17. ```
  18. ## Tests
  19. Simply clone the repo, `npm install`, and run `npm test`
  20. [package-url]: https://npmjs.org/package/data-view-byte-length
  21. [npm-version-svg]: https://versionbadg.es/inspect-js/data-view-byte-length.svg
  22. [deps-svg]: https://david-dm.org/inspect-js/data-view-byte-length.svg
  23. [deps-url]: https://david-dm.org/inspect-js/data-view-byte-length
  24. [dev-deps-svg]: https://david-dm.org/inspect-js/data-view-byte-length/dev-status.svg
  25. [dev-deps-url]: https://david-dm.org/inspect-js/data-view-byte-length#info=devDependencies
  26. [npm-badge-png]: https://nodei.co/npm/data-view-byte-length.png?downloads=true&stars=true
  27. [license-image]: https://img.shields.io/npm/l/data-view-byte-length.svg
  28. [license-url]: LICENSE
  29. [downloads-image]: https://img.shields.io/npm/dm/data-view-byte-length.svg
  30. [downloads-url]: https://npm-stat.com/charts.html?package=data-view-byte-length
  31. [codecov-image]: https://codecov.io/gh/inspect-js/data-view-byte-length/branch/main/graphs/badge.svg
  32. [codecov-url]: https://app.codecov.io/gh/inspect-js/data-view-byte-length/
  33. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/data-view-byte-length
  34. [actions-url]: https://github.com/inspect-js/data-view-byte-length/actions