blob: 707a89a6e1b2d3e953f1b1d30e70bbd9258c70bd [file] [log] [blame]
Eugene Kliuchnikova6292892017-08-28 11:31:29 +02001if (!Int32Array.__proto__.from) {
2 Object.defineProperty(Int32Array.__proto__, 'from', {
3 value: function(obj) {
4 obj = Object(obj);
5 if (!obj['length']) {
6 return new this(0);
7 }
8 var typed_array = new this(obj.length);
9 for(var i = 0; i < typed_array.length; i++) {
10 typed_array[i] = obj[i];
11 }
12 return typed_array;
13 }
14 });
15}
16
17if (!Array.prototype.copyWithin) {
18 Array.prototype.copyWithin = function(target, start, end) {
19 var O = Object(this);
20 var len = O.length >>> 0;
21 var to = target | 0;
22 var from = start | 0;
23 var count = Math.min(Math.min(end | 0, len) - from, len - to);
24 var direction = 1;
25 if (from < to && to < (from + count)) {
26 direction = -1;
27 from += count - 1;
28 to += count - 1;
29 }
30 while (count > 0) {
31 O[to] = O[from];
32 from += direction;
33 to += direction;
34 count--;
35 }
36 return O;
37 };
38}
39
40if (!Array.prototype.fill) {
41 Object.defineProperty(Array.prototype, 'fill', {
42 value: function(value, start, end) {
43 end = end | 0;
44 var O = Object(this);
45 var k = start | 0;
46 while (k < end) {
47 O[k] = value;
48 k++;
49 }
50 return O;
51 }
52 });
53}
54
55if (!Int8Array.prototype.copyWithin) {
56 Int8Array.prototype.copyWithin = Array.prototype.copyWithin;
57}
58
59if (!Int8Array.prototype.fill) {
60 Int8Array.prototype.fill = Array.prototype.fill;
61}
62
63if (!Int32Array.prototype.fill) {
64 Int32Array.prototype.fill = Array.prototype.fill;
65}