You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
658 B
21 lines
658 B
'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; |
|
});
|
|
|