Last change
on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
658 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict';
|
---|
| 2 | var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
|
---|
| 3 |
|
---|
| 4 | var aTypedArray = ArrayBufferViewCore.aTypedArray;
|
---|
| 5 | var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
|
---|
| 6 | var floor = Math.floor;
|
---|
| 7 |
|
---|
| 8 | // `%TypedArray%.prototype.reverse` method
|
---|
| 9 | // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reverse
|
---|
| 10 | exportTypedArrayMethod('reverse', function reverse() {
|
---|
| 11 | var that = this;
|
---|
| 12 | var length = aTypedArray(that).length;
|
---|
| 13 | var middle = floor(length / 2);
|
---|
| 14 | var index = 0;
|
---|
| 15 | var value;
|
---|
| 16 | while (index < middle) {
|
---|
| 17 | value = that[index];
|
---|
| 18 | that[index++] = that[--length];
|
---|
| 19 | that[length] = value;
|
---|
| 20 | } return that;
|
---|
| 21 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.