Detalhes do pacote

typedarray.prototype.slice

es-shims9.4mMIT1.0.5

ES spec-compliant shim for TypedArray.prototype.slice

javascript, ecmascript, TypedArray.prototype.slice, polyfill

readme (leia-me)

TypedArray.prototype.slice Version Badge

github actions coverage License Downloads

npm badge

An ES spec-compliant TypedArray.prototype.slice shim. Invoke its "shim" method to shim TypedArray.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('typedarray.prototype.slice');

var arr = new Uint8Array([1, 2, 3]);

var arr2 = slice(arr);

arr2[0] = 2;
arr2[1] = 3;

assert.deepEqual(arr, new Uint8Array([1, 2, 3]));
assert.deepEqual(arr2, new Uint8Array([2, 3, 3]));
assert.notEqual(arr.buffer, arr2.buffer);

if (!Uint8Array.prototype.slice) {
    slice.shim();
}

var arr3 = arr.slice();
arr3[0] = 2;
arr3[1] = 3;

assert.deepEqual(arr, new Uint8Array([1, 2, 3]));
assert.deepEqual(arr3, new Uint8Array([2, 3, 3]));
assert.notEqual(arr.buffer, arr3.buffer);

Engines where this is needed

- node v0.11.4 - v4: no prototype or own `slice` method
- node < v0.11.3: own `slice` method that fails to clone the underlying buffer

Tests

Simply clone the repo, npm install, and run npm test

changelog (log de mudanças)

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.5 - 2025-01-02

Commits

  • [Fix] (-‸ლ) typo in specifier from dd67051195bdc0a9a5a2252c0fd3bd9155f6b08b cffa05e

v1.0.4 - 2025-01-02

Commits

  • [actions] split out node 10-20, and 20+ 1ca7eb2
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, auto-changelog, es-value-fixtures, object-inspect, tape 259de62
  • [Deps] update call-bind, es-abstract, typed-array-buffer, typed-array-byte-offset 5c9dbf9
  • [Refactor] use math-intrinsics directly dd67051
  • [Refactor] use get-proto and math-intrinsics directly 20395cc
  • [Tests] replace aud with npm audit 53d2fef
  • [Dev Deps] add missing peer dep 70a2f57

v1.0.3 - 2024-03-15

Commits

  • [Deps] update es-abstract 9067824
  • [Deps] update call-bind, typed-array-buffer, typed-array-byte-offset 33da086
  • [Dev Deps] update available-typed-arrays, tape 2f8d038

v1.0.2 - 2024-02-06

Commits

  • [Dev Deps] update aud, anvailable-typed-arrays, npmignore, object-inspect, tape 9334d4e
  • [Deps] update call-bind, define-properties, es-abstract, get-intrinsic 0acd649
  • [Refactor] use es-errors, so things that only need those do not need get-intrinsic 70215ad

v1.0.1 - 2023-07-18

Commits

  • [readme] fix title and URLs 391dc87

v1.0.0 - 2023-07-18

Commits

  • Initial implementation, tests, readme 7684f32
  • Initial commit e4ff962
  • [Fix] node v0.11.4 - 3 have an own slice method that works incorrectly 361b2c6
  • [Fix] node &lt; v0.6 lacks proper toString behavior on Typed Arrays bcf30f9
  • npm init a24ef46
  • [Fix] update es-abstract and move it to runtime deps b70eb79
  • Only apps should have lockfiles 3361cbe