json-logic-js
Advanced tools
Comparing version 1.2.3 to 2.0.0
@@ -173,6 +173,2 @@ /* globals define,module */ | ||
}, | ||
"method": function(obj, method, args) { | ||
return obj[method].apply(obj, args); | ||
}, | ||
}; | ||
@@ -179,0 +175,0 @@ |
{ | ||
"name": "json-logic-js", | ||
"version": "1.2.3", | ||
"version": "2.0.0", | ||
"description": "Build complex rules, serialize them as JSON, and execute them in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "logic.js", |
@@ -207,36 +207,2 @@ var jsonLogic = require("../logic.js"); | ||
QUnit.test( "Expanding functionality with method", function( assert) { | ||
// Data contains a real object with methods and local state | ||
var a = { | ||
count: 0, | ||
increment: function() { | ||
return this.count += 1; | ||
}, | ||
add: function(b) { | ||
return this.count += b; | ||
}, | ||
}; | ||
// Look up "a" in data, and run the increment method on it with no args. | ||
assert.equal( | ||
jsonLogic.apply( | ||
{"method": [{"var": "a"}, "increment"]}, | ||
{"a": a} | ||
), | ||
1 // Happy return value | ||
); | ||
assert.equal(a.count, 1); // Happy state change | ||
// Run the add method with an argument | ||
assert.equal( | ||
jsonLogic.apply( | ||
{"method": [{"var": "a"}, "add", [41]]}, | ||
{"a": a} | ||
), | ||
42 // Happy return value | ||
); | ||
assert.equal(a.count, 42); // Happy state change | ||
}); | ||
QUnit.test("Control structures don't eval depth-first", function(assert) { | ||
@@ -243,0 +209,0 @@ // Depth-first recursion was wasteful but not harmful until we added custom operations that could have side-effects. |
Sorry, the diff of this file is not supported yet
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
282373
21
792