made with esnextbin
Created
May 6, 2016 01:49
-
-
Save briancavalier/11761ba9cc1da644776ef1896d244edf 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 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: () => {} | |
}) |
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": { | |
"xstream": "2.1.3" | |
} | |
} |
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 _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