made with esnextbin
Created
March 8, 2016 02:01
-
-
Save briancavalier/6c07d9249aefc553ec68 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains 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>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
This file contains 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 { from, empty, continueWith } from 'most' | |
const repeat = (n, stream) => | |
n === 0 ? empty() | |
: n === 1 ? stream | |
: continueWith(() => repeat(n-1, stream), stream) | |
const s = from([1,2,3]) | |
repeat(2, s).observe(x => console.log(x)) |
This file contains 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.18.0" | |
} | |
} |
This file contains 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 repeat = function repeat(n, stream) { | |
return n === 0 ? (0, _most.empty)() : n === 1 ? stream : (0, _most.continueWith)(function () { | |
return repeat(n - 1, stream); | |
}, stream); | |
}; | |
var s = (0, _most.from)([1, 2, 3]); | |
repeat(2, s).observe(function (x) { | |
return console.log(x); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment