Comparing version 0.1.3 to 0.1.4
@@ -29,3 +29,3 @@ (function (root, factory) { | ||
function map(s, f) { | ||
return stream([s], function() { return f(s()); }); | ||
return stream([s], function(self) { self(f(s())); }); | ||
} | ||
@@ -32,0 +32,0 @@ |
{ | ||
"name": "flyd", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "The less is more, modular, functional reactive programming library", | ||
@@ -5,0 +5,0 @@ "main": "flyd.js", |
@@ -1,6 +0,8 @@ | ||
[![Build Status](https://travis-ci.org/paldepind/flyd.svg?branch=master)](https://travis-ci.org/paldepind/flyd) | ||
# Flyd | ||
# Flyd | ||
The modular, KISS, functional reactive programming library for JavaScript. | ||
[![Build Status](https://travis-ci.org/paldepind/flyd.svg?branch=master)](https://travis-ci.org/paldepind/flyd) | ||
[![Join the chat at https://gitter.im/paldepind/flyd](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/paldepind/flyd?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
# Table of contents | ||
@@ -27,5 +29,5 @@ | ||
* __Simple and powerful__. Less is more! Flyd provides combineable observable | ||
* __Simple but powerful__. Less is more! Flyd provides combineable observable | ||
streams as the basic building block. This minimal core is less than 200 SLOC | ||
and FRP abstractions can easily be built on top of it. | ||
and FRP abstractions can concisely be built on top of it. | ||
* __A more functional style__. Flyd is more functional and less object oriented. | ||
@@ -36,15 +38,15 @@ Instead of methods it gives you curried functions with arguments in the | ||
* Supports the transducer protocol. You can for instance transduce streams with | ||
[Ramda](http://ramdajs.com/). | ||
[Ramda](http://ramdajs.com/) and [transducers.js](https://github.com/jlongster/transducers.js). | ||
* Complies to the [fantasy land](https://github.com/fantasyland/fantasy-land) | ||
applicative specification. | ||
* Elegant support for promises. | ||
* [Atomic updates](#atomic-updates) | ||
* Easy to extend with custom [modules](#modules) | ||
* [Atomic updates](#atomic-updates). | ||
* Easy to extend with custom [modules](#modules). | ||
## Examples | ||
* [Sum](http://paldepind.github.io/flyd/examples/sum/) - very simple example | ||
* [Multiple clicks](http://paldepind.github.io/flyd/examples/multiple-clicks/) - a remake | ||
* [Sum](http://paldepind.github.io/flyd/examples/sum/) - A very simple example | ||
* [Multiple clicks](http://paldepind.github.io/flyd/examples/multiple-clicks/) - A remake | ||
of the multiple clicks example from "The introduction to Reactive | ||
Programming you've been missing". Compare it to the not quite as elegant [Rx | ||
Programming you've been missing". Compare it to the [RxJs | ||
implementation](http://jsfiddle.net/staltz/4gGgs/27/). | ||
@@ -643,4 +645,3 @@ * [Secret combination](http://paldepind.github.io/flyd/examples/secret-combination/) | ||
Flyd should work in all JavaScript environments. Some of its modules may however | ||
assume ECMAScript 4. | ||
Flyd works in all ECMAScript 5 environments. It works in older environments | ||
with polyfills for `Array.prototype.filter` and `Array.prototype.map`. |
@@ -328,2 +328,12 @@ var assert = require('assert'); | ||
}); | ||
it('handles function returning undefined', function() { | ||
var x = stream(1); | ||
var maybeDoubleX = flyd.map(function(x) { | ||
return x > 3 ? 2*x : undefined; | ||
}, x); | ||
assert.equal(undefined, maybeDoubleX()); | ||
assert.equal(true, maybeDoubleX.hasVal); | ||
x(4); | ||
assert.equal(8, maybeDoubleX()); | ||
}); | ||
it('is curried', function() { | ||
@@ -330,0 +340,0 @@ var x = stream(3); |
108712
1991
645