initial commit - far from runnable
This commit is contained in:
commit
db057ce342
8614 changed files with 1032171 additions and 0 deletions
30
node_modules/rxjs/dist/esm/internal/operators/single.js
generated
vendored
Normal file
30
node_modules/rxjs/dist/esm/internal/operators/single.js
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { EmptyError } from '../util/EmptyError';
|
||||
import { SequenceError } from '../util/SequenceError';
|
||||
import { NotFoundError } from '../util/NotFoundError';
|
||||
import { operate } from '../util/lift';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
export function single(predicate) {
|
||||
return operate((source, subscriber) => {
|
||||
let hasValue = false;
|
||||
let singleValue;
|
||||
let seenValue = false;
|
||||
let index = 0;
|
||||
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
|
||||
seenValue = true;
|
||||
if (!predicate || predicate(value, index++, source)) {
|
||||
hasValue && subscriber.error(new SequenceError('Too many matching values'));
|
||||
hasValue = true;
|
||||
singleValue = value;
|
||||
}
|
||||
}, () => {
|
||||
if (hasValue) {
|
||||
subscriber.next(singleValue);
|
||||
subscriber.complete();
|
||||
}
|
||||
else {
|
||||
subscriber.error(seenValue ? new NotFoundError('No matching values') : new EmptyError());
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=single.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue