made with esnextbin
Last active
May 5, 2016 02:50
-
-
Save briancavalier/a5119fc58c8ccdfa3329b9c6d55306c4 to your computer and use it in GitHub Desktop.
esnextbin sketch
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
| <!doctype html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Sliders</title> | |
| </head> | |
| <body> | |
| <div id="app"> | |
| </body> | |
| </html> |
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 { periodic } from 'most' | |
| import { Observable } from '@reactivex/rxjs' | |
| // period | |
| const p = 1 | |
| // number of events | |
| const n = 1000 | |
| const elapsed = (name, start) => document.write(`${name} ${Date.now() - start}<br/>`) | |
| const runRx = () => { | |
| const start = Date.now() | |
| Observable.interval(p).take(n).subscribe({ | |
| next() {}, | |
| error() {}, | |
| complete() { | |
| elapsed('rxjs', start) | |
| } | |
| }) | |
| } | |
| const runMost = () => { | |
| const start = Date.now() | |
| // most periodic first event is at time zero, whereas | |
| // rxjs interval first event is at time p, so use | |
| // delay(p) here to normalize to rxjs semantics | |
| return periodic(p).delay(p).take(n).drain() | |
| .then(() => elapsed('most', start)) | |
| } | |
| runMost().then(runRx) |
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
| { | |
| "name": "esnextbin-sketch", | |
| "version": "0.0.0", | |
| "dependencies": { | |
| "most": "0.19.2", | |
| "@reactivex/rxjs": "5.0.0-beta.7" | |
| } | |
| } |
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
| 'use strict'; | |
| var _most = require('most'); | |
| var _rxjs = require('@reactivex/rxjs'); | |
| // period | |
| var p = 1; | |
| // number of events | |
| var n = 1000; | |
| var elapsed = function elapsed(name, start) { | |
| return document.write(name + ' ' + (Date.now() - start) + '<br/>'); | |
| }; | |
| var runRx = function runRx() { | |
| var start = Date.now(); | |
| _rxjs.Observable.interval(p).take(n).subscribe({ | |
| next: function next() {}, | |
| error: function error() {}, | |
| complete: function complete() { | |
| elapsed('rxjs', start); | |
| } | |
| }); | |
| }; | |
| var runMost = function runMost() { | |
| var start = Date.now(); | |
| // most periodic first event is at time zero, whereas | |
| // rxjs interval first event is at time p, so use | |
| // delay(p) here to normalize to rxjs semantics | |
| return (0, _most.periodic)(p).delay(p).take(n).drain().then(function () { | |
| return elapsed('most', start); | |
| }); | |
| }; | |
| runMost().then(runRx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment