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