The truth table
Every combination of the 5 sources seniority reads, and which one wins: 32 rows generated from the exported TRUTH_TABLE, which is generated from ORDER, the array the resolver reads.
The order is flag > env > config > package.json > default: the first source that sets a value wins. The
table below is that sentence for every case, one row per combination of sources that set a
value. set means the source set one; · means it did not.
flag | env | config | package.json | default | wins |
|---|---|---|---|---|---|
| set | · | · | · | · | flag |
| set | set | · | · | · | flag |
| set | · | set | · | · | flag |
| set | set | set | · | · | flag |
| set | · | · | set | · | flag |
| set | set | · | set | · | flag |
| set | · | set | set | · | flag |
| set | set | set | set | · | flag |
| set | · | · | · | set | flag |
| set | set | · | · | set | flag |
| set | · | set | · | set | flag |
| set | set | set | · | set | flag |
| set | · | · | set | set | flag |
| set | set | · | set | set | flag |
| set | · | set | set | set | flag |
| set | set | set | set | set | flag |
| · | set | · | · | · | env |
| · | set | set | · | · | env |
| · | set | · | set | · | env |
| · | set | set | set | · | env |
| · | set | · | · | set | env |
| · | set | set | · | set | env |
| · | set | · | set | set | env |
| · | set | set | set | set | env |
| · | · | set | · | · | config |
| · | · | set | set | · | config |
| · | · | set | · | set | config |
| · | · | set | set | set | config |
| · | · | · | set | · | package.json |
| · | · | · | set | set | package.json |
| · | · | · | · | set | default |
| · | · | · | · | · | nothing: the option is unset |
The same rows are exported as data, so a program, a test or a page can read them:
import { TRUTH_TABLE } from 'seniority';
TRUTH_TABLE.find((row) => row.set.join() === 'env,config').winner; // 'env'TRUTH_TABLE is truthTable(ORDER), and ORDER is the array resolve reads. The repository holds both
to precedence-vectors.json, in seniority's suite and through a real burgee program, so a
change to the order has to change the vectors in the same diff.
A plugin source slots between two of these by rank and never reorders them; see
Plugins.
Precedence and --explain
resolve() applies one fixed order — flag, env, config, package.json, default — and records, for every value, the source that set it, the file line, and every candidate it beat, as text, --json data or an agent event.
Config files
discover() finds a config file in a fixed order, follows extends, and records each key's line; search() walks upward only when asked, bounded by stopAt, a depth limit and the root; loaders bring any format.