frontend/.pnpm-store/v3/files/a7/88c72e028da5fcb916f59234b7e0cda700081b38ccaf46c75b4f5b83b35b36e088710f8407ad496495136b24fa90b5fb6a3ca1e5f53c6f44a11413cb8270d0

30 lines
914 B
Plaintext

import { Subscriber } from '../Subscriber';
export function defaultIfEmpty(defaultValue = null) {
return (source) => source.lift(new DefaultIfEmptyOperator(defaultValue));
}
class DefaultIfEmptyOperator {
constructor(defaultValue) {
this.defaultValue = defaultValue;
}
call(subscriber, source) {
return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
}
}
class DefaultIfEmptySubscriber extends Subscriber {
constructor(destination, defaultValue) {
super(destination);
this.defaultValue = defaultValue;
this.isEmpty = true;
}
_next(value) {
this.isEmpty = false;
this.destination.next(value);
}
_complete() {
if (this.isEmpty) {
this.destination.next(this.defaultValue);
}
this.destination.complete();
}
}
//# sourceMappingURL=defaultIfEmpty.js.map