typed-array-byte-offset 1.0.2 → 1.0.4

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,34 @@ 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.4](https://github.com/inspect-js/typed-array-byte-offset/compare/v1.0.3...v1.0.4) - 2024-12-18
9
+
10
+ ### Commits
11
+
12
+ - [Tests] split out and enhance "no-proto" tests [`64d1a73`](https://github.com/inspect-js/typed-array-byte-offset/commit/64d1a73a0a7f20484ee817c4a6758121887e30d3)
13
+ - [types] improve types [`21f484f`](https://github.com/inspect-js/typed-array-byte-offset/commit/21f484f55f9c6e3406b5eacbc937aa2e195da731)
14
+ - [Tests] add `--disable-proto=delete` tests [`8f77f2a`](https://github.com/inspect-js/typed-array-byte-offset/commit/8f77f2af48e1522aae10e0429810907df9f9f6fc)
15
+ - [actions] re-add a finisher; add perms [`59c1b7b`](https://github.com/inspect-js/typed-array-byte-offset/commit/59c1b7bfab826bceb43441c60affb1c1ad4e6cc7)
16
+ - [Deps] update `call-bind`, `gopd`, `has-proto`, `reflect.getprototypeof` [`c0c30d5`](https://github.com/inspect-js/typed-array-byte-offset/commit/c0c30d57642858c8327b3d90b6104ccbb459d71a)
17
+ - [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/tsconfig`, `@types/tape` [`2638bd5`](https://github.com/inspect-js/typed-array-byte-offset/commit/2638bd5d7000e6d902414aeac88c00a148f5b152)
18
+ - [Deps] update `is-typed-array`, `reflect.getprototypeof` [`11540a5`](https://github.com/inspect-js/typed-array-byte-offset/commit/11540a577044442ce42d684d00d4686d7613bed4)
19
+ - [Deps] update `is-typed-array` [`ad9cb70`](https://github.com/inspect-js/typed-array-byte-offset/commit/ad9cb70bcc09eaf535c24ce24a00716058833d64)
20
+ - [Dev Deps] update `@types/tape` [`2838854`](https://github.com/inspect-js/typed-array-byte-offset/commit/2838854db6053003b0818a337f1e2f95ab383bce)
21
+
22
+ ## [v1.0.3](https://github.com/inspect-js/typed-array-byte-offset/compare/v1.0.2...v1.0.3) - 2024-11-21
23
+
24
+ ### Fixed
25
+
26
+ - [Fix] avoid relying on `__proto__` accessor [`#4`](https://github.com/inspect-js/typed-array-byte-offset/issues/4)
27
+
28
+ ### Commits
29
+
30
+ - [types] use shared config [`10b0823`](https://github.com/inspect-js/typed-array-byte-offset/commit/10b0823ecc13b95920cfa8f27fe61af5678fb67b)
31
+ - [actions] split out node 10-20, and 20+ [`11554a9`](https://github.com/inspect-js/typed-array-byte-offset/commit/11554a96ca11b85c7ad87118e1d811bfde2b9f32)
32
+ - [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/eslint-config`, `@types/object-inspect`, `auto-changelog`, `object-inspect`, `tape` [`c39dd06`](https://github.com/inspect-js/typed-array-byte-offset/commit/c39dd06d2868a724463722ff2f416b5c41171140)
33
+ - [Tests] run tsc and `@arethetypeswrong/cli` in CI [`0b984aa`](https://github.com/inspect-js/typed-array-byte-offset/commit/0b984aa64c86f4bcb476b716cdd16d67c39b68ca)
34
+ - [Tests] replace `aud` with `npm audit` [`512b59d`](https://github.com/inspect-js/typed-array-byte-offset/commit/512b59df0e567592282795bfec331193d828f2fc)
35
+
8
36
  ## [v1.0.2](https://github.com/inspect-js/typed-array-byte-offset/compare/v1.0.1...v1.0.2) - 2024-02-20
9
37
 
10
38
  ### Commits
package/index.d.ts CHANGED
@@ -1,17 +1,14 @@
1
- type TypedArray =
2
- | Int8Array
3
- | Uint8Array
4
- | Uint8ClampedArray
5
- | Int16Array
6
- | Uint16Array
7
- | Int32Array
8
- | Uint32Array
9
- | Float32Array
10
- | Float64Array
11
- | BigInt64Array
12
- | BigUint64Array;
1
+ import TypedArrayNames from 'possible-typed-array-names';
13
2
 
14
- declare function typedArrayByteOffset(value: TypedArray): number;
3
+ declare namespace typedArrayByteOffset {
4
+ export type TypedArrayName = typeof TypedArrayNames[number];
5
+
6
+ export type TypedArrayConstructor = typeof globalThis[TypedArrayName];
7
+
8
+ export type TypedArray = TypedArrayConstructor['prototype'];
9
+ }
10
+
11
+ declare function typedArrayByteOffset(value: typedArrayByteOffset.TypedArray): number;
15
12
  declare function typedArrayByteOffset(value: unknown): false;
16
13
 
17
14
  export = typedArrayByteOffset;
package/index.js CHANGED
@@ -2,15 +2,17 @@
2
2
 
3
3
  var forEach = require('for-each');
4
4
  var callBind = require('call-bind');
5
+ var gPO = require('reflect.getprototypeof/polyfill')();
5
6
 
6
7
  var typedArrays = require('available-typed-arrays')();
7
8
 
8
- /** @typedef {Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array} TypedArray */
9
- /** @typedef {(x: TypedArray) => number} ByteOffsetGetter */
9
+ /** @typedef {(x: import('.').TypedArray) => number} ByteOffsetGetter */
10
10
 
11
- /** @type {Object.<typeof typedArrays, ByteOffsetGetter>} */
12
- var getters = {};
13
- var hasProto = require('has-proto')();
11
+ /** @type {Record<import('.').TypedArrayName, ByteOffsetGetter>} */
12
+ var getters = {
13
+ // @ts-expect-error TS can't handle __proto__ or `satisfies` in jsdoc
14
+ __proto__: null
15
+ };
14
16
 
15
17
  var gOPD = require('gopd');
16
18
  var oDP = Object.defineProperty;
@@ -25,9 +27,8 @@ if (gOPD) {
25
27
  var Proto = global[typedArray].prototype;
26
28
  // @ts-expect-error TS can't guarantee the callback is invoked sync
27
29
  var descriptor = gOPD(Proto, 'byteOffset');
28
- if (!descriptor && hasProto) {
29
- // @ts-expect-error hush, TS, every object has a dunder proto
30
- var superProto = Proto.__proto__; // eslint-disable-line no-proto
30
+ if (!descriptor) {
31
+ var superProto = gPO(Proto);
31
32
  // @ts-expect-error TS can't guarantee the callback is invoked sync
32
33
  descriptor = gOPD(superProto, 'byteOffset');
33
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typed-array-byte-offset",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Robustly get the byte offset of a Typed Array",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -16,9 +16,10 @@
16
16
  "pretest": "npm run lint",
17
17
  "prelint": "evalmd README.md",
18
18
  "lint": "eslint --ext=js,mjs .",
19
+ "postlint": "tsc -p . && attw -P",
19
20
  "tests-only": "nyc tape 'test/**/*.js'",
20
21
  "test": "npm run tests-only",
21
- "posttest": "aud --production",
22
+ "posttest": "npx npm@'>=10.2' audit --production",
22
23
  "version": "auto-changelog && git add CHANGELOG.md",
23
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
25
  },
@@ -57,24 +58,27 @@
57
58
  "homepage": "https://github.com/inspect-js/typed-array-byte-offset#readme",
58
59
  "dependencies": {
59
60
  "available-typed-arrays": "^1.0.7",
60
- "call-bind": "^1.0.7",
61
+ "call-bind": "^1.0.8",
61
62
  "for-each": "^0.3.3",
62
- "gopd": "^1.0.1",
63
- "has-proto": "^1.0.3",
64
- "is-typed-array": "^1.1.13"
63
+ "gopd": "^1.2.0",
64
+ "has-proto": "^1.2.0",
65
+ "is-typed-array": "^1.1.15",
66
+ "reflect.getprototypeof": "^1.0.9"
65
67
  },
66
68
  "devDependencies": {
67
- "@ljharb/eslint-config": "^21.1.0",
69
+ "@arethetypeswrong/cli": "^0.17.1",
70
+ "@ljharb/eslint-config": "^21.1.1",
71
+ "@ljharb/tsconfig": "^0.2.2",
68
72
  "@types/call-bind": "^1.0.5",
73
+ "@types/es-abstract": "^1.17.9",
69
74
  "@types/for-each": "^0.3.3",
70
75
  "@types/gopd": "^1.0.3",
71
76
  "@types/is-callable": "^1.1.2",
72
77
  "@types/make-arrow-function": "^1.2.2",
73
78
  "@types/make-generator-function": "^2.0.3",
74
- "@types/object-inspect": "^1.8.4",
75
- "@types/tape": "^5.6.4",
76
- "aud": "^2.0.4",
77
- "auto-changelog": "^2.4.0",
79
+ "@types/object-inspect": "^1.13.0",
80
+ "@types/tape": "^5.8.0",
81
+ "auto-changelog": "^2.5.0",
78
82
  "eslint": "=8.8.0",
79
83
  "evalmd": "^0.0.19",
80
84
  "in-publish": "^2.0.1",
@@ -83,11 +87,11 @@
83
87
  "make-generator-function": "^2.0.0",
84
88
  "npmignore": "^0.3.1",
85
89
  "nyc": "^10.3.2",
86
- "object-inspect": "^1.13.1",
90
+ "object-inspect": "^1.13.3",
87
91
  "possible-typed-array-names": "^1.0.0",
88
92
  "safe-publish-latest": "^2.0.0",
89
- "tape": "^5.7.5",
90
- "typescript": "^5.4.0-dev.20240219"
93
+ "tape": "^5.9.0",
94
+ "typescript": "next"
91
95
  },
92
96
  "engines": {
93
97
  "node": ">= 0.4"
@@ -105,7 +109,8 @@
105
109
  },
106
110
  "publishConfig": {
107
111
  "ignore": [
108
- ".github/workflows"
112
+ ".github/workflows",
113
+ "types"
109
114
  ]
110
115
  }
111
116
  }
package/test/index.js CHANGED
@@ -67,6 +67,7 @@ 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
70
71
  var arr = new TypedArray(buffer, byteOffset);
71
72
  t.equal(typedArrayByteOffset(arr), byteOffset, 'new ' + typedArray + '(new ArrayBuffer(' + length + '), ' + byteOffset + ') is typed array of byte offset ' + byteOffset);
72
73
  } else {
package/tsconfig.json CHANGED
@@ -1,49 +1,10 @@
1
1
  {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig to read more about this file */
4
-
5
- /* Projects */
6
-
7
- /* Language and Environment */
8
- "target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
9
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
10
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
11
- "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
12
- // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
13
-
14
- /* Modules */
15
- "module": "commonjs", /* Specify what module code is generated. */
16
- // "rootDir": "./", /* Specify the root folder within your source files. */
17
- // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
18
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
19
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
20
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
21
- "typeRoots": ["types"], /* Specify multiple folders that act like './node_modules/@types'. */
22
- "resolveJsonModule": true, /* Enable importing .json files. */
23
- // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
24
-
25
- /* JavaScript Support */
26
- "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
27
- "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
28
- "maxNodeModuleJsDepth": 0, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
29
-
30
- /* Emit */
31
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
32
- "declarationMap": true, /* Create sourcemaps for d.ts files. */
33
- "noEmit": true, /* Disable emitting files from a compilation. */
34
-
35
- /* Interop Constraints */
36
- "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
37
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
38
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
39
-
40
- /* Type Checking */
41
- "strict": true, /* Enable all strict type-checking options. */
42
-
43
- /* Completeness */
44
- //"skipLibCheck": true /* Skip type checking all .d.ts files. */
45
- },
46
- "exclude": [
47
- "coverage"
48
- ]
2
+ "extends": "@ljharb/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "ES2021",
5
+ "maxNodeModuleJsDepth": 0,
6
+ },
7
+ "exclude": [
8
+ "coverage",
9
+ ],
49
10
  }