https://github.com/es-shims/arraybuffer.prototype.slice
ES spec-compliant shim for ArrayBuffer.prototype.slice
https://github.com/es-shims/arraybuffer.prototype.slice
array arraybuffer buffer ecmascript es-shim javascript polyfill shim slice typed
Last synced: about 2 months ago
JSON representation
ES spec-compliant shim for ArrayBuffer.prototype.slice
- Host: GitHub
- URL: https://github.com/es-shims/arraybuffer.prototype.slice
- Owner: es-shims
- License: mit
- Created: 2023-07-09T06:09:41.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-15T21:56:18.000Z (7 months ago)
- Last Synced: 2025-05-07T12:55:05.708Z (about 2 months ago)
- Topics: array, arraybuffer, buffer, ecmascript, es-shim, javascript, polyfill, shim, slice, typed
- Language: JavaScript
- Homepage:
- Size: 52.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ArrayBuffer.prototype.slice [![Version Badge][npm-version-svg]][package-url]
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url][![npm badge][npm-badge-png]][package-url]
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](https://github.com/es-shims/api) interface. It works in an ES5-supported environment and complies with the [spec](https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice).
Most common usage:
```js
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`[package-url]: https://npmjs.org/package/arraybuffer.prototype.slice
[npm-version-svg]: https://versionbadg.es/es-shims/ArrayBuffer.prototype.slice.svg
[deps-svg]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice.svg
[deps-url]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice
[dev-deps-svg]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/arraybuffer.prototype.slice.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/arraybuffer.prototype.slice.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/arraybuffer.prototype.slice.svg
[downloads-url]: https://npm-stat.com/charts.html?package=arraybuffer.prototype.slice
[codecov-image]: https://codecov.io/gh/es-shims/ArrayBuffer.prototype.slice/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/es-shims/ArrayBuffer.prototype.slice/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/ArrayBuffer.prototype.slice
[actions-url]: https://github.com/es-shims/ArrayBuffer.prototype.slice/actions