Skip to content

Instantly share code, notes, and snippets.

@webhacking
Created January 24, 2019 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webhacking/428bddff5908b762c457729662106568 to your computer and use it in GitHub Desktop.
Save webhacking/428bddff5908b762c457729662106568 to your computer and use it in GitHub Desktop.
RxJS Example 04
import {from} from 'rxjs/internal/observable/from';
import {bufferCount, count, filter} from 'rxjs/operators';
const source = 'acbqibekboabkdnopenmenuckofqamdqlvopenmenuasdqweascqwekasdcnaskdeqweqwcasdopenmenu';
const sequence$ = from(source);
const matchSequence = 'openmenu';
sequence$
.pipe(
bufferCount(matchSequence.length, 1),
filter((x) => {
return ( x.join('') === matchSequence )
}),
count(),
)
.subscribe((cnt: number) => {
console.log(cnt)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment