CoolFace
Apppublic

Umama-at-Bluchip/Quick-UI

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
1# ArrayBuffer.prototype.slice <sup>[![Version Badge][npm-version-svg]][package-url]</sup>2 3[![github actions][actions-image]][actions-url]4[![coverage][codecov-image]][codecov-url]5[![License][license-image]][license-url]6[![Downloads][downloads-image]][downloads-url]7 8[![npm badge][npm-badge-png]][package-url]9 10An ES spec-compliant `ArrayBuffer.prototype.slice` shim. Invoke its "shim" method to shim ArrayBuffer.prototype.slice if it is unavailable.11 12This 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).13 14Most common usage:15```js16var assert = require('assert');17var slice = require('arraybuffer.prototype.slice');18 19var ab = new ArrayBuffer(1);20var arr = new Uint8Array(ab);21arr[0] = 123;22 23var ab2 = slice(ab);24 25var arr2 = new Uint8Array(ab2);26arr2[0] = 234;27 28assert.deepEqual(arr, new Uint8Array([123]));29assert.deepEqual(arr2, new Uint8Array([234]));30 31if (!ArrayBuffer.prototype.transfer) {32	slice.shim();33}34 35var ab2 = ab.slice();36 37var arr2 = new Uint8Array(ab2);38arr2[0] = 234;39 40assert.deepEqual(arr, new Uint8Array([123]));41assert.deepEqual(arr2, new Uint8Array([234]));42```43 44## Tests45Simply clone the repo, `npm install`, and run `npm test`46 47[package-url]: https://npmjs.org/package/arraybuffer.prototype.slice48[npm-version-svg]: https://versionbadg.es/es-shims/ArrayBuffer.prototype.slice.svg49[deps-svg]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice.svg50[deps-url]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice51[dev-deps-svg]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice/dev-status.svg52[dev-deps-url]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice#info=devDependencies53[npm-badge-png]: https://nodei.co/npm/arraybuffer.prototype.slice.png?downloads=true&stars=true54[license-image]: https://img.shields.io/npm/l/arraybuffer.prototype.slice.svg55[license-url]: LICENSE56[downloads-image]: https://img.shields.io/npm/dm/arraybuffer.prototype.slice.svg57[downloads-url]: https://npm-stat.com/charts.html?package=arraybuffer.prototype.slice58[codecov-image]: https://codecov.io/gh/es-shims/ArrayBuffer.prototype.slice/branch/main/graphs/badge.svg59[codecov-url]: https://app.codecov.io/gh/es-shims/ArrayBuffer.prototype.slice/60[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/ArrayBuffer.prototype.slice61[actions-url]: https://github.com/es-shims/ArrayBuffer.prototype.slice/actions62