Skip to content

Instantly share code, notes, and snippets.

/index.html

Created May 28, 2016
Embed
What would you like to do?
JS Bin // source http://jsbin.com/tebihizuke
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="https://rawgit.com/baconjs/bacon.js/master/dist/Bacon.js"></script>
</head>
<body>
<script id="jsbin-javascript">
// Bacon.sequentially gives the values in the array with a delay
// specified by the first parameter in ms
var originalStream = Bacon.sequentially(100, [1, -6, -24, 666])
originalStream.log("Original")
// Create a stream with every number increased by 20
var increasedStream = originalStream.map(function(x) {return x*20})
increasedStream.log("Increased")
// Create a stream with only the positive numbers of originalStream
var positiveStream = originalStream.filter(function(x) {if (x>0) return x})
positiveStream.log("Positive")
// Create a stream which tell if the numbers in originalStream are positive (true) or negative(false)
var signStream = originalStream.map(function(x) {x>0})
signStream.log("Sign")
// Combine .map and .filter to make your own streams
</script>
<script id="jsbin-source-javascript" type="text/javascript">// Bacon.sequentially gives the values in the array with a delay
// specified by the first parameter in ms
var originalStream = Bacon.sequentially(100, [1, -6, -24, 666])
originalStream.log("Original")
// Create a stream with every number increased by 20
var increasedStream = originalStream.map(function(x) {return x*20})
increasedStream.log("Increased")
// Create a stream with only the positive numbers of originalStream
var positiveStream = originalStream.filter(function(x) {if (x>0) return x})
positiveStream.log("Positive")
// Create a stream which tell if the numbers in originalStream are positive (true) or negative(false)
var signStream = originalStream.map(function(x) {x>0})
signStream.log("Sign")
// Combine .map and .filter to make your own streams</script></body>
</html>
// Bacon.sequentially gives the values in the array with a delay
// specified by the first parameter in ms
var originalStream = Bacon.sequentially(100, [1, -6, -24, 666])
originalStream.log("Original")
// Create a stream with every number increased by 20
var increasedStream = originalStream.map(function(x) {return x*20})
increasedStream.log("Increased")
// Create a stream with only the positive numbers of originalStream
var positiveStream = originalStream.filter(function(x) {if (x>0) return x})
positiveStream.log("Positive")
// Create a stream which tell if the numbers in originalStream are positive (true) or negative(false)
var signStream = originalStream.map(function(x) {x>0})
signStream.log("Sign")
// Combine .map and .filter to make your own streams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment