MCPcopy
hub / github.com/CacheControl/json-rules-engine / addFact

Method addFact

src/engine.js:162–174  ·  view source on GitHub ↗

* Add a fact definition to the engine. Facts are called by rules as they are evaluated. * @param {object|Fact} id - fact identifier or instance of Fact * @param {function} definitionFunc - function to be called when computing the fact value for a given rule * @param {Object} options - opti

(id, valueOrMethod, options)

Source from the content-addressed store, hash-verified

160 * @param {Object} options - options to initialize the fact with. used when "id" is not a Fact instance
161 */
162 addFact (id, valueOrMethod, options) {
163 let factId = id
164 let fact
165 if (id instanceof Fact) {
166 factId = id.id
167 fact = id
168 } else {
169 fact = new Fact(id, valueOrMethod, options)
170 }
171 debug(`engine::addFact id:${factId}`)
172 this.facts.set(factId, fact)
173 return this
174 }
175
176 /**
177 * Remove a fact definition to the engine. Facts are called by rules as they are evaluated.

Callers 15

setupFunction · 0.95
startFunction · 0.95
startFunction · 0.95
startFunction · 0.95
startFunction · 0.95
startFunction · 0.95
index.test-d.tsFile · 0.45
engine-all.test.jsFile · 0.45
engine-run.test.jsFile · 0.45
engine.test.jsFile · 0.45
setupFunction · 0.45

Calls 1

debugFunction · 0.85

Tested by 11

setupFunction · 0.36
setupFunction · 0.36
setupFunction · 0.36
setupFunction · 0.36
setupFunction · 0.36
setupFunction · 0.36
setupFunction · 0.36
setupFunction · 0.36
setupFunction · 0.36
simpleSetupFunction · 0.36
advancedSetupFunction · 0.36