1 line
3.6 KiB
Plaintext
Executable File
1 line
3.6 KiB
Plaintext
Executable File
{"version":3,"file":"startWith.js","sourceRoot":"","sources":["../../src/operators/startWith.ts"],"names":[],"mappings":";AAEA,gCAAgC,+BAA+B,CAAC,CAAA;AAChE,iCAAiC,gCAAgC,CAAC,CAAA;AAClE,gCAAgC,+BAA+B,CAAC,CAAA;AAChE,uBAAuC,sBAAsB,CAAC,CAAA;AAC9D,4BAA4B,qBAAqB,CAAC,CAAA;AAWlD,mCAAmC;AAEnC;;;;;;;;;;;;;GAaG;AACH;IAA6B,eAA+B;SAA/B,WAA+B,CAA/B,sBAA+B,CAA/B,IAA+B;QAA/B,8BAA+B;;IAC1D,MAAM,CAAC,UAAC,MAAqB;QAC3B,IAAI,SAAS,GAAe,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACpD,EAAE,CAAC,CAAC,yBAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC3B,KAAK,CAAC,GAAG,EAAE,CAAC;QACd,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC;QAED,IAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;QACzB,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACd,MAAM,CAAC,eAAY,CAAC,IAAI,mCAAgB,CAAO,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;QAC/E,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YACnB,MAAM,CAAC,eAAY,CAAC,IAAI,iCAAe,CAAS,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;QAC7E,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,MAAM,CAAC,eAAY,CAAC,IAAI,iCAAe,CAAI,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAlBe,iBAAS,YAkBxB,CAAA","sourcesContent":["import { IScheduler } from '../Scheduler';\nimport { Observable } from '../Observable';\nimport { ArrayObservable } from '../observable/ArrayObservable';\nimport { ScalarObservable } from '../observable/ScalarObservable';\nimport { EmptyObservable } from '../observable/EmptyObservable';\nimport { concat as concatStatic } from '../observable/concat';\nimport { isScheduler } from '../util/isScheduler';\nimport { MonoTypeOperatorFunction } from '../interfaces';\n\n/* tslint:disable:max-line-length */\nexport function startWith<T>(v1: T, scheduler?: IScheduler): MonoTypeOperatorFunction<T>;\nexport function startWith<T>(v1: T, v2: T, scheduler?: IScheduler): MonoTypeOperatorFunction<T>;\nexport function startWith<T>(v1: T, v2: T, v3: T, scheduler?: IScheduler): MonoTypeOperatorFunction<T>;\nexport function startWith<T>(v1: T, v2: T, v3: T, v4: T, scheduler?: IScheduler): MonoTypeOperatorFunction<T>;\nexport function startWith<T>(v1: T, v2: T, v3: T, v4: T, v5: T, scheduler?: IScheduler): MonoTypeOperatorFunction<T>;\nexport function startWith<T>(v1: T, v2: T, v3: T, v4: T, v5: T, v6: T, scheduler?: IScheduler): MonoTypeOperatorFunction<T>;\nexport function startWith<T>(...array: Array<T | IScheduler>): MonoTypeOperatorFunction<T>;\n/* tslint:enable:max-line-length */\n\n/**\n * Returns an Observable that emits the items you specify as arguments before it begins to emit\n * items emitted by the source Observable.\n *\n * <img src=\"./img/startWith.png\" width=\"100%\">\n *\n * @param {...T} values - Items you want the modified Observable to emit first.\n * @param {Scheduler} [scheduler] - A {@link IScheduler} to use for scheduling\n * the emissions of the `next` notifications.\n * @return {Observable} An Observable that emits the items in the specified Iterable and then emits the items\n * emitted by the source Observable.\n * @method startWith\n * @owner Observable\n */\nexport function startWith<T>(...array: Array<T | IScheduler>): MonoTypeOperatorFunction<T> {\n return (source: Observable<T>) => {\n let scheduler = <IScheduler>array[array.length - 1];\n if (isScheduler(scheduler)) {\n array.pop();\n } else {\n scheduler = null;\n }\n\n const len = array.length;\n if (len === 1) {\n return concatStatic(new ScalarObservable<T>(<T>array[0], scheduler), source);\n } else if (len > 1) {\n return concatStatic(new ArrayObservable<T>(<T[]>array, scheduler), source);\n } else {\n return concatStatic(new EmptyObservable<T>(scheduler), source);\n }\n };\n}\n"]} |