Demo: single
single with a condition asserts there is only one match.
single( v=> (condition))
1.For more than one match it emits *SequenceError*
2.For no match, it emits *NotFoundError*
3.For EMPTY input, it emits EmptyError
single without a condition asserts there is only one value.
//Emits either of the 2 data streams
//based on Math.random() outcome
let input = iif(()=>(Math.random()>0.5),
of(2,5,25,5,15,5), //outputs 25
of(3,5,25,5,25,5) //outputs "E"
).pipe(concatMap(v=>of(v).pipe(delay(100*v))));
//asserts there is only one match
let process = single(v => (v%25 == 0));
//Catch the error and convert it into the given observable
let catchError = catchError(e => of("E"));
let output = input.pipe(process,catchError)
.subscribe(v=>console.log(v))