Skip to content

Instantly share code, notes, and snippets.

@TylorS
Last active March 8, 2016 01:07
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 TylorS/5f5b4fd20b8e59c1954e to your computer and use it in GitHub Desktop.
Save TylorS/5f5b4fd20b8e59c1954e 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>
const {from, empty, continueWith} = require('most')
function repeat(n, stream) {
return continueWith(() => {
return n-- > 1 ?
repeat(n, stream) :
empty()
}, stream)
}
const a$ = from([1, 2, 3])
repeat(1, a$).observe(x => console.log(`Next: ${x}`))
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"most": "0.18.0"
}
}
'use strict';
var _require = require('most');
var from = _require.from;
var empty = _require.empty;
var continueWith = _require.continueWith;
function repeat(n, stream) {
return continueWith(function () {
return n-- > 1 ? repeat(n, stream) : empty();
}, stream);
}
var a$ = from([1, 2, 3]);
repeat(1, a$).observe(function (x) {
return console.log('Next: ' + x);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment