UNPKG

core-js

Version:
24 lines (21 loc) 919 B
'use strict'; var speciesConstructor = require('../internals/species-constructor'); var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var aTypedArray = ArrayBufferViewCore.aTypedArray; var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor; var arraySlice = [].slice; var FORCED = require('../internals/fails')(function () { // eslint-disable-next-line no-undef new Int8Array(1).slice(); }); // `%TypedArray%.prototype.slice` method // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.slice ArrayBufferViewCore.exportProto('slice', function slice(start, end) { var list = arraySlice.call(aTypedArray(this), start, end); var C = speciesConstructor(this, this.constructor); var index = 0; var length = list.length; var result = new (aTypedArrayConstructor(C))(length); while (length > index) result[index] = list[index++]; return result; }, FORCED);