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ACD,EAAE,CAAC,CAAC,GAAG,GAAG,cAAc,CAAC,CAAC,CAAC;QACvB,MAAM,CAAC,cAAc,CAAC;IAC1B,CAAC;IACD,MAAM,CAAC,GAAG,CAAC;AACb,CAAC;AAED,wBAAwB,KAAU;IAChC,MAAM,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,WAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,cAAc,KAAU;IACtB,IAAI,aAAa,GAAG,CAAC,KAAK,CAAC;IAC3B,EAAE,CAAC,CAAC,aAAa,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,CAAC,aAAa,CAAC;IACvB,CAAC;IACD,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,aAAa,CAAC;IACvB,CAAC;IACD,MAAM,CAAC,aAAa,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { root } from '../util/root';\nimport { IScheduler } from '../Scheduler';\nimport { Observable } from '../Observable';\nimport { iterator as Symbol_iterator } from '../symbol/iterator';\nimport { TeardownLogic } from '../Subscription';\nimport { Subscriber } from '../Subscriber';\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @extends {Ignored}\n * @hide true\n */\nexport class IteratorObservable<T> extends Observable<T> {\n private iterator: any;\n\n static create<T>(iterator: any, scheduler?: IScheduler): IteratorObservable<T> {\n return new IteratorObservable(iterator, scheduler);\n }\n\n static dispatch(state: any) {\n\n const { index, hasError, iterator, subscriber } = state;\n\n if (hasError) {\n subscriber.error(state.error);\n return;\n }\n\n let result = iterator.next();\n if (result.done) {\n subscriber.complete();\n return;\n }\n\n subscriber.next(result.value);\n state.index = index + 1;\n\n if (subscriber.closed) {\n if (typeof iterator.return === 'function') {\n iterator.return();\n }\n return;\n }\n\n (<any> this).schedule(state);\n }\n\n constructor(iterator: any, private scheduler?: IScheduler) {\n super();\n\n if (iterator == null) {\n throw new Error('iterator cannot be null.');\n }\n\n this.iterator = getIterator(iterator);\n }\n\n /** @deprecated internal use only */ _subscribe(subscriber: Subscriber<T>): TeardownLogic {\n\n let index = 0;\n const { iterator, scheduler } = this;\n\n if (scheduler) {\n return scheduler.schedule(IteratorObservable.dispatch, 0, {\n index, iterator, subscriber\n });\n } else {\n do {\n let result = iterator.next();\n if (result.done) {\n subscriber.complete();\n break;\n } else {\n subscriber.next(result.value);\n }\n if (subscriber.closed) {\n if (typeof iterator.return === 'function') {\n iterator.return();\n }\n break;\n }\n } while (true);\n }\n }\n}\n\nclass StringIterator {\n constructor(private str: string,\n private idx: number = 0,\n private len: number = str.length) {\n }\n [Symbol_iterator]() { return (this); }\n next() {\n return this.idx < this.len ? {\n done: false,\n value: this.str.charAt(this.idx++)\n } : {\n done: true,\n value: undefined\n };\n }\n}\n\nclass ArrayIterator {\n constructor(private arr: Array<any>,\n private idx: number = 0,\n private len: number = toLength(arr)) {\n }\n [Symbol_iterator]() { return this; }\n next() {\n return this.idx < this.len ? {\n done: false,\n value: this.arr[this.idx++]\n } : {\n done: true,\n value: undefined\n };\n }\n}\n\nfunction getIterator(obj: any) {\n const i = obj[Symbol_iterator];\n if (!i && typeof obj === 'string') {\n return new StringIterator(obj);\n }\n if (!i && obj.length !== undefined) {\n return new ArrayIterator(obj);\n }\n if (!i) {\n throw new TypeError('object is not iterable');\n }\n return obj[Symbol_iterator]();\n}\n\nconst maxSafeInteger = Math.pow(2, 53) - 1;\n\nfunction toLength(o: any) {\n let len = +o.length;\n if (isNaN(len)) {\n return 0;\n }\n if (len === 0 || !numberIsFinite(len)) {\n return len;\n }\n len = sign(len) * Math.floor(Math.abs(len));\n if (len <= 0) {\n return 0;\n }\n if (len > maxSafeInteger) {\n return maxSafeInteger;\n }\n return len;\n}\n\nfunction numberIsFinite(value: any) {\n return typeof value === 'number' && root.isFinite(value);\n}\n\nfunction sign(value: any) {\n let valueAsNumber = +value;\n if (valueAsNumber === 0) {\n return valueAsNumber;\n }\n if (isNaN(valueAsNumber)) {\n return valueAsNumber;\n }\n return valueAsNumber < 0 ? -1 : 1;\n}\n"]}