Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reactive-function

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactive-function - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

.travis.yml

4

index.js

@@ -42,3 +42,3 @@ var ReactiveProperty = require("reactive-property");

// The returned reactive function acts as a getter (not a setter).
// The returned object.
var reactiveFunction = {};

@@ -107,3 +107,3 @@

graph
.topologicalSort(Object.keys(changedNodes))
.topologicalSort(Object.keys(changedNodes), false)
.map(function (id){

@@ -110,0 +110,0 @@ return properties[id];

{
"name": "reactive-function",
"version": "0.4.0",
"version": "0.5.0",
"description": "A library for managing data flows and changing state.",

@@ -33,3 +33,3 @@ "main": "index.js",

"dependencies": {
"graph-data-structure": "^0.1.0",
"graph-data-structure": "^0.5.0",
"reactive-property": "^0.7.0"

@@ -36,0 +36,0 @@ },

@@ -1,2 +0,5 @@

# reactive-function
# reactive-function [![Build Status](https://travis-ci.org/curran/reactive-function.svg?branch=master)](https://travis-ci.org/curran/reactive-function)
[![NPM](https://nodei.co/npm/reactive-function.png)](https://npmjs.org/package/reactive-function)
A library for managing data flows and changing state.

@@ -48,5 +51,5 @@

inputs: [firstName, lastName],
output: lastName,
output: fullName,
callback: function (first, last){
return first + " " last;
return first + " " + last;
}

@@ -53,0 +56,0 @@ });

@@ -14,12 +14,12 @@ // Unit tests for reactive-function.

var a = ReactiveProperty(5);
var b = ReactiveProperty(10);
var firstName = ReactiveProperty("Jane");
var lastName = ReactiveProperty("Smith");
var c = ReactiveProperty();
var fullName = ReactiveProperty();
ReactiveFunction({
inputs: [a, b],
output: c,
callback: function (a, b){
return a + b;
inputs: [firstName, lastName],
output: fullName,
callback: function (first, last){
return first + " " + last;
}

@@ -29,3 +29,11 @@ });

ReactiveFunction.digest();
assert.equal(c(), 15);
assert.equal(fullName(), "Jane Smith");
firstName("John");
ReactiveFunction.digest();
assert.equal(fullName(), "John Smith");
lastName("Lennon");
ReactiveFunction.digest();
assert.equal(fullName(), "John Lennon");
});

@@ -139,25 +147,9 @@

ReactiveFunction.digest();
assert.equal(e(), ((a() * 2) + 5) + (a() * 3));
a(10);
ReactiveFunction.digest();
assert.equal(e(), ((a() * 2) + 5) + (a() * 3));
});
// Not sure if this is really necessary.
// It would be a nice safeguard but would clutter the code.
//it("Should throw an error if attempting to set the value directly.", function () {
// var a = ReactiveProperty(5);
// var b = ReactiveProperty();
// ReactiveFunction({
// inputs: [a],
// output: b,
// callback: function (a){
// return a * 2;
// }
// });
// assert.throws(function (){
// b(5);
// });
//});
it("Should clear changed nodes on digest.", function () {

@@ -339,2 +331,53 @@ var numInvocations = 0;

it("Should compute Ohm's Law.", function (){
// These symbols are used in the definition of Ohm's law.
// See https://en.wikipedia.org/wiki/Ohm%27s_law
var I = ReactiveProperty();
var V = ReactiveProperty();
var R = ReactiveProperty();
// I = V / R
ReactiveFunction({
inputs: [V, R],
output: I,
callback: function (v, r){ return v / r; }
});
// V = I * R
ReactiveFunction({
inputs: [I, R],
output: V,
callback: function (i, r){ return i * r; }
});
// R = V / I
ReactiveFunction({
inputs: [V, I],
output: R,
callback: function (v, i){ return v / i; }
});
V(9)
I(2)
ReactiveFunction.digest();
assert.equal(R(), 4.5);
R(6)
I(2)
ReactiveFunction.digest();
assert.equal(V(), 12);
V(9);
R(18);
ReactiveFunction.digest();
assert.equal(I(), 0.5);
V(9)
I(2)
ReactiveFunction.digest();
assert.equal(R(), 4.5);
});
it("Should remove the 'evaluate' function from the output on destroy.", function (){

@@ -341,0 +384,0 @@ var a = ReactiveProperty(5);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc