reactive-function
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -36,5 +36,8 @@ var ReactiveProperty = require("reactive-property"); | ||
// TODO check for wrong number of args | ||
// Parse arguments. | ||
var dependencies = Array.apply(null, arguments); | ||
var callback = dependencies.pop(); | ||
var args = Array.apply(null, arguments); | ||
var dependencies = args.splice(1); | ||
var callback = args[0]; | ||
@@ -41,0 +44,0 @@ // This stores the output value. |
{ | ||
"name": "reactive-function", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A library for managing data flows and changing state.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
62
test.js
@@ -15,5 +15,7 @@ // Unit tests for reactive-function. | ||
var b = ReactiveProperty(10); | ||
var c = ReactiveFunction(a, b, function (a, b){ | ||
var c = ReactiveFunction(function (a, b){ | ||
return a + b; | ||
}); | ||
}, a, b); | ||
ReactiveFunction.digest(); | ||
@@ -28,5 +30,10 @@ assert.equal(c(), 15); | ||
var d = ReactiveFunction(a, function (a){ return a * 2; }); | ||
var e = ReactiveFunction(a, b, c, function (a, b, c){ return a + b + c; }); | ||
var d = ReactiveFunction(function (a){ | ||
return a * 2; | ||
}, a); | ||
var e = ReactiveFunction(function (a, b, c){ | ||
return a + b + c; | ||
}, a, b, c); | ||
ReactiveFunction.digest(); | ||
@@ -40,4 +47,11 @@ | ||
var a = ReactiveProperty(5); | ||
var b = ReactiveFunction(a, function (a){ return a * 2; }); | ||
var c = ReactiveFunction(b, function (b){ return b / 2; }); | ||
var b = ReactiveFunction(function (a){ | ||
return a * 2; | ||
}, a); | ||
var c = ReactiveFunction(function (b){ | ||
return b / 2; | ||
}, b); | ||
ReactiveFunction.digest(); | ||
@@ -50,4 +64,11 @@ assert.equal(c(), 5); | ||
var b = ReactiveProperty(10); | ||
var c = ReactiveFunction(a, function (a){ return a * 2; }); | ||
var d = ReactiveFunction(b, c, function (b, c){ return b + c; }); | ||
var c = ReactiveFunction(function (a){ | ||
return a * 2; | ||
}, a); | ||
var d = ReactiveFunction(function (b, c){ | ||
return b + c; | ||
}, b, c); | ||
ReactiveFunction.digest(); | ||
@@ -66,7 +87,10 @@ assert.equal(d(), 20); | ||
var a = ReactiveProperty(5); | ||
var b = ReactiveFunction(a, function (a){ return a * 2; }); | ||
var c = ReactiveFunction(b, function (b){ return b + 5; }); | ||
var d = ReactiveFunction(a, function (a){ return a * 3; }); | ||
var e = ReactiveFunction(c, d, function (c, d){ return c + d; }); | ||
var b = ReactiveFunction(function (a){ return a * 2; }, a); | ||
var c = ReactiveFunction(function (b){ return b + 5; }, b); | ||
var d = ReactiveFunction(function (a){ return a * 3; }, a); | ||
var e = ReactiveFunction(function (c, d){ return c + d; }, c, d); | ||
ReactiveFunction.digest(); | ||
assert.equal(e(), ((a() * 2) + 5) + (a() * 3)); | ||
@@ -77,3 +101,7 @@ }); | ||
var a = ReactiveProperty(5); | ||
var b = ReactiveFunction(a, function (a){ return a * 2; }); | ||
var b = ReactiveFunction(function (a){ | ||
return a * 2; | ||
}, a); | ||
assert.throws(function (){ | ||
@@ -87,6 +115,6 @@ b(5); | ||
var a = ReactiveProperty(5); | ||
var b = ReactiveFunction(a, function (a){ | ||
var b = ReactiveFunction(function (a){ | ||
numInvocations++; | ||
return a * 2; | ||
}); | ||
}, a); | ||
ReactiveFunction.digest(); | ||
@@ -101,5 +129,5 @@ ReactiveFunction.digest(); | ||
var c = ReactiveFunction(a, b, function (a, b){ | ||
var c = ReactiveFunction(function (a, b){ | ||
return a + b; | ||
}); | ||
}, a, b); | ||
@@ -106,0 +134,0 @@ setTimeout(function (){ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9074
209
0