Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
937 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
|
---|
3 | var typedArraySpeciesConstructor = require('../internals/typed-array-species-constructor');
|
---|
4 | var fails = require('../internals/fails');
|
---|
5 |
|
---|
6 | var aTypedArray = ArrayBufferViewCore.aTypedArray;
|
---|
7 | var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
|
---|
8 | var $slice = [].slice;
|
---|
9 |
|
---|
10 | var FORCED = fails(function () {
|
---|
11 | // eslint-disable-next-line es/no-typed-arrays -- required for testing
|
---|
12 | new Int8Array(1).slice();
|
---|
13 | });
|
---|
14 |
|
---|
15 | // `%TypedArray%.prototype.slice` method
|
---|
16 | // https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice
|
---|
17 | exportTypedArrayMethod('slice', function slice(start, end) {
|
---|
18 | var list = $slice.call(aTypedArray(this), start, end);
|
---|
19 | var C = typedArraySpeciesConstructor(this);
|
---|
20 | var index = 0;
|
---|
21 | var length = list.length;
|
---|
22 | var result = new C(length);
|
---|
23 | while (length > index) result[index] = list[index++];
|
---|
24 | return result;
|
---|
25 | }, FORCED);
|
---|
Note:
See
TracBrowser
for help on using the repository browser.