Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

first.js 591B

1234567891011
  1. import { EmptyError } from '../util/EmptyError';
  2. import { filter } from './filter';
  3. import { take } from './take';
  4. import { defaultIfEmpty } from './defaultIfEmpty';
  5. import { throwIfEmpty } from './throwIfEmpty';
  6. import { identity } from '../util/identity';
  7. export function first(predicate, defaultValue) {
  8. const hasDefaultValue = arguments.length >= 2;
  9. return (source) => source.pipe(predicate ? filter((v, i) => predicate(v, i, source)) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(() => new EmptyError()));
  10. }
  11. //# sourceMappingURL=first.js.map