Skip to content

Instantly share code, notes, and snippets.

@briancavalier
Created March 8, 2016 02:01
Show Gist options
  • Save briancavalier/6c07d9249aefc553ec68 to your computer and use it in GitHub Desktop.
Save briancavalier/6c07d9249aefc553ec68 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!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>
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))
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"most": "0.18.0"
}
}
'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