seniority
Guides

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.

flagenvconfigpackage.jsondefaultwins
set····flag
setset···flag
set·set··flag
setsetset··flag
set··set·flag
setset·set·flag
set·setset·flag
setsetsetset·flag
set···setflag
setset··setflag
set·set·setflag
setsetset·setflag
set··setsetflag
setset·setsetflag
set·setsetsetflag
setsetsetsetsetflag
·set···env
·setset··env
·set·set·env
·setsetset·env
·set··setenv
·setset·setenv
·set·setsetenv
·setsetsetsetenv
··set··config
··setset·config
··set·setconfig
··setsetsetconfig
···set·package.json
···setsetpackage.json
····setdefault
·····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.