Skip to content

Instantly share code, notes, and snippets.

@briancavalier
Created May 6, 2016 01:49
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 briancavalier/11761ba9cc1da644776ef1896d244edf to your computer and use it in GitHub Desktop.
Save briancavalier/11761ba9cc1da644776ef1896d244edf 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 xs from 'xstream'
const extend = (f, stream) =>
stream.mapTo(stream.map(f))
const s = xs.periodic(1).take(10)
const logStream = s =>
s.fold((x, y) => x.concat(y), []).last()
.addListener({
next: x => document.write('(' + x + ')\n'),
error: () => {},
complete: () => {}
})
extend(x => x.take(3), s)
.addListener({
next: logStream,
error: () => {},
complete: () => {}
})
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"xstream": "2.1.3"
}
}
'use strict';
var _xstream = require('xstream');
var _xstream2 = _interopRequireDefault(_xstream);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var extend = function extend(f, stream) {
return stream.mapTo(stream.map(f));
};
var s = _xstream2.default.periodic(1).take(10);
var logStream = function logStream(s) {
return s.fold(function (x, y) {
return x.concat(y);
}, []).last().addListener({
next: function next(x) {
return document.write('(' + x + ')\n');
},
error: function error() {},
complete: function complete() {}
});
};
extend(function (x) {
return x.take(3);
}, s).addListener({
next: logStream,
error: function error() {},
complete: function complete() {}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment