arraybuffer.prototype.slice (1.0.4)
Published 2026-02-24 13:53:02 +00:00 by atheaadmin
Installation
registry=npm install arraybuffer.prototype.slice@1.0.4"arraybuffer.prototype.slice": "1.0.4"About this package
ArrayBuffer.prototype.slice 
An ES spec-compliant ArrayBuffer.prototype.slice shim. Invoke its "shim" method to shim ArrayBuffer.prototype.slice if it is unavailable.
This package implements the es-shim API interface. It works in an ES5-supported environment and complies with the spec.
Most common usage:
var assert = require('assert');
var slice = require('arraybuffer.prototype.slice');
var ab = new ArrayBuffer(1);
var arr = new Uint8Array(ab);
arr[0] = 123;
var ab2 = slice(ab);
var arr2 = new Uint8Array(ab2);
arr2[0] = 234;
assert.deepEqual(arr, new Uint8Array([123]));
assert.deepEqual(arr2, new Uint8Array([234]));
if (!ArrayBuffer.prototype.transfer) {
slice.shim();
}
var ab2 = ab.slice();
var arr2 = new Uint8Array(ab2);
arr2[0] = 234;
assert.deepEqual(arr, new Uint8Array([123]));
assert.deepEqual(arr2, new Uint8Array([234]));
Tests
Simply clone the repo, npm install, and run npm test
Dependencies
Dependencies
| ID | Version |
|---|---|
| array-buffer-byte-length | ^1.0.1 |
| call-bind | ^1.0.8 |
| define-properties | ^1.2.1 |
| es-abstract | ^1.23.5 |
| es-errors | ^1.3.0 |
| get-intrinsic | ^1.2.6 |
| is-array-buffer | ^3.0.4 |
Development Dependencies
| ID | Version |
|---|---|
| @es-shims/api | ^2.5.1 |
| @ljharb/eslint-config | ^21.1.1 |
| auto-changelog | ^2.5.0 |
| eclint | ^2.8.1 |
| encoding | ^0.1.13 |
| es-value-fixtures | ^1.5.0 |
| eslint | =8.8.0 |
| evalmd | ^0.0.19 |
| for-each | ^0.3.3 |
| functions-have-names | ^1.2.3 |
| has-strict-mode | ^1.0.1 |
| in-publish | ^2.0.1 |
| npmignore | ^0.3.1 |
| nyc | ^10.3.2 |
| object-inspect | ^1.13.3 |
| safe-publish-latest | ^2.0.0 |
| tape | ^5.9.0 |
Keywords
javascript
ecmascript
ArrayBuffer.prototype.slice
polyfill
shim
ArrayBuffer
array
buffer
ArrayBuffer#slice
slice
typed array
es-shim API
