a6aa9a070d6b6bdffe4a203d74fc950f142872045d0ca4cc10e7002cf96facc46021f909c6d482b7ac557e4361130af78bcd43ae72056a6fc460ad9c8be77f 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # is-shared-array-buffer <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. Is this value a JS SharedArrayBuffer? This module works cross-realm/iframe, does not depend on `instanceof` or mutable properties, and despite ES6 Symbol.toStringTag.
  8. ## Example
  9. ```js
  10. var assert = require('assert');
  11. var isSharedArrayBuffer = require('is-shared-array-buffer');
  12. assert(!isSharedArrayBuffer(function () {}));
  13. assert(!isSharedArrayBuffer(null));
  14. assert(!isSharedArrayBuffer(function* () { yield 42; return Infinity; });
  15. assert(!isSharedArrayBuffer(Symbol('foo')));
  16. assert(!isSharedArrayBuffer(1n));
  17. assert(!isSharedArrayBuffer(Object(1n)));
  18. assert(!isSharedArrayBuffer(new Set()));
  19. assert(!isSharedArrayBuffer(new WeakSet()));
  20. assert(!isSharedArrayBuffer(new Map()));
  21. assert(!isSharedArrayBuffer(new WeakMap()));
  22. assert(!isSharedArrayBuffer(new WeakRef({})));
  23. assert(!isSharedArrayBuffer(new FinalizationRegistry(() => {})));
  24. assert(!isSharedArrayBuffer(new ArrayBuffer()));
  25. assert(isSharedArrayBuffer(new SharedArrayBuffer()));
  26. class MySharedArrayBuffer extends SharedArrayBuffer {}
  27. assert(isSharedArrayBuffer(new MySharedArrayBuffer()));
  28. ```
  29. ## Tests
  30. Simply clone the repo, `npm install`, and run `npm test`
  31. [package-url]: https://npmjs.org/package/is-shared-array-buffer
  32. [npm-version-svg]: https://versionbadg.es/inspect-js/is-shared-array-buffer.svg
  33. [deps-svg]: https://david-dm.org/inspect-js/is-shared-array-buffer.svg
  34. [deps-url]: https://david-dm.org/inspect-js/is-shared-array-buffer
  35. [dev-deps-svg]: https://david-dm.org/inspect-js/is-shared-array-buffer/dev-status.svg
  36. [dev-deps-url]: https://david-dm.org/inspect-js/is-shared-array-buffer#info=devDependencies
  37. [npm-badge-png]: https://nodei.co/npm/is-shared-array-buffer.png?downloads=true&stars=true
  38. [license-image]: https://img.shields.io/npm/l/is-shared-array-buffer.svg
  39. [license-url]: LICENSE
  40. [downloads-image]: https://img.shields.io/npm/dm/is-shared-array-buffer.svg
  41. [downloads-url]: https://npm-stat.com/charts.html?package=is-shared-array-buffer
  42. [codecov-image]: https://codecov.io/gh/inspect-js/is-shared-array-buffer/branch/main/graphs/badge.svg
  43. [codecov-url]: https://app.codecov.io/gh/inspect-js/is-shared-array-buffer/
  44. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-shared-array-buffer
  45. [actions-url]: https://github.com/inspect-js/is-shared-array-buffer/actions