array-to-reversed.js 405 B

1234567891011
  1. var lengthOfArrayLike = require('../internals/length-of-array-like');
  2. // https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.toReversed
  3. // https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toReversed
  4. module.exports = function (O, C) {
  5. var len = lengthOfArrayLike(O);
  6. var A = new C(len);
  7. var k = 0;
  8. for (; k < len; k++) A[k] = O[len - k - 1];
  9. return A;
  10. };