| 'use strict'; |
| var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); |
| var speciesConstructor = require('../internals/species-constructor'); |
| var fails = require('../internals/fails'); |
| |
| var aTypedArray = ArrayBufferViewCore.aTypedArray; |
| var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor; |
| var $slice = [].slice; |
| |
| var FORCED = 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 = $slice.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); |