is-shared-array-buffer <sup>Version Badge</sup>

github actions coverage License Downloads

npm badge

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.

Example

var assert = require('assert');
var isSharedArrayBuffer = require('is-shared-array-buffer');

assert(!isSharedArrayBuffer(function () {}));
assert(!isSharedArrayBuffer(null));
assert(!isSharedArrayBuffer(function* () { yield 42; return Infinity; });
assert(!isSharedArrayBuffer(Symbol('foo')));
assert(!isSharedArrayBuffer(1n));
assert(!isSharedArrayBuffer(Object(1n)));

assert(!isSharedArrayBuffer(new Set()));
assert(!isSharedArrayBuffer(new WeakSet()));
assert(!isSharedArrayBuffer(new Map()));
assert(!isSharedArrayBuffer(new WeakMap()));
assert(!isSharedArrayBuffer(new WeakRef({})));
assert(!isSharedArrayBuffer(new FinalizationRegistry(() => {})));
assert(!isSharedArrayBuffer(new ArrayBuffer()));

assert(isSharedArrayBuffer(new SharedArrayBuffer()));

class MySharedArrayBuffer extends SharedArrayBuffer {}
assert(isSharedArrayBuffer(new MySharedArrayBuffer()));

Tests

Simply clone the repo, npm install, and run npm test

is-shared-array-buffer - Installation

To install is-shared-array-buffer via this registry, you'll need to install via the --registry parameter with your package manager.

n

NPM

npm install is-shared-array-buffer --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Yarn

yarn config set registry https://js.registry.sudovanilla.org
yarn install is-shared-array-buffer

Learn more about the config option.

PNPM

pnpm install is-shared-array-buffer --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Bun Logo

Bun

bun install is-shared-array-buffer --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Learn more about setting this up in your bunfig.toml configuration.


For Deno, add the following to your .npmrc file in your directory:

registry="https://js.registry.sudovanilla.org"

Then run the deno install command.

is-shared-array-buffer - Download

Download Tarball (v1.0.4)

Integrity sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==
SHASUM 9b67844bd9b7f246ba0708c3a93e34269c774f6f
Tarball https://js.registry.sudovanilla.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.4.tgz