Socket
Socket
Sign inDemoInstall

is-typed-array

Package Overview
Dependencies
17
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-typed-array

Is this value a JS Typed Array? This module works cross-realm/iframe, does not depend on `instanceof` or mutable properties, and despite ES6 Symbol.toStringTag.


Version published
Weekly downloads
33M
increased by1.97%
Maintainers
2
Install size
198 kB
Created
Weekly downloads
 

Package description

What is is-typed-array?

The is-typed-array npm package is a utility for checking if a given value is a typed array. Typed arrays are array-like objects that provide a mechanism for reading and writing raw binary data in memory buffers. This package helps in determining whether a variable is one of the typed array types, such as Int8Array, Uint8Array, Float32Array, etc.

What are is-typed-array's main functionalities?

Check if a value is a typed array

This feature allows you to check if a given value is a typed array. The function returns true if the value is one of the typed array types, and false otherwise.

const isTypedArray = require('is-typed-array');

const buffer = new ArrayBuffer(16);
const int16Array = new Int16Array(buffer);
const result = isTypedArray(int16Array); // true

Other packages similar to is-typed-array

Changelog

Source

v1.1.10 - 2022-11-02

Commits

  • [meta] add auto-changelog cf6d86b
  • [actions] update rebase action to use reusable workflow 8da51a5
  • [Dev Deps] update aud, is-callable, object-inspect, tape 554e3de
  • [Refactor] use gopd instead of an es-abstract helper [cdaa465`](https://github.com/inspect-js/is-typed-array/commit/cdaa465d5f94bfc9e32475e31209e1c2458a9603)
  • [Deps] update es-abstract 677ae4b
<!-- auto-changelog-above -->

1.1.9 / 2022-05-13

  • [Refactor] use foreach instead of for-each
  • [readme] markdown URL cleanup
  • [Deps] update es-abstract
  • [meta] use npmignore to autogenerate an npmignore file
  • [Dev Deps] update eslint, @ljharb/eslint-config, object-inspect, safe-publish-latest, tape
  • [actions] reuse common workflows
  • [actions] update codecov uploader

1.1.8 / 2021-08-30

  • [Refactor] use globalThis if available (#53)
  • [Deps] update available-typed-arrays
  • [Dev Deps] update @ljharb/eslint-config

1.1.7 / 2021-08-07

  • [Fix] if Symbol.toStringTag exists but is not present, use Object.prototype.toString
  • [Dev Deps] update is-callable, tape

1.1.6 / 2021-08-05

  • [Fix] use has-tostringtag to behave correctly in the presence of symbol shams
  • [readme] add actions and codecov badges
  • [meta] use prepublishOnly script for npm 7+
  • [Deps] update available-typed-arrays, es-abstract
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, object-inspect, tape
  • [actions] use node/install instead of node/run; use codecov action

1.1.5 / 2021-02-14

  • [meta] do not publish github action workflow files or nyc output
  • [Deps] update call-bind, es-abstract
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, is-callable, tape

1.1.4 / 2020-12-05

  • [readme] fix repo URLs, remove defunct badges
  • [Deps] update available-typed-arrays, es-abstract; use call-bind where applicable
  • [meta] gitignore nyc output
  • [meta] only audit prod deps
  • [actions] add "Allow Edits" workflow
  • [actions] switch Automatic Rebase workflow to pull_request_target event
  • [Dev Deps] update eslint, @ljharb/eslint-config, is-callable, make-arrow-function, make-generator-function, object-inspect, tape; add aud
  • [Tests] migrate tests to Github Actions
  • [Tests] run nyc on all tests

1.1.3 / 2020-01-24

  • [Refactor] use es-abstract’s callBound, available-typed-arrays, has-symbols

1.1.2 / 2020-01-20

  • [Fix] in envs without Symbol.toStringTag, dc8a8cc made arrays return true
  • [Tests] add evalmd to prelint

1.1.1 / 2020-01-18

  • [Robustness] don’t rely on Array.prototype.indexOf existing
  • [meta] remove unused Makefile and associated utilities
  • [meta] add funding field; create FUNDING.yml
  • [actions] add automatic rebasing / merge commit blocking
  • [Dev Deps] update eslint, @ljharb/eslint-config, is-callable, replace, semver, tape; add safe-publish-latest
  • [Tests] use shared travis-ci configs
  • [Tests] use npx aud instead of nsp or npm audit with hoops

1.1.0 / 2019-02-16

  • [New] add BigInt64Array and BigUint64Array
  • [Refactor] use an array instead of an object for storing Typed Array names
  • [meta] ignore test.html
  • [Tests] up to node v11.10, v10.15, v8.15, v7.10, v6.16, v5.10, v4.9
  • [Tests] remove jscs
  • [Tests] use npm audit instead of nsp
  • [Dev Deps] update eslint, @ljharb/eslint-config, is-callable, tape, replace, semver
  • [Dev Deps] remove unused eccheck script + dep

1.0.4 / 2016-03-19

  • [Fix] Symbol.toStringTag is on the super-[[Prototype]] of Float32Array, not the [[Prototype]] (#3)
  • [Tests] up to node v5.9, v4.4
  • [Tests] use pretest/posttest for linting/security
  • [Dev Deps] update tape, jscs, nsp, eslint, @ljharb/eslint-config, semver, is-callable

1.0.3 / 2015-10-13

  • [Deps] Add missing foreach dependency (#1)

1.0.2 / 2015-10-05

  • [Deps] Remove unneeded "isarray" dependency
  • [Dev Deps] update eslint, @ljharb/eslint-config

1.0.1 / 2015-10-02

  • Rerelease: avoid instanceof and the constructor property; work cross-realm; work with Symbol.toStringTag.

1.0.0 / 2015-05-06

  • Initial release.

Readme

Source

is-typed-array Version Badge

github actions coverage [![dependency status][5]][6] [![dev dependency status][7]][8] License Downloads

npm badge

Is this value a JS Typed Array? This module works cross-realm/iframe, does not depend on instanceof or mutable properties, and despite ES6 Symbol.toStringTag.

Example

var isTypedArray = require('is-typed-array');
var assert = require('assert');

assert.equal(false, isTypedArray(undefined));
assert.equal(false, isTypedArray(null));
assert.equal(false, isTypedArray(false));
assert.equal(false, isTypedArray(true));
assert.equal(false, isTypedArray([]));
assert.equal(false, isTypedArray({}));
assert.equal(false, isTypedArray(/a/g));
assert.equal(false, isTypedArray(new RegExp('a', 'g')));
assert.equal(false, isTypedArray(new Date()));
assert.equal(false, isTypedArray(42));
assert.equal(false, isTypedArray(NaN));
assert.equal(false, isTypedArray(Infinity));
assert.equal(false, isTypedArray(new Number(42)));
assert.equal(false, isTypedArray('foo'));
assert.equal(false, isTypedArray(Object('foo')));
assert.equal(false, isTypedArray(function () {}));
assert.equal(false, isTypedArray(function* () {}));
assert.equal(false, isTypedArray(x => x * x));
assert.equal(false, isTypedArray([]));

assert.ok(isTypedArray(new Int8Array()));
assert.ok(isTypedArray(new Uint8Array()));
assert.ok(isTypedArray(new Uint8ClampedArray()));
assert.ok(isTypedArray(new Int16Array()));
assert.ok(isTypedArray(new Uint16Array()));
assert.ok(isTypedArray(new Int32Array()));
assert.ok(isTypedArray(new Uint32Array()));
assert.ok(isTypedArray(new Float32Array()));
assert.ok(isTypedArray(new Float64Array()));
assert.ok(isTypedArray(new BigInt64Array()));
assert.ok(isTypedArray(new BigUint64Array()));

Tests

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

Keywords

FAQs

Last updated on 02 Nov 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc