11
11
*/
12
12
13
13
require ( 'colors' )
14
- let Engine = require ( '../dist' ) . Engine
14
+ const Engine = require ( '../dist' ) . Engine
15
15
16
16
/**
17
17
* Setup a new engine
18
18
*/
19
- let engine = new Engine ( )
19
+ const engine = new Engine ( )
20
20
21
21
/**
22
22
* Rule for determining if account has enough money to purchase a $50 gift card product
23
23
*
24
24
* customer-account-balance >= $50 gift card
25
25
*/
26
- let rule = {
26
+ const rule = {
27
27
conditions : {
28
28
all : [ {
29
29
// extract 'balance' from the 'customer' account type
@@ -55,7 +55,7 @@ engine.addFact('account', (params, almanac) => {
55
55
return almanac . factValue ( 'accounts' )
56
56
. then ( accounts => {
57
57
// use "params" to filter down to the type specified, in this case the "customer" account
58
- let customerAccount = accounts . filter ( account => account . type === params . accountType )
58
+ const customerAccount = accounts . filter ( account => account . type === params . accountType )
59
59
// return the customerAccount object, which "path" will use to pull the "balance" property
60
60
return customerAccount [ 0 ]
61
61
} )
@@ -66,7 +66,7 @@ engine.addFact('product', (params, almanac) => {
66
66
return almanac . factValue ( 'products' )
67
67
. then ( products => {
68
68
// use "params" to filter down to the product specified, in this case the "giftCard" product
69
- let product = products . filter ( product => product . productId === params . productId )
69
+ const product = products . filter ( product => product . productId === params . productId )
70
70
// return the product object, which "path" will use to pull the "price" property
71
71
return product [ 0 ]
72
72
} )
85
85
} )
86
86
87
87
// define fact(s) known at runtime
88
- let productList = {
88
+ const productList = {
89
89
products : [
90
90
{
91
91
productId : 'giftCard' ,
0 commit comments