123456789101112131415161718192021 |
- 'use strict';
- var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
-
- var aTypedArray = ArrayBufferViewCore.aTypedArray;
- var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
- var floor = Math.floor;
-
- // `%TypedArray%.prototype.reverse` method
- // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reverse
- exportTypedArrayMethod('reverse', function reverse() {
- var that = this;
- var length = aTypedArray(that).length;
- var middle = floor(length / 2);
- var index = 0;
- var value;
- while (index < middle) {
- value = that[index];
- that[index++] = that[--length];
- that[length] = value;
- } return that;
- });
|