(global)
| 5 | //=======// |
| 6 | { |
| 7 | const install = (global) => { |
| 8 | Reflect.defineProperty(global.Array.prototype, "last", { |
| 9 | get() { |
| 10 | return this[this.length - 1]; |
| 11 | }, |
| 12 | set(value) { |
| 13 | Reflect.defineProperty(this, "last", { |
| 14 | value, |
| 15 | configurable: true, |
| 16 | writable: true, |
| 17 | enumerable: true, |
| 18 | }); |
| 19 | }, |
| 20 | configurable: true, |
| 21 | enumerable: false, |
| 22 | }); |
| 23 | |
| 24 | Reflect.defineProperty(global.Array.prototype, "clone", { |
| 25 | get() { |
| 26 | return [...this]; |
| 27 | }, |
| 28 | set(value) { |
| 29 | Reflect.defineProperty(this, "clone", { |
| 30 | value, |
| 31 | configurable: true, |
| 32 | writable: true, |
| 33 | enumerable: true, |
| 34 | }); |
| 35 | }, |
| 36 | configurable: true, |
| 37 | enumerable: false, |
| 38 | }); |
| 39 | |
| 40 | Reflect.defineProperty(global.Array.prototype, "at", { |
| 41 | value(position) { |
| 42 | if (position >= 0) return this[position]; |
| 43 | return this[this.length + position]; |
| 44 | }, |
| 45 | configurable: true, |
| 46 | enumerable: false, |
| 47 | writable: true, |
| 48 | }); |
| 49 | |
| 50 | Reflect.defineProperty(global.Array.prototype, "shuffle", { |
| 51 | value() { |
| 52 | for (let i = this.length - 1; i > 0; i--) { |
| 53 | const r = Math.floor(Math.random() * (i + 1)); |
| 54 | [this[i], this[r]] = [this[r], this[i]]; |
| 55 | } |
| 56 | return this; |
| 57 | }, |
| 58 | configurable: true, |
| 59 | enumerable: false, |
| 60 | writable: true, |
| 61 | }); |
| 62 | |
| 63 | Reflect.defineProperty(global.Array.prototype, "trim", { |
| 64 | value() { |
nothing calls this directly
no outgoing calls
no test coverage detected