Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

arraybuffer.prototype.slice

es-shims88.2mMIT1.0.4

ES spec-compliant shim for ArrayBuffer.prototype.slice

javascript, ecmascript, ArrayBuffer.prototype.slice, polyfill, shim, ArrayBuffer, array, buffer, ArrayBuffer#slice, slice, typed array, es-shim API

readme

ArrayBuffer.prototype.slice Version Badge

github actions coverage License Downloads

npm badge

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

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v1.0.4 - 2024-12-15

Commits

  • [actions] split out node 10-20, and 20+ 5e59635
  • [Deps] update call-bind, es-abstract, get-intrinsic 0afbb59
  • [Dev Deps] update @es-shims/api, auto-changelog, es-value-fixtures, object-inspect, tape d76caf4
  • [Deps] update call-bind, es-abstract, es-errors, get-intrinsic 2b374a2
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, object-inspect, tape a24fd39
  • [Tests] replace aud with npm audit c704fb0
  • [Deps] remove unused dependency 0274b32
  • [Dev Deps] add missing peer dep 673f754

v1.0.3 - 2024-02-04

Commits

  • [Deps] update array-buffer-byte-length, call-bind, define-properties, es-abstract, get-intrinsic, is-array-buffer d9b6859
  • [Dev Deps] update aud, npmignore, object-inspect, tape 38cb58d
  • [Refactor] use es-errors where possible, so things that only need those do not need get-intrinsic 5c07bef

v1.0.2 - 2023-09-05

Commits

  • [Deps] update es-abstract a9ab0d2
  • [Dev Deps] update tape 6b24af5
  • [Fix] move es-abstract to runtime deps 63a8397

v1.0.1 - 2023-07-11

Commits

  • [Fix] node < 0.11 has an own nonconfigurable slice property; use it 554823c
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, es-abstract, tape 53b0421
  • [Deps] update define-properties, get-intrinsic 4966b02

v1.0.0 - 2023-07-09

Commits