2018-08-16 08:05:00 +00:00
|
|
|
// This file exports the functions of the public computing library
|
|
|
|
import { analyseMany, parseAll } from './traverse.js'
|
|
|
|
import { rulesFr, collectDefaults, nestedSituationToPathMap } from './rules'
|
2018-08-15 09:39:10 +00:00
|
|
|
|
2018-08-16 08:05:00 +00:00
|
|
|
let parsedRules = parseAll(rulesFr)
|
|
|
|
|
|
|
|
// The public evaluation function takes a nested object of input values
|
|
|
|
let nestedSituationToStateSelector = nestedSituation => dottedName =>
|
|
|
|
({
|
|
|
|
...collectDefaults(rulesFr),
|
|
|
|
...nestedSituationToPathMap(nestedSituation)
|
|
|
|
}[dottedName])
|
|
|
|
|
|
|
|
export default (targetNames, nestedSituation) =>
|
|
|
|
analyseMany(parsedRules, targetNames)(
|
|
|
|
nestedSituationToStateSelector(nestedSituation)
|
|
|
|
)
|