5e4ba40043a2c6b385cbef0a58da6262113b0e64337f16e5fdee00d17b694077ab7adc20626b5e29ce6fc275ab02fa200adbaa8106aa414bd367f85bc95f2d 967 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  3. var typedArraySpeciesConstructor = require('../internals/typed-array-species-constructor');
  4. var fails = require('../internals/fails');
  5. var arraySlice = require('../internals/array-slice');
  6. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  7. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  8. var FORCED = fails(function () {
  9. // eslint-disable-next-line es/no-typed-arrays -- required for testing
  10. new Int8Array(1).slice();
  11. });
  12. // `%TypedArray%.prototype.slice` method
  13. // https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice
  14. exportTypedArrayMethod('slice', function slice(start, end) {
  15. var list = arraySlice(aTypedArray(this), start, end);
  16. var C = typedArraySpeciesConstructor(this);
  17. var index = 0;
  18. var length = list.length;
  19. var result = new C(length);
  20. while (length > index) result[index] = list[index++];
  21. return result;
  22. }, FORCED);