Debian Codegraph @

node/rxjs/dist/esm5/internal/operators/last.js

raw
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 var hasDefaultValue = arguments.length >= 2;
9 return function (source) {
10 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 }
13 //# sourceMappingURL=last.js.map