# 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.

Source: https://seniority.interlace.tools/docs/guides/truth-table

<!-- Generated by scripts/truth-table-page.ts from seniority's TRUTH_TABLE. Do not edit; run `npm run truth-table:page`. -->

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:

```js
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](/docs/guides/plugins).
