Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sequenceEqual.d.ts 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { Operator } from '../Operator';
  2. import { Observable } from '../Observable';
  3. import { Subscriber } from '../Subscriber';
  4. import { Observer, OperatorFunction } from '../types';
  5. /**
  6. * Compares all values of two observables in sequence using an optional comparor function
  7. * and returns an observable of a single boolean value representing whether or not the two sequences
  8. * are equal.
  9. *
  10. * <span class="informal">Checks to see of all values emitted by both observables are equal, in order.</span>
  11. *
  12. * ![](sequenceEqual.png)
  13. *
  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.
  20. *
  21. * ## Example
  22. * figure out if the Konami code matches
  23. * ```javascript
  24. * const codes = from([
  25. * 'ArrowUp',
  26. * 'ArrowUp',
  27. * 'ArrowDown',
  28. * 'ArrowDown',
  29. * 'ArrowLeft',
  30. * 'ArrowRight',
  31. * 'ArrowLeft',
  32. * 'ArrowRight',
  33. * 'KeyB',
  34. * 'KeyA',
  35. * 'Enter', // no start key, clearly.
  36. * ]);
  37. *
  38. * const keys = fromEvent(document, 'keyup').pipe(map(e => e.code));
  39. * const matches = keys.pipe(
  40. * bufferCount(11, 1),
  41. * mergeMap(
  42. * last11 => from(last11).pipe(sequenceEqual(codes)),
  43. * ),
  44. * );
  45. * matches.subscribe(matched => console.log('Successful cheat at Contra? ', matched));
  46. * ```
  47. *
  48. * @see {@link combineLatest}
  49. * @see {@link zip}
  50. * @see {@link withLatestFrom}
  51. *
  52. * @param {Observable} compareTo The observable sequence to compare the source sequence to.
  53. * @param {function} [comparor] An optional function to compare each value pair
  54. * @return {Observable} An Observable of a single boolean value representing whether or not
  55. * the values emitted by both observables were equal in sequence.
  56. * @method sequenceEqual
  57. * @owner Observable
  58. */
  59. export declare function sequenceEqual<T>(compareTo: Observable<T>, comparor?: (a: T, b: T) => boolean): OperatorFunction<T, boolean>;
  60. export declare class SequenceEqualOperator<T> implements Operator<T, boolean> {
  61. private compareTo;
  62. private comparor;
  63. constructor(compareTo: Observable<T>, comparor: (a: T, b: T) => boolean);
  64. call(subscriber: Subscriber<boolean>, source: any): any;
  65. }
  66. /**
  67. * We need this JSDoc comment for affecting ESDoc.
  68. * @ignore
  69. * @extends {Ignored}
  70. */
  71. export declare class SequenceEqualSubscriber<T, R> extends Subscriber<T> {
  72. private compareTo;
  73. private comparor;
  74. private _a;
  75. private _b;
  76. private _oneComplete;
  77. constructor(destination: Observer<R>, compareTo: Observable<T>, comparor: (a: T, b: T) => boolean);
  78. protected _next(value: T): void;
  79. _complete(): void;
  80. checkValues(): void;
  81. emit(value: boolean): void;
  82. nextB(value: T): void;
  83. completeB(): void;
  84. }