445cd8714d704735f0db27d4bb9102e8160282c63cc0fb73bbe3cb2bc112026548e6813f909a94bd73c5531df727294932b5c019400048d042acd7aa5dc6d4 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # data-view-byte-offset <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 `byteOffset` 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.byteOffset` has been deleted after this module has loaded.
  10. ## Example
  11. ```js
  12. const dataViewByteOffset = require('data-view-byte-offset');
  13. const assert = require('assert');
  14. const ab = new ArrayBuffer(42);
  15. const dv = new DataView(ab, 2);
  16. assert.equal(dataViewByteOffset(dv), 2);
  17. ```
  18. ## Tests
  19. Simply clone the repo, `npm install`, and run `npm test`
  20. [package-url]: https://npmjs.org/package/data-view-byte-offset
  21. [npm-version-svg]: https://versionbadg.es/inspect-js/data-view-byte-offset.svg
  22. [deps-svg]: https://david-dm.org/inspect-js/data-view-byte-offset.svg
  23. [deps-url]: https://david-dm.org/inspect-js/data-view-byte-offset
  24. [dev-deps-svg]: https://david-dm.org/inspect-js/data-view-byte-offset/dev-status.svg
  25. [dev-deps-url]: https://david-dm.org/inspect-js/data-view-byte-offset#info=devDependencies
  26. [npm-badge-png]: https://nodei.co/npm/data-view-byte-offset.png?downloads=true&stars=true
  27. [license-image]: https://img.shields.io/npm/l/data-view-byte-offset.svg
  28. [license-url]: LICENSE
  29. [downloads-image]: https://img.shields.io/npm/dm/data-view-byte-offset.svg
  30. [downloads-url]: https://npm-stat.com/charts.html?package=data-view-byte-offset
  31. [codecov-image]: https://codecov.io/gh/inspect-js/data-view-byte-offset/branch/main/graphs/badge.svg
  32. [codecov-url]: https://app.codecov.io/gh/inspect-js/data-view-byte-offset/
  33. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/data-view-byte-offset
  34. [actions-url]: https://github.com/inspect-js/data-view-byte-offset/actions