const Glib = require('../glib'); Object.defineProperty(Array.prototype, 'glib', { enumerable: false, configurable: false, get() { return Glib.fromIterable(this); }, }); Object.defineProperty(Array.prototype, 'set', { enumerable: false, configurable: false, get() { return new Set(this); }, }); Array.prototype.safeSplice = function safeSplice(...args) { const spliced = this.slice(); spliced.splice(...args); return spliced; }; Array.prototype.chainSplice = function chainSplice(...args) { this.splice(...args); return this; }; Array.prototype.chainPush = function chainPush(...args) { this.push(...args); return this; }; Array.prototype.safePush = function safePush(...args) { const clone = this.slice(); clone.push(...args); return clone; }; Array.prototype.safeReverse = function safeReverse(...args) { const clone = this.slice(); clone.reverse(...args); return clone; }; Array.prototype.safeSort = function safeSort(...args) { const clone = this.slice(); clone.sort(...args); return clone; };