Comparing version 0.0.1 to 0.0.2
@@ -54,4 +54,3 @@ (function (root, factory) { | ||
function map(f) { | ||
var s = this; | ||
function map(s, f) { | ||
return stream(function() { return f(s()); }); | ||
@@ -145,3 +144,3 @@ } | ||
s.destroy = destroyStream.bind(null, s); | ||
s.map = map; | ||
s.map = map.bind(null, s); | ||
s.ap = ap; | ||
@@ -188,3 +187,4 @@ s.of = of; | ||
reduce: reduce, | ||
map: map, | ||
}; | ||
})); |
{ | ||
"name": "flyd", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "The less is more, modular, functional reactive programming library", | ||
@@ -36,3 +36,20 @@ "main": "flyd.js", | ||
}, | ||
"homepage": "https://github.com/paldepind/flyd" | ||
"homepage": "https://github.com/paldepind/flyd", | ||
"testling": { | ||
"harness": "mocha", | ||
"files": "test/*.js", | ||
"browsers": [ | ||
"ie/8..latest", | ||
"firefox/16..latest", | ||
"firefox/nightly", | ||
"chrome/22..latest", | ||
"chrome/canary", | ||
"opera/12..latest", | ||
"opera/next", | ||
"safari/5.1..latest", | ||
"ipad/6.0..latest", | ||
"iphone/6.0..latest", | ||
"android-browser/4.2..latest" | ||
] | ||
} | ||
} |
@@ -8,2 +8,11 @@ # Flyd | ||
[![browser support](https://ci.testling.com/paldepind/flyd.png) | ||
](https://ci.testling.com/paldepind/flyd) | ||
# Table of contents | ||
* [Introduction](#introduction) | ||
* [Tutorial](#tutorial) | ||
* [API](#api) | ||
## Introduction | ||
@@ -177,2 +186,3 @@ | ||
}; | ||
``` | ||
@@ -212,4 +222,5 @@ We simply create a new stream dependent on the first stream. We declare | ||
__Arguments__ | ||
* \[`dependencies`\] (array) - The streams on which this stream should initially depend. | ||
* `body` (function|\*) - The function body of the stream or it initial value. | ||
* \[`dependencies`\] (array) – The streams on which this stream should initially depend. | ||
* `body` (function|\*) – The function body of the stream or it initial value. | ||
* \[`staticDependencies`\] – Disables automatic dependency resolution of the stream. | ||
@@ -220,2 +231,46 @@ __Returns__ | ||
###flyd.map(s, fn) | ||
Returns a new stream consisting of every value from `s` passed through `fn. | ||
__Example__ | ||
```javascript | ||
var numbers = stream(0); | ||
var squaredNumbers = flyd.map(numbers, function(n) { return n*n; }); | ||
``` | ||
###flyd.reduce(s, fn, acc) | ||
Creates a new stream with the results of calling the function on every incoming | ||
stream with and accumulator and the incoming value. | ||
__Example__ | ||
```javascript | ||
var clicks = stream(); | ||
element.addEventListener(clicks); | ||
var nrOfClicks = flyd.reduce(clicks, function(sum) { return sum+1; }, 0); | ||
``` | ||
###flyd.merge(stream1, stream2) | ||
Creates a new stream down which all values from both `stream1` and `stream2` | ||
will be sent. | ||
__Example__ | ||
```javascript | ||
var btn1Clicks = stream(); | ||
button1Elm.addEventListener(clicks); | ||
var btn2Clicks = stream(); | ||
button2Elm.addEventListener(clicks); | ||
var allClicks = flyd.merge(btn1Clicks, btn2Clicks); | ||
``` | ||
### flyd.transduce(stream, transducer) | ||
Creates a new stream resulting from applying `transducer` to `stream`. | ||
__Example__ | ||
```javascript | ||
``` | ||
###stream() | ||
@@ -225,2 +280,10 @@ | ||
__Example__ | ||
```javascript | ||
var names = stream('Turing'); | ||
names(); // 'Turing' | ||
names('Bohr'); | ||
names(); // 'Bohr' | ||
``` | ||
###stream(val) | ||
@@ -241,16 +304,1 @@ | ||
functions from `stream1` to the values in `stream2`. | ||
###flyd.reduce(s, fn, acc) | ||
Creates a new stream with the results of calling the function on every incoming | ||
stream with and accumulator and the incoming value. | ||
###flyd.merge(stream1, stream2) | ||
Creates a new stream down which all values from both `stream1` and `stream2` | ||
will be sent. | ||
### flyd.transduce(stream, transducer) | ||
Creates a new stream resulting from applying `transducer` to `stream`. | ||
46100
299