Socket
Socket
Sign inDemoInstall

is-typed-array

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-typed-array - npm Package Compare versions

Comparing version 1.1.11 to 1.1.12

6

CHANGELOG.md

@@ -8,2 +8,8 @@ # Changelog

## [v1.1.12](https://github.com/inspect-js/is-typed-array/compare/v1.1.11...v1.1.12) - 2023-07-17
### Commits
- [Refactor] use `which-typed-array` for all internals [`7619405`](https://github.com/inspect-js/is-typed-array/commit/761940532de595f6721fed101b02814dcfa7fe4e)
## [v1.1.11](https://github.com/inspect-js/is-typed-array/compare/v1.1.10...v1.1.11) - 2023-07-17

@@ -10,0 +16,0 @@

83

index.js
'use strict';
var forEach = require('for-each');
var availableTypedArrays = require('available-typed-arrays');
var callBind = require('call-bind');
var callBound = require('call-bind/callBound');
var whichTypedArray = require('which-typed-array');
var $toString = callBound('Object.prototype.toString');
var hasToStringTag = require('has-tostringtag/shams')();
var gOPD = require('gopd');
var g = typeof globalThis === 'undefined' ? global : globalThis;
var typedArrays = availableTypedArrays();
var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) {
for (var i = 0; i < array.length; i += 1) {
if (array[i] === value) {
return i;
}
}
return -1;
};
var $slice = callBound('String.prototype.slice');
var cache = { __proto__: null };
var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
if (hasToStringTag && gOPD && getPrototypeOf) {
forEach(typedArrays, function (typedArray) {
var arr = new g[typedArray]();
if (Symbol.toStringTag in arr) {
var proto = getPrototypeOf(arr);
var descriptor = gOPD(proto, Symbol.toStringTag);
if (!descriptor) {
var superProto = getPrototypeOf(proto);
descriptor = gOPD(superProto, Symbol.toStringTag);
}
cache['$' + typedArray] = callBind(descriptor.get);
}
});
} else {
forEach(typedArrays, function (typedArray) {
var arr = new g[typedArray]();
cache['$' + typedArray] = callBind(arr.slice);
});
}
var tryTypedArrays = function tryAllTypedArrays(value) {
var anyTrue = false;
forEach(cache, function (getter, typedArray) {
if (!anyTrue) {
try {
anyTrue = ('$' + getter(value)) === typedArray;
} catch (e) { /**/ }
}
});
return anyTrue;
};
var trySlices = function tryAllSlices(value) {
var anyTrue = false;
forEach(cache, function (getter) {
if (!anyTrue) {
try {
getter(value);
anyTrue = true;
} catch (e) { /**/ }
}
});
return anyTrue;
};
module.exports = function isTypedArray(value) {
if (!value || typeof value !== 'object') { return false; }
if (!hasToStringTag) {
var tag = $slice($toString(value), 8, -1);
if ($indexOf(typedArrays, tag) > -1) {
return true;
}
if (tag !== 'Object') {
return false;
}
// node < 0.6 hits here on real Typed Arrays
return trySlices(value);
}
if (!gOPD) { return null; } // unknown engine
return tryTypedArrays(value);
return !!whichTypedArray(value);
};
{
"name": "is-typed-array",
"version": "1.1.11",
"version": "1.1.12",
"author": {

@@ -61,7 +61,3 @@ "name": "Jordan Harband",

"dependencies": {
"available-typed-arrays": "^1.0.5",
"call-bind": "^1.0.2",
"for-each": "^0.3.3",
"gopd": "^1.0.1",
"has-tostringtag": "^1.0.0"
"which-typed-array": "^1.1.11"
},

@@ -74,2 +70,4 @@ "devDependencies": {

"evalmd": "^0.0.19",
"for-each": "^0.3.3",
"has-tostringtag": "^1.0.0",
"in-publish": "^2.0.1",

@@ -76,0 +74,0 @@ "is-callable": "^1.2.7",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc