Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typed-array-byte-length

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typed-array-byte-length - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

index.d.ts

11

CHANGELOG.md

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

## [v1.0.1](https://github.com/inspect-js/typed-array-byte-length/compare/v1.0.0...v1.0.1) - 2024-02-20
### Commits
- add types [`3144671`](https://github.com/inspect-js/typed-array-byte-length/commit/3144671ca4035136c558a107ce61af255ae3e858)
- [actions] skip ls check on node < 10; remove redundant finisher [`0f83947`](https://github.com/inspect-js/typed-array-byte-length/commit/0f83947bfe641fd87253330a6a83e8b7571e5c6a)
- [Refactor] use `gopd` [`507b948`](https://github.com/inspect-js/typed-array-byte-length/commit/507b948f9e754ad5b0888a15558448ec879c04c4)
- [Dev Deps] update `aud`, `available-typed-arrays`, `npmignore`, `object-inspect`, `tape` [`aba282d`](https://github.com/inspect-js/typed-array-byte-length/commit/aba282da3a3e16f648ceb4bc4f174cf4942a94e9)
- [Deps] update `call-bind`, `has-proto`, `is-typed-array` [`acfe4a9`](https://github.com/inspect-js/typed-array-byte-length/commit/acfe4a9081f35cea3b450b07a4736e1ab037a708)
- [meta] add `sideEffects` flag [`063a8a7`](https://github.com/inspect-js/typed-array-byte-length/commit/063a8a7ec8c134a012903531beccfc4418f701d0)
## v1.0.0 - 2023-07-14

@@ -10,0 +21,0 @@

26

index.js
'use strict';
var callBind = require('call-bind');
var forEach = require('for-each');
var callBind = require('call-bind');
var gOPD = require('gopd');
var hasProto = require('has-proto')();
var isTypedArray = require('is-typed-array');
var typedArrays = require('available-typed-arrays')();
/** @typedef {Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array} TypedArray */
/** @typedef {import('possible-typed-array-names')[number]} TypedArrayNames */
/** @typedef {(value: TypedArray) => number} Getter */
/** @type {Object.<TypedArrayNames, Getter>} */
var getters = {};
var hasProto = require('has-proto')();
var gOPD = Object.getOwnPropertyDescriptor;
var oDP = Object.defineProperty;
if (gOPD) {
/** @type {Getter} */
var getByteLength = function (x) {

@@ -21,5 +28,8 @@ return x.byteLength;

var Proto = global[typedArray].prototype;
// @ts-expect-error TS doesn't narrow properly inside callbacks
var descriptor = gOPD(Proto, 'byteLength');
if (!descriptor && hasProto) {
// @ts-expect-error hush, TS, every object has a dunder proto
var superProto = Proto.__proto__; // eslint-disable-line no-proto
// @ts-expect-error TS doesn't narrow properly inside callbacks
descriptor = gOPD(superProto, 'byteLength');

@@ -33,2 +43,3 @@ }

var arr = new global[typedArray](2);
// @ts-expect-error TS doesn't narrow properly inside callbacks
descriptor = gOPD(arr, 'byteLength');

@@ -46,5 +57,6 @@ if (descriptor && descriptor.configurable) {

/** @type {Getter} */
var tryTypedArrays = function tryAllTypedArrays(value) {
var foundByteLength;
forEach(getters, function (getter) {
/** @type {number} */ var foundByteLength;
forEach(getters, /** @type {(getter: Getter) => void} */ function (getter) {
if (typeof foundByteLength !== 'number') {

@@ -59,7 +71,7 @@ try {

});
// @ts-expect-error TS can't guarantee the callback is invoked sync
return foundByteLength;
};
var isTypedArray = require('is-typed-array');
/** @type {import('.')} */
module.exports = function typedArrayByteLength(value) {

@@ -66,0 +78,0 @@ if (!isTypedArray(value)) {

{
"name": "typed-array-byte-length",
"version": "1.0.0",
"version": "1.0.1",
"description": "Robustly get the byte length of a Typed Array",

@@ -10,2 +10,4 @@ "main": "index.js",

},
"types": "./index.d.ts",
"sideEffects": false,
"scripts": {

@@ -18,2 +20,3 @@ "prepack": "npmignore --auto --commentLines=autogenerated",

"lint": "eslint --ext=js,mjs .",
"postlint": "tsc -p .",
"tests-only": "nyc tape 'test/**/*.js'",

@@ -59,12 +62,21 @@ "test": "npm run tests-only",

"dependencies": {
"call-bind": "^1.0.2",
"call-bind": "^1.0.7",
"for-each": "^0.3.3",
"has-proto": "^1.0.1",
"is-typed-array": "^1.1.10"
"gopd": "^1.0.1",
"has-proto": "^1.0.3",
"is-typed-array": "^1.1.13"
},
"devDependencies": {
"@ljharb/eslint-config": "^21.1.0",
"aud": "^2.0.2",
"@types/call-bind": "^1.0.5",
"@types/for-each": "^0.3.3",
"@types/gopd": "^1.0.3",
"@types/is-callable": "^1.1.2",
"@types/make-arrow-function": "^1.2.2",
"@types/make-generator-function": "^2.0.3",
"@types/object-inspect": "^1.8.4",
"@types/tape": "^5.6.4",
"aud": "^2.0.4",
"auto-changelog": "^2.4.0",
"available-typed-arrays": "^1.0.5",
"available-typed-arrays": "^1.0.7",
"eslint": "=8.8.0",

@@ -76,7 +88,8 @@ "evalmd": "^0.0.19",

"make-generator-function": "^2.0.0",
"npmignore": "^0.3.0",
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"object-inspect": "^1.12.3",
"object-inspect": "^1.13.1",
"safe-publish-latest": "^2.0.0",
"tape": "^5.6.3"
"tape": "^5.7.5",
"typescript": "next"
},

@@ -83,0 +96,0 @@ "engines": {

@@ -14,2 +14,3 @@ 'use strict';

t.test('non-number/string primitives', function (st) {
// @ts-expect-error
st.equal(false, typedArrayByteLength(), 'undefined is not typed array');

@@ -16,0 +17,0 @@ st.equal(false, typedArrayByteLength(null), 'null is not typed array');

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