-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#96] Fix issues with module imports in Browser Environments
- Issue with module imports failing is fixed with this. - Polyfill Process.nextick issues fixed in browser context. - Added both web and node.js examples in examples folder. - Cleaned iup unwanted dependencies.
- Loading branch information
1 parent
f6dd06c
commit 831f0e9
Showing
13 changed files
with
563 additions
and
766 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/2.MultipleRules.js → examples/node.js/2.MultipleRules.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/3.CascadingRules.js → examples/node.js/3.CascadingRules.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/4.PrioritizedRules.js → examples/node.js/4.PrioritizedRules.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/5.RecurssionWithRules.js → examples/node.js/5.RecurssionWithRules.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/6.MoreRulesAndFacts.js → examples/node.js/6.MoreRulesAndFacts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Node Rules Web example</title> | ||
<script src="../../dist/node-rules.min.js"></script> | ||
</head> | ||
<body> | ||
|
||
<!-- | ||
==== READ THIS IF YOU ARE FINDING TROUBLE TO TO RUN THIS! ==== | ||
1. Install "Live Server" plugin on VS Code. | ||
2. Right click on this file in the sidebar of Vs Code. | ||
3. Choose open with Live Server option and bingo you are done. | ||
--> | ||
|
||
<script type="text/javascript"> | ||
|
||
/* Creating Rule Engine instance */ | ||
var R = new NodeRules(); | ||
|
||
/* Add a rule */ | ||
var rule = { | ||
"condition": function(R) { | ||
console.log(this); | ||
R.when(this.transactionTotal < 500); | ||
}, | ||
"consequence": function(R) { | ||
this.result = false; | ||
this.reason = "The transaction was blocked as it was less than 500"; | ||
R.stop(); | ||
} | ||
}; | ||
|
||
/* Register Rule */ | ||
R.register(rule); | ||
|
||
/* Add a Fact with less than 500 as transaction, and this should be blocked */ | ||
var fact = { | ||
"name": "user4", | ||
"application": "MOB2", | ||
"transactionTotal": 400, | ||
"cardType": "Credit Card" | ||
}; | ||
|
||
/* Check if the engine blocks it! */ | ||
R.execute(fact, function (data) { | ||
if (data.result) { | ||
console.log("Valid transaction"); | ||
} else { | ||
console.log("Blocked Reason:" + data.reason); | ||
} | ||
}); | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.