startWith.js 879 B

123456789101112131415161718192021222324252627
  1. import { fromArray } from '../observable/fromArray';
  2. import { scalar } from '../observable/scalar';
  3. import { empty } from '../observable/empty';
  4. import { concat as concatStatic } from '../observable/concat';
  5. import { isScheduler } from '../util/isScheduler';
  6. export function startWith(...array) {
  7. return (source) => {
  8. let scheduler = array[array.length - 1];
  9. if (isScheduler(scheduler)) {
  10. array.pop();
  11. }
  12. else {
  13. scheduler = null;
  14. }
  15. const len = array.length;
  16. if (len === 1 && !scheduler) {
  17. return concatStatic(scalar(array[0]), source);
  18. }
  19. else if (len > 0) {
  20. return concatStatic(fromArray(array, scheduler), source);
  21. }
  22. else {
  23. return concatStatic(empty(scheduler), source);
  24. }
  25. };
  26. }
  27. //# sourceMappingURL=startWith.js.map