This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Observable } from "rxjs"; | |
| // code based on https://rxjs-dev.firebaseapp.com/guide/v6/pipeable-operators | |
| export const delayAndTakeLast = () => <T>(source: Observable<wrappedWithDelay<T>>) => | |
| new Observable<T>(observer => { | |
| let nextIndex = 0; | |
| let prevFiredIndex = -1; | |
| let delayedEvents: { index: number; event: T; timeout: any }[] = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Observable } from "rxjs"; | |
| // code based on https://rxjs-dev.firebaseapp.com/guide/v6/pipeable-operators | |
| // Usages: | |
| // uniqueEventCounter(250, buttonComperator, 2) => for click/double-click, when more than 1 button emit events. | |
| // uniqueEventCounter(250, trueComperator, 2) => for click/double-click, when only 1 button emit events. | |
| export const trueComperator = (a: any, b: any) => true; | |
| export const simpleComperator = (a: any, b: any) => a === b; | |
| export const buttonComperator = (a: MouseEvent, b: MouseEvent) => a.srcElement === b.srcElement; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://www.youtube.com/watch?v=tj_sBZw9nS0 | |
| const isMatch = (s: string, p: string): boolean => { | |
| if (!s.length || !p.length) { | |
| return !s.length && !p.length; | |
| } | |
| if (p[1] === '*') { | |
| if (isMatch(s, p.substr(2))) return true; |