source: trip-planner-front/node_modules/core-js/modules/es.array-buffer.slice.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var fails = require('../internals/fails');
4var ArrayBufferModule = require('../internals/array-buffer');
5var anObject = require('../internals/an-object');
6var toAbsoluteIndex = require('../internals/to-absolute-index');
7var toLength = require('../internals/to-length');
8var speciesConstructor = require('../internals/species-constructor');
9
10var ArrayBuffer = ArrayBufferModule.ArrayBuffer;
11var DataView = ArrayBufferModule.DataView;
12var nativeArrayBufferSlice = ArrayBuffer.prototype.slice;
13
14var INCORRECT_SLICE = fails(function () {
15 return !new ArrayBuffer(2).slice(1, undefined).byteLength;
16});
17
18// `ArrayBuffer.prototype.slice` method
19// https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice
20$({ target: 'ArrayBuffer', proto: true, unsafe: true, forced: INCORRECT_SLICE }, {
21 slice: function slice(start, end) {
22 if (nativeArrayBufferSlice !== undefined && end === undefined) {
23 return nativeArrayBufferSlice.call(anObject(this), start); // FF fix
24 }
25 var length = anObject(this).byteLength;
26 var first = toAbsoluteIndex(start, length);
27 var fin = toAbsoluteIndex(end === undefined ? length : end, length);
28 var result = new (speciesConstructor(this, ArrayBuffer))(toLength(fin - first));
29 var viewSource = new DataView(this);
30 var viewTarget = new DataView(result);
31 var index = 0;
32 while (first < fin) {
33 viewTarget.setUint8(index++, viewSource.getUint8(first++));
34 } return result;
35 }
36});
Note: See TracBrowser for help on using the repository browser.