UNPKG

601 BJavaScriptView Raw
1'use strict';
2var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
3
4var aTypedArray = ArrayBufferViewCore.aTypedArray;
5var floor = Math.floor;
6
7// `%TypedArray%.prototype.reverse` method
8// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reverse
9ArrayBufferViewCore.exportProto('reverse', function reverse() {
10 var that = this;
11 var length = aTypedArray(that).length;
12 var middle = floor(length / 2);
13 var index = 0;
14 var value;
15 while (index < middle) {
16 value = that[index];
17 that[index++] = that[--length];
18 that[length] = value;
19 } return that;
20});