1 | 'use strict';
|
2 | var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
|
3 | var speciesConstructor = require('../internals/species-constructor');
|
4 | var fails = require('../internals/fails');
|
5 |
|
6 | var aTypedArray = ArrayBufferViewCore.aTypedArray;
|
7 | var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
|
8 | var $slice = [].slice;
|
9 |
|
10 | var FORCED = fails(function () {
|
11 |
|
12 | new Int8Array(1).slice();
|
13 | });
|
14 |
|
15 |
|
16 |
|
17 | ArrayBufferViewCore.exportProto('slice', function slice(start, end) {
|
18 | var list = $slice.call(aTypedArray(this), start, end);
|
19 | var C = speciesConstructor(this, this.constructor);
|
20 | var index = 0;
|
21 | var length = list.length;
|
22 | var result = new (aTypedArrayConstructor(C))(length);
|
23 | while (length > index) result[index] = list[index++];
|
24 | return result;
|
25 | }, FORCED);
|