Eugene Kliuchnikov | a629289 | 2017-08-28 11:31:29 +0200 | [diff] [blame] | 1 | if (!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 | |
| 17 | if (!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 | |
| 40 | if (!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 | |
| 55 | if (!Int8Array.prototype.copyWithin) { |
| 56 | Int8Array.prototype.copyWithin = Array.prototype.copyWithin; |
| 57 | } |
| 58 | |
| 59 | if (!Int8Array.prototype.fill) { |
| 60 | Int8Array.prototype.fill = Array.prototype.fill; |
| 61 | } |
| 62 | |
| 63 | if (!Int32Array.prototype.fill) { |
| 64 | Int32Array.prototype.fill = Array.prototype.fill; |
| 65 | } |