Skip to content

Commit fae43e6

Browse files
authored
Merge pull request #104 from CacheControl/maintenance
Maintenance
2 parents 28a5c8e + 27e62cf commit fae43e6

33 files changed

+4101
-8508
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ npm-debug.log
33
.vscode
44
.idea
55
.DS_Store
6-
dist
6+
dist
7+
*.tgz

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
src/
22
.travis.yml
33
.gitignore
4+
test/
5+
examples/
6+
docs/

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: node_js
22
node_js:
3-
- 4.2
3+
- 8
44
script:
55
- npm test

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
44
[![Build Status](https://travis-ci.org/CacheControl/json-rules-engine.svg?branch=master)](https://travis-ci.org/CacheControl/json-rules-engine)
55
[![npm version](https://badge.fury.io/js/json-rules-engine.svg)](https://badge.fury.io/js/json-rules-engine)
6+
[![install size](https://packagephobia.now.sh/badge?p=json-rules-engine)](https://packagephobia.now.sh/result?p=json-rules-engine)
67

78
A rules engine expressed in JSON
89

examples/02-nested-boolean-logic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ engine.addRule({
4444
}]
4545
}]
4646
},
47-
event: { // define the event to fire when the conditions evaluate truthy
47+
event: { // define the event to fire when the conditions evaluate truthy
4848
type: 'fouledOut',
4949
params: {
5050
message: 'Player has fouled out!'

examples/04-fact-dependency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ engine.addFact('employee-tenure', (params, almanac) => {
110110
// define fact(s) known at runtime
111111
facts = { accountId: 'washington' }
112112
engine
113-
.run(facts) // first run, using washington's facts
113+
.run(facts) // first run, using washington's facts
114114
.then(() => {
115115
facts = { accountId: 'jefferson' }
116116
return engine.run(facts) // second run, using jefferson's facts; facts & evaluation are independent of the first run

examples/05-optimizing-runtime-with-fact-priorities.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ engine.addFact('account-information', (params, almanac) => {
6767
// this fact will not be evaluated, because the "date" fact will fail first
6868
console.log('Checking the "account-information" fact...') // this message will not appear
6969
return almanac.factValue('accountId')
70-
.then((accountId) => {
71-
return accountClient.getAccountInformation(accountId)
72-
})
70+
.then((accountId) => {
71+
return accountClient.getAccountInformation(accountId)
72+
})
7373
}, { priority: LOW })
7474

7575
/**

examples/06-custom-operators.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ facts = {
9191
word: 'bacon'
9292
}
9393
engine
94-
.run(facts) // first run, using 'bacon'
94+
.run(facts) // first run, using 'bacon'
9595
.then(() => {
9696
facts = {
9797
word: 'antelope'

examples/07-rule-chaining.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ engine
8282
// define fact(s) known at runtime
8383
facts = { accountId: 'washington', drinksOrangeJuice: true, enjoysVodka: true, isSociable: true }
8484
engine
85-
.run(facts) // first run, using washington's facts
85+
.run(facts) // first run, using washington's facts
8686
.then(() => {
8787
facts = { accountId: 'jefferson', drinksOrangeJuice: true, enjoysVodka: false, isSociable: true }
8888
return engine.run(facts) // second run, using jefferson's facts; facts & evaluation are independent of the first run

examples/08-fact-comparison.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let rule = {
3333
accountType: 'customer'
3434
},
3535

36-
operator: 'greaterThanInclusive', // >=
36+
operator: 'greaterThanInclusive', // >=
3737

3838
// "value" in this instance is an object containing a fact definition
3939
// fact helpers "path" and "params" are supported here as well
@@ -115,7 +115,7 @@ let userFacts = {
115115
facts = Object.assign({}, userFacts, productList)
116116

117117
engine
118-
.run(facts) // first run, user can afford a gift card
118+
.run(facts) // first run, user can afford a gift card
119119
.then(() => {
120120
// second run; a user that cannot afford a gift card
121121
userFacts = {

examples/09-rule-results.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ engine.addRule({
3030
value: 3.5
3131
}]
3232
},
33-
event: { // define the event to fire when the conditions evaluate truthy
33+
event: { // define the event to fire when the conditions evaluate truthy
3434
type: 'honor-roll',
3535
params: {
3636
message: 'Student made the athletics honor-roll'
@@ -45,14 +45,14 @@ function render (message, ruleResult) {
4545
}
4646
// if rule failed, iterate over each failed condition to determine why the student didn't qualify for athletics honor roll
4747
let detail = ruleResult.conditions.all.filter(condition => !condition.result)
48-
.map(condition => {
49-
switch (condition.operator) {
50-
case 'equal':
51-
return `was not an ${condition.fact}`
52-
case 'greaterThanInclusive':
53-
return `${condition.fact} of ${condition.factResult} was too low`
54-
}
55-
}).join(' and ')
48+
.map(condition => {
49+
switch (condition.operator) {
50+
case 'equal':
51+
return `was not an ${condition.fact}`
52+
case 'greaterThanInclusive':
53+
return `${condition.fact} of ${condition.factResult} was too low`
54+
}
55+
}).join(' and ')
5656
console.log(`${message} ${detail}`.red)
5757
}
5858

0 commit comments

Comments
 (0)