throwIfEmpty.js 619 B

123456789101112131415161718192021
  1. /** PURE_IMPORTS_START _tap,_util_EmptyError PURE_IMPORTS_END */
  2. import { tap } from './tap';
  3. import { EmptyError } from '../util/EmptyError';
  4. export var throwIfEmpty = function (errorFactory) {
  5. if (errorFactory === void 0) {
  6. errorFactory = defaultErrorFactory;
  7. }
  8. return tap({
  9. hasValue: false,
  10. next: function () { this.hasValue = true; },
  11. complete: function () {
  12. if (!this.hasValue) {
  13. throw errorFactory();
  14. }
  15. }
  16. });
  17. };
  18. function defaultErrorFactory() {
  19. return new EmptyError();
  20. }
  21. //# sourceMappingURL=throwIfEmpty.js.map