63391cb4bb44ec67bc2c576124c68214a2f6fe61296d81ed677c4ccbe3bb8a9472d8079e59f41a5789a4bf225c1e386014b4335ec89aa7d323b0ecba441672 658 B

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