debian-mirror-gitlab/core-js/modules/es.typed-array.reverse.js
2019-09-25 13:30:05 +05:30

20 lines
601 B
JavaScript

'use strict';
var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
var aTypedArray = ArrayBufferViewCore.aTypedArray;
var floor = Math.floor;
// `%TypedArray%.prototype.reverse` method
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reverse
ArrayBufferViewCore.exportProto('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;
});