166fee26ab7a193cc229e5997b5c506a80a6a7409b48cc917cfa6fc7008fa88b91150eef467d1cbf13ec0909c8c1c2b9c5bf5d0c5288603261a863ec3018c5 763 B

123456789101112
  1. /** PURE_IMPORTS_START _util_EmptyError,_filter,_take,_defaultIfEmpty,_throwIfEmpty,_util_identity PURE_IMPORTS_END */
  2. import { EmptyError } from '../util/EmptyError';
  3. import { filter } from './filter';
  4. import { take } from './take';
  5. import { defaultIfEmpty } from './defaultIfEmpty';
  6. import { throwIfEmpty } from './throwIfEmpty';
  7. import { identity } from '../util/identity';
  8. export function first(predicate, defaultValue) {
  9. var hasDefaultValue = arguments.length >= 2;
  10. return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
  11. }
  12. //# sourceMappingURL=first.js.map