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

ConstraintNetwork

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ConstraintNetwork - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

10

ConstraintNetwork.js
this.ConstraintNetwork = (function() {
this.ConstraintNetwork = (function(cn) {
var i = 0;

@@ -74,3 +74,3 @@ function Constraint(inputs, outputs, transform, name) {

function equationToConstraints(equation) {
var parseTree = parseEquation(equation);
var parseTree = cn.Equation.parse(equation);
var expr = parseTree.expression;

@@ -100,8 +100,4 @@ var output = parseTree.output.name;

return ConstraintNetwork;
})();
})(this);
this.Equation = {
};
this.Equation = (function() {

@@ -108,0 +104,0 @@ try {

@@ -6,2 +6,3 @@ var should =require("should");

var eq_tests = {
//Equation, output variable, input variables, right hand side
"a = 0": ["a", [], new cn.Equation.Literal(0)],

@@ -17,6 +18,5 @@ "a = b": ["a", ["b"], new cn.Equation.Lookup("b")],

for (var key in eq_tests) {
(function(key, value) {
exports["test " + key] = function() {
exports["test equation " + key] = function() {
var eq = cn.Equation.parse(key);

@@ -29,1 +29,21 @@ eq.output.should.eql(new cn.Equation.Lookup(value[0]));

}
var eq_network_tests = [
//Name, equations, input, expected output
["no equations", [], {p: "q"}, {p: "q"}],
["just output", ["a=0"], {}, {a: 0}],
["input is output", ["a=b"], {b: 10}, {a:10, b:10}],
["transitive property", ["a=b", "b=c"], {c:10}, {a:10,b:10,c:10}],
["solve for some", ["a=b+5","b=12","c=d * 20"], {}, {a:17,b:12}]
]
for (var i = 0; i < eq_network_tests.length; i++) {
var t = eq_network_tests[i];
(function(name, equations, initial_mappings, expected_output_mappings) {
exports["test equation network " + name] = function() {
var network = cn.ConstraintNetwork.fromEquations(equations);
var result = network.solve(initial_mappings);
result.should.eql(expected_output_mappings);
}
})(t[0], t[1], t[2], t[3]);
}

@@ -5,3 +5,3 @@ {

"description": "A constraint network library (think spreadsheet-style logic)",
"version": "0.0.0",
"version": "0.1.0",
"repository": {

@@ -8,0 +8,0 @@ "url": ""

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