Last active
August 29, 2015 14:11
-
-
Save hekike/2af764c859e18464557e to your computer and use it in GitHub Desktop.
Mixed highlandjs and node streams
This file contains hidden or 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
var stream = require('stream'); | |
var _ = require('highland'); | |
var $ = require('jquery'); | |
var toConsoleStream = new stream.Writable({ objectMode: true }); | |
toConsoleStream._write = function (data, encoding, done) { | |
console.log(data); | |
done(); | |
}; | |
_('click', $('#button')) | |
.throttle(200) | |
.map(1) | |
.scan(0, _.add) | |
.pipe(toConsoleStream); |
This file contains hidden or 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 http-equiv='Content-type' content='text/html; charset=utf-8'> | |
<title>FRP</title> | |
</head> | |
<body> | |
<button id="button">BUTTON</button> | |
<script src="bundle.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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": "frp-node-stream", | |
"version": "0.0.1", | |
"main": "app.js", | |
"scripts": { | |
"bundle": "webpack-dev-server", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"devDependencies": { | |
"webpack": "^1.4.13", | |
"webpack-dev-server": "^1.6.6" | |
}, | |
"dependencies": { | |
"highland": "^2.2.0", | |
"jquery": "^2.1.1" | |
} | |
} |
This file contains hidden or 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
module.exports = { | |
entry: { | |
app: ['./app.js'] | |
}, | |
output: { | |
path: './', | |
filename: 'bundle.js' | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment