SetLike.js.map
2.42 KB
{"version":3,"sources":["../../sources/polyfills/SetLike.ts"],"names":["SetLike","items","value","has","push","previousLength","length","filter","item","callbackfn","forEach","indexOf","Set"],"mappings":";;;;;;;;;;;;;AAmBA;IACMA,O;AAGL,qBAA6B;AAAA,QAAjBC,KAAiB,uEAAJ,EAAI;;AAAA;;AAAA;;AAC5B,SAAKA,KAAL,GAAaA,KAAb;AACA;;;;WAED,aAAIC,KAAJ,EAAoB;AACnB,UAAI,KAAKC,GAAL,CAASD,KAAT,MAAoB,KAAxB,EAA+B;AAC9B,aAAKD,KAAL,CAAWG,IAAX,CAAgBF,KAAhB;AACA;;AACD,aAAO,IAAP;AACA;;;WACD,iBAAc;AACb,WAAKD,KAAL,GAAa,EAAb;AACA;;;WACD,iBAAOC,KAAP,EAA0B;AACzB,UAAMG,cAAc,GAAG,KAAKJ,KAAL,CAAWK,MAAlC;AACA,WAAKL,KAAL,GAAa,KAAKA,KAAL,CAAWM,MAAX,CAAkB,UAACC,IAAD;AAAA,eAAUA,IAAI,KAAKN,KAAnB;AAAA,OAAlB,CAAb;AAEA,aAAOG,cAAc,KAAK,KAAKJ,KAAL,CAAWK,MAArC;AACA;;;WACD,iBAAQG,UAAR,EAAsE;AAAA;;AACrE,WAAKR,KAAL,CAAWS,OAAX,CAAmB,UAACF,IAAD,EAAU;AAC5BC,QAAAA,UAAU,CAACD,IAAD,EAAOA,IAAP,EAAa,KAAb,CAAV;AACA,OAFD;AAGA;;;WACD,aAAIN,KAAJ,EAAuB;AACtB,aAAO,KAAKD,KAAL,CAAWU,OAAX,CAAmBT,KAAnB,MAA8B,CAAC,CAAtC;AACA;;;SAED,eAAmB;AAClB,aAAO,KAAKD,KAAL,CAAWK,MAAlB;AACA;;;;;;eAGa,OAAOM,GAAP,KAAe,WAAf,GAA6BA,GAA7B,GAAmCZ,O","sourcesContent":["declare global {\n\tclass Set<T> {\n\t\t// es2015.collection.d.ts\n\t\tconstructor(items?: T[]);\n\t\tadd(value: T): this;\n\t\tclear(): void;\n\t\tdelete(value: T): boolean;\n\t\tforEach(\n\t\t\tcallbackfn: (value: T, value2: T, set: Set<T>) => void,\n\t\t\tthisArg?: unknown\n\t\t): void;\n\t\thas(value: T): boolean;\n\t\treadonly size: number;\n\n\t\t// es2015.iterable.d.ts\n\t\t// no implemennted\n\t}\n}\n\n// for environments without Set we fallback to arrays with unique members\nclass SetLike<T> implements Set<T> {\n\tprivate items: T[];\n\n\tconstructor(items: T[] = []) {\n\t\tthis.items = items;\n\t}\n\n\tadd(value: T): this {\n\t\tif (this.has(value) === false) {\n\t\t\tthis.items.push(value);\n\t\t}\n\t\treturn this;\n\t}\n\tclear(): void {\n\t\tthis.items = [];\n\t}\n\tdelete(value: T): boolean {\n\t\tconst previousLength = this.items.length;\n\t\tthis.items = this.items.filter((item) => item !== value);\n\n\t\treturn previousLength !== this.items.length;\n\t}\n\tforEach(callbackfn: (value: T, value2: T, set: Set<T>) => void): void {\n\t\tthis.items.forEach((item) => {\n\t\t\tcallbackfn(item, item, this);\n\t\t});\n\t}\n\thas(value: T): boolean {\n\t\treturn this.items.indexOf(value) !== -1;\n\t}\n\n\tget size(): number {\n\t\treturn this.items.length;\n\t}\n}\n\nexport default typeof Set === \"undefined\" ? Set : SetLike;\n"],"file":"SetLike.js"}