Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Ambitious data-flow library.
Install the module with: npm install menrva
var menrva = require('menrva');
menrva.some('awe'); // some, as in awesome?
The core type of menrva. Signal
is abstract class, and cannot be created explicitly.
Similar concepts are: Behaviours in FRP, Properties in bacon.js.
You can add methods to Signal
's prototype. They will be available on all signals.
map (@ : Signal a, f : a -> b, eq = egal : b -> b -> boolean) : Signal b
onValue (@ : Signal a, callback : a -> void) -> Unsubscriber
Add value callback. callback
is immediately executed with the current value of signal.
After than callback
will be called, each time signal's value changes.
The return value is a function, which will remove the callback if executed.
A signal which value you can set.
Similar concepts are: Bacon.Model in bacon.js, BehaviourSubject in Rx.
source (initialValue : a, eq = egal : a -> a -> boolean) : Source a
set (@ : Source a, tx : Transaction, value : a) : void
modify (@ : Source a, tx : Transaction, f : a -> a) : void
Mofify source value. f
will be called with current value of signal inside the transaction.
combine (Signal a..., f : a... -> b) : Signal b
Applicative n-ary lift. Lift pure function to operate on signals:
var $sum = menrva.combine($a, $b, function (a, b) {
return a + b;
});
One gathers atomic updates into single transaction (to avoid glitches).
var tx = menrva.transaction();
sourceA.set(tx, 42);
sourceB.modify(tx, function (x) { return x + x; });
tx.commit(); // not necessary, transactions are auto-commited
There are also optional syntaxes for simple transactions:
menrva.transaction()
.set(sourceA, 42)
.modify(sourceB, function (x) { return x + x; })
.commit();
or even
menrva.transaction([sourceA, 42, sourceB, function(x) { return x + x; }]).commit();
transaction (facts) : Transaction
Create transaction.
Shorthand syntax:
transaction ([sourceA, valueA, sourceB, valueB ...]) : Transaction
If value
is function, source.modify(tx, value)
is called; otherwise source.set(tx, value)
.
Commit the transaction, forcing synchronous data propagation.
Rollback the transaction. Maybe be called multiple times (consecutives calls are no-op).
Note: for now rollback
only resets the pending actions in transactions. Transaction is still valid, and more actions can be added
Lenses are composable functional references. They allow you to access and modify data potentially very deep within a structure!
zoom (@ : Source a, path : Path a b, eq = egal : b -> b -> boolean) : Source b
Zoom (or focus) into part specified by path
of the original signal.
One can set
and modify
zoomed signals, they act as sources.
var quux = source.zoom("foo.bar.quux");
signal.log (@ : Signal a, args...) : Unsubscriber
Essentially `signal.onValue(console.log.bind(console, args...))
signal.onSpread (@ : Signal [a, b...], callback : a -> b ... -> void) : Unsubscriber
onValue
with signal's tuple arguments spread.
tuple (x : Signal a, y : Signal b...) : Signal [a, b...]
Combine signals into tuple.
egal (a, b) : boolean
Identity check. Object.is
. http://wiki.ecmascript.org/doku.php?id=harmony:egal
Also known as Maybe
.
equals (@ : option a, other : *, eq = eqal : a -> a -> boolean) : boolean
Equality check.
map (@ : option a, f : a -> b) : option b
elim (@ : option a, x : b, f : a -> b) : b
orElse (@ : option a, x : a) : a
In lieu of a formal styleguide, take care to maintain the existing coding style.
Add tests for any new or changed functionality. 100% coverage isn't hard. Semantic coverage is important too though.
Note: README.md
is autogenerated file.
Copyright (c) 2014 Oleg Grenrus. Licensed under the MIT license.
FAQs
Ambitious data-flow library
The npm package menrva receives a total of 0 weekly downloads. As such, menrva popularity was classified as not popular.
We found that menrva demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.