typedarray.prototype.slice 1.0.5 → 1.0.6

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,18 @@ 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.6](https://github.com/es-shims/TypedArray.prototype.slice/compare/v1.0.5...v1.0.6) - 2026-10-04
9
+
10
+ ### Commits
11
+
12
+ - [Fix] `getPolyfill`: use the implementation where the native method throws for a non-Typed-Array `constructor` [`b848109`](https://github.com/es-shims/TypedArray.prototype.slice/commit/b84810985071b8737e32f3d61f5585b17f8ecb0c)
13
+ - [Deps] update `call-bind`, `es-abstract`, `typed-array-byte-offset` [`74761c7`](https://github.com/es-shims/TypedArray.prototype.slice/commit/74761c7ed1304a8f9826b295a3703791ee32759e)
14
+ - [Dev Deps] update `@ljharb/eslint-config`, `auto-changelog`, `eslint`, `evalmd`, `npmignore`, `tape` [`502413b`](https://github.com/es-shims/TypedArray.prototype.slice/commit/502413b0242b59ed482b7645ddfcb204f43306da)
15
+ - [Dev Deps] update `es-value-fixtures`, `for-each`, `has-strict-mode`, `object-inspect` [`bd0da39`](https://github.com/es-shims/TypedArray.prototype.slice/commit/bd0da39ed1d61409f3a8064fd92b9080cd3a8761)
16
+ - [actions] update workflows [`00c4591`](https://github.com/es-shims/TypedArray.prototype.slice/commit/00c4591e3fe7c8d1c74c281cc6f5bd3b5aad997d)
17
+ - [Dev Deps] update `auto-changelog`; remove `encoding` [`52fb2a2`](https://github.com/es-shims/TypedArray.prototype.slice/commit/52fb2a2f60d9da64dec341d77324c233ccfde1ff)
18
+ - [actions] set least-privilege `cache-mode` [`e9898b4`](https://github.com/es-shims/TypedArray.prototype.slice/commit/e9898b417a388cfbc29c0cee5f6d3831a630a4eb)
19
+
8
20
  ## [v1.0.5](https://github.com/es-shims/TypedArray.prototype.slice/compare/v1.0.4...v1.0.5) - 2025-01-02
9
21
 
10
22
  ### Commits
package/implementation.js CHANGED
@@ -2,19 +2,19 @@
2
2
 
3
3
  var $TypeError = require('es-errors/type');
4
4
 
5
- var Get = require('es-abstract/2024/Get');
6
- var GetValueFromBuffer = require('es-abstract/2024/GetValueFromBuffer');
7
- var IsDetachedBuffer = require('es-abstract/2024/IsDetachedBuffer');
5
+ var Get = require('es-abstract/2025/Get');
6
+ var GetValueFromBuffer = require('es-abstract/2025/GetValueFromBuffer');
7
+ var IsDetachedBuffer = require('es-abstract/2025/IsDetachedBuffer');
8
8
  var max = require('math-intrinsics/max');
9
9
  var min = require('math-intrinsics/min');
10
- var Set = require('es-abstract/2024/Set');
11
- var SetValueInBuffer = require('es-abstract/2024/SetValueInBuffer');
12
- var ToIntegerOrInfinity = require('es-abstract/2024/ToIntegerOrInfinity');
13
- var ToString = require('es-abstract/2024/ToString');
14
- var TypedArrayElementSize = require('es-abstract/2024/TypedArrayElementSize');
15
- var TypedArrayElementType = require('es-abstract/2024/TypedArrayElementType');
16
- var TypedArraySpeciesCreate = require('es-abstract/2024/TypedArraySpeciesCreate');
17
- var ValidateTypedArray = require('es-abstract/2024/ValidateTypedArray');
10
+ var Set = require('es-abstract/2025/Set');
11
+ var SetValueInBuffer = require('es-abstract/2025/SetValueInBuffer');
12
+ var ToIntegerOrInfinity = require('es-abstract/2025/ToIntegerOrInfinity');
13
+ var ToString = require('es-abstract/2025/ToString');
14
+ var TypedArrayElementSize = require('es-abstract/2025/TypedArrayElementSize');
15
+ var TypedArrayElementType = require('es-abstract/2025/TypedArrayElementType');
16
+ var TypedArraySpeciesCreate = require('es-abstract/2025/TypedArraySpeciesCreate');
17
+ var ValidateTypedArray = require('es-abstract/2025/ValidateTypedArray');
18
18
 
19
19
  var typedArrayBuffer = require('typed-array-buffer');
20
20
  var typedArrayByteOffset = require('typed-array-byte-offset');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typedarray.prototype.slice",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "ES spec-compliant shim for TypedArray.prototype.slice",
5
5
  "author": "Jordan Harband <ljharb@gmail.com>",
6
6
  "funding": {
@@ -53,34 +53,34 @@
53
53
  "es-shim API"
54
54
  ],
55
55
  "dependencies": {
56
- "call-bind": "^1.0.8",
56
+ "call-bind": "^1.0.9",
57
57
  "define-properties": "^1.2.1",
58
- "es-abstract": "^1.23.9",
58
+ "es-abstract": "^1.24.2",
59
59
  "es-errors": "^1.3.0",
60
60
  "get-proto": "^1.0.1",
61
61
  "math-intrinsics": "^1.1.0",
62
62
  "typed-array-buffer": "^1.0.3",
63
- "typed-array-byte-offset": "^1.0.4"
63
+ "typed-array-byte-offset": "^1.0.5"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@es-shims/api": "^2.5.1",
67
- "@ljharb/eslint-config": "^21.1.1",
68
- "auto-changelog": "^2.5.0",
67
+ "@ljharb/eslint-config": "^22.2.5",
68
+ "auto-changelog": "^2.7.0",
69
69
  "available-typed-arrays": "^1.0.7",
70
70
  "eclint": "^2.8.1",
71
- "encoding": "^0.1.13",
72
- "es-value-fixtures": "^1.5.0",
73
- "eslint": "=8.8.0",
74
- "evalmd": "^0.0.19",
75
- "for-each": "^0.3.3",
71
+ "es-value-fixtures": "^1.7.1",
72
+ "eslint": "^8.57.1",
73
+ "evalmd": "^0.0.22",
74
+ "for-each": "^0.3.5",
76
75
  "functions-have-names": "^1.2.3",
77
- "has-strict-mode": "^1.0.1",
76
+ "has-strict-mode": "^1.1.0",
78
77
  "in-publish": "^2.0.1",
79
- "npmignore": "^0.3.1",
78
+ "is-typed-array": "^1.1.15",
79
+ "npmignore": "^0.3.5",
80
80
  "nyc": "^10.3.2",
81
- "object-inspect": "^1.13.3",
81
+ "object-inspect": "^1.13.4",
82
82
  "safe-publish-latest": "^2.0.0",
83
- "tape": "^5.9.0"
83
+ "tape": "^5.10.2"
84
84
  },
85
85
  "testling": {
86
86
  "files": "test/index.js"
package/polyfill.js CHANGED
@@ -3,5 +3,18 @@
3
3
  var implementation = require('./implementation');
4
4
 
5
5
  module.exports = function getPolyfill() {
6
- return (typeof Uint8Array === 'function' && Uint8Array.prototype.slice) || implementation;
6
+ if (typeof Uint8Array === 'function' && Uint8Array.prototype.slice) {
7
+ // V8 4.5 and 4.6 (node 4 and 5) throw when `this.constructor` is not a Typed Array constructor, which includes every Buffer
8
+ var ta = new Uint8Array(1);
9
+ ta.constructor = function (length) {
10
+ return new Uint8Array(length);
11
+ };
12
+ try {
13
+ ta.slice();
14
+ } catch (e) {
15
+ return implementation;
16
+ }
17
+ return Uint8Array.prototype.slice;
18
+ }
19
+ return implementation;
7
20
  };
package/test/tests.js CHANGED
@@ -4,6 +4,7 @@ var inspect = require('object-inspect');
4
4
  // var IsDetachedBuffer = require('es-abstract/2023/IsDetachedBuffer');
5
5
 
6
6
  var forEach = require('for-each');
7
+ var isTypedArray = require('is-typed-array');
7
8
  var availableTypedArrays = require('available-typed-arrays')();
8
9
  var v = require('es-value-fixtures');
9
10
 
@@ -40,10 +41,28 @@ module.exports = function runTests(slice, t) {
40
41
  );
41
42
  s2t.notEqual(copy.buffer, ta.buffer, 'the new instance has a different buffer than the original when sliced with a start index');
42
43
 
44
+ var withConstructor = new TA(isBigInt ? [BigInt(1), BigInt(2), BigInt(3)] : [1, 2, 3]);
45
+ withConstructor.constructor = function () {
46
+ throw new EvalError('a `constructor` without `Symbol.species` should not be called');
47
+ };
48
+ var fromDefault = slice(withConstructor);
49
+ s2t.ok(fromDefault instanceof TA, 'a `constructor` without `Symbol.species` uses the default constructor');
50
+ s2t.deepEqual(fromDefault, ta, 'a `constructor` without `Symbol.species` keeps the values');
51
+
43
52
  s2t.end();
44
53
  });
45
54
  });
46
55
 
47
56
  return st.end();
48
57
  });
58
+
59
+ var buffer = typeof Buffer === 'function' && (Buffer.from ? Buffer.from([1, 2, 3]) : new Buffer([1, 2, 3]));
60
+ t.test('Buffer', { skip: !isTypedArray(buffer) }, function (st) {
61
+
62
+ var copy = slice(buffer);
63
+ st.notEqual(copy, buffer, 'returns a new instance');
64
+ st.deepEqual(Array.prototype.slice.call(copy), [1, 2, 3], 'returns a new instance with the same values');
65
+
66
+ st.end();
67
+ });
49
68
  };