1 |
- {"version":3,"file":"sequenceEqual.js","sourceRoot":"","sources":["../../src/operator/sequenceEqual.ts"],"names":[],"mappings":";AACA,8BAA6C,4BAA4B,CAAC,CAAA;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,uBAAsD,SAAwB,EAC7C,QAAkC;IACjE,MAAM,CAAC,6BAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC;AAHe,qBAAa,gBAG5B,CAAA","sourcesContent":["import { Observable } from '../Observable';\nimport { sequenceEqual as higherOrder } from '../operators/sequenceEqual';\n\n/**\n * Compares all values of two observables in sequence using an optional comparor function\n * and returns an observable of a single boolean value representing whether or not the two sequences\n * are equal.\n *\n * <span class=\"informal\">Checks to see of all values emitted by both observables are equal, in order.</span>\n *\n * <img src=\"./img/sequenceEqual.png\" width=\"100%\">\n *\n * `sequenceEqual` subscribes to two observables and buffers incoming values from each observable. Whenever either\n * observable emits a value, the value is buffered and the buffers are shifted and compared from the bottom\n * up; If any value pair doesn't match, the returned observable will emit `false` and complete. If one of the\n * observables completes, the operator will wait for the other observable to complete; If the other\n * observable emits before completing, the returned observable will emit `false` and complete. If one observable never\n * completes or emits after the other complets, the returned observable will never complete.\n *\n * @example <caption>figure out if the Konami code matches</caption>\n * var code = Rx.Observable.from([\n * \"ArrowUp\",\n * \"ArrowUp\",\n * \"ArrowDown\",\n * \"ArrowDown\",\n * \"ArrowLeft\",\n * \"ArrowRight\",\n * \"ArrowLeft\",\n * \"ArrowRight\",\n * \"KeyB\",\n * \"KeyA\",\n * \"Enter\" // no start key, clearly.\n * ]);\n *\n * var keys = Rx.Observable.fromEvent(document, 'keyup')\n * .map(e => e.code);\n * var matches = keys.bufferCount(11, 1)\n * .mergeMap(\n * last11 =>\n * Rx.Observable.from(last11)\n * .sequenceEqual(code)\n * );\n * matches.subscribe(matched => console.log('Successful cheat at Contra? ', matched));\n *\n * @see {@link combineLatest}\n * @see {@link zip}\n * @see {@link withLatestFrom}\n *\n * @param {Observable} compareTo The observable sequence to compare the source sequence to.\n * @param {function} [comparor] An optional function to compare each value pair\n * @return {Observable} An Observable of a single boolean value representing whether or not\n * the values emitted by both observables were equal in sequence.\n * @method sequenceEqual\n * @owner Observable\n */\nexport function sequenceEqual<T>(this: Observable<T>, compareTo: Observable<T>,\n comparor?: (a: T, b: T) => boolean): Observable<boolean> {\n return higherOrder(compareTo, comparor)(this);\n}\n"]}
|