1 import { Operator } from '../Operator';
2 import { Observable } from '../Observable';
3 import { Subscriber } from '../Subscriber';
4 import { Observer, OperatorFunction } from '../types';
6 * Compares all values of two observables in sequence using an optional comparator function
7 * and returns an observable of a single boolean value representing whether or not the two sequences
10 * <span class="informal">Checks to see of all values emitted by both observables are equal, in order.</span>
12 * ![](sequenceEqual.png)
14 * `sequenceEqual` subscribes to two observables and buffers incoming values from each observable. Whenever either
15 * observable emits a value, the value is buffered and the buffers are shifted and compared from the bottom
16 * up; If any value pair doesn't match, the returned observable will emit `false` and complete. If one of the
17 * observables completes, the operator will wait for the other observable to complete; If the other
18 * observable emits before completing, the returned observable will emit `false` and complete. If one observable never
19 * completes or emits after the other complets, the returned observable will never complete.
22 * figure out if the Konami code matches
24 * import { from, fromEvent } from 'rxjs';
25 * import { sequenceEqual, bufferCount, mergeMap, map } from 'rxjs/operators';
27 * const codes = from([
38 * 'Enter', // no start key, clearly.
41 * const keys = fromEvent(document, 'keyup').pipe(map(e => e.code));
42 * const matches = keys.pipe(
45 * last11 => from(last11).pipe(sequenceEqual(codes)),
48 * matches.subscribe(matched => console.log('Successful cheat at Contra? ', matched));
51 * @see {@link combineLatest}
53 * @see {@link withLatestFrom}
55 * @param {Observable} compareTo The observable sequence to compare the source sequence to.
56 * @param {function} [comparator] An optional function to compare each value pair
57 * @return {Observable} An Observable of a single boolean value representing whether or not
58 * the values emitted by both observables were equal in sequence.
59 * @method sequenceEqual
62 export declare function sequenceEqual<T>(compareTo: Observable<T>, comparator?: (a: T, b: T) => boolean): OperatorFunction<T, boolean>;
63 export declare class SequenceEqualOperator<T> implements Operator<T, boolean> {
66 constructor(compareTo: Observable<T>, comparator: (a: T, b: T) => boolean);
67 call(subscriber: Subscriber<boolean>, source: any): any;
70 * We need this JSDoc comment for affecting ESDoc.
74 export declare class SequenceEqualSubscriber<T, R> extends Subscriber<T> {
80 constructor(destination: Observer<R>, compareTo: Observable<T>, comparator: (a: T, b: T) => boolean);
81 protected _next(value: T): void;
84 emit(value: boolean): void;
85 nextB(value: T): void;