UNPKG

@ricardomatias/ring

Version:

Your average array made cyclical by using Proxy

2 lines (1 loc) 997 B
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).ring=e()}(this,(function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}var e={getPrototypeOf:function(){return Array.prototype},get:function(e,o,n){var r=e.length;if(o in Array.prototype)return"function"!=typeof Array.prototype[o]?Reflect.get(e,o,n):function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Array.prototype[o].apply(e,n)};if("symbol"===t(o))return Reflect.get(e,o,n);var f=parseInt(o,10);return f<0?f=r+f:f>r-1&&(f%=r),Reflect.get(e,f,n)},set:function(t,e,o,n){return Reflect.set(t,e,o,n)}};return function(t){if(t.length)return new Proxy([].concat(t),e)}}));