@lopatnov/make-iterable
Version:
A TypeScript library that converts objects, functions, and their prototypes into Array-like iterable entities. Supports ES Modules, CommonJS, and UMD.
2 lines (1 loc) • 1.19 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).makeIterable=t()}(this,function(){"use strict";const e=new Set(Object.getOwnPropertyNames(Object.prototype)),t=Object.getOwnPropertyNames(Array.prototype).filter(t=>!e.has(t));return function(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e)throw new Error(`Incorrect argument: ${e}`);return function(e){if("function"==typeof e.push&&"function"==typeof e.pop&&"function"==typeof e.splice)return;const o=Array.prototype;t.forEach(t=>{if(o[t]instanceof Function)e[t]=function(...e){return o[t].apply(this,e)};else if("length"===t){let t=0;for(;void 0!==e[t];)t++;Object.defineProperty(e,"length",{value:t,writable:!0,enumerable:!1,configurable:!1})}else e[t]=o[t]})}(e),function(e){Symbol&&Symbol.iterator&&(Object.getOwnPropertyDescriptor(e,Symbol.iterator)||Object.defineProperty(e,Symbol.iterator,{writable:!1,enumerable:!1,configurable:!1,value:function(){let e=0;return{next:()=>this.length&&e<this.length?{value:this[e++],done:!1}:{value:void 0,done:!0}}}}))}(e),e}});