1b5f9d4b3cddb4ff0bde73c1b9c09588aba5317ca288f14c27a4af45306d7ecbdfac2d3bd1f61143ed97701da61472fd8f443d14cd26fd20a27d6e91df0926 777 B

123456789101112
  1. /** PURE_IMPORTS_START _util_EmptyError,_filter,_takeLast,_throwIfEmpty,_defaultIfEmpty,_util_identity PURE_IMPORTS_END */
  2. import { EmptyError } from '../util/EmptyError';
  3. import { filter } from './filter';
  4. import { takeLast } from './takeLast';
  5. import { throwIfEmpty } from './throwIfEmpty';
  6. import { defaultIfEmpty } from './defaultIfEmpty';
  7. import { identity } from '../util/identity';
  8. export function last(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, takeLast(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
  11. }
  12. //# sourceMappingURL=last.js.map