seniority
API reference

seniority/rc

Every export of seniority/rc, with its signature and doc comment: parse, rc, module.exports, rc, plus 3 types.

import rc from 'seniority/rc';
import { parse, rc, module.exports } from 'seniority/rc';

Functions

default

The default export, declared as rc.

rc, with its world as an argument.

defaults may be a string, which rc reads as a JSON document — cc.json — and that form is kept because it is how rc's own README tells you to pass a default config.

function rc(name: string, defaults?: RcConfig | string, argv?: RcConfig, parseWith?: RcParse, options?: RcOptions): RcConfig;
ParameterType
namestring
defaults (optional)RcConfig | string
argv (optional)RcConfig
parseWith (optional)RcParse
options (optional)RcOptions

Returns RcConfig

module.exports

rc, with its world as an argument.

defaults may be a string, which rc reads as a JSON document — cc.json — and that form is kept because it is how rc's own README tells you to pass a default config.

function rc(name: string, defaults?: RcConfig | string, argv?: RcConfig, parseWith?: RcParse, options?: RcOptions): RcConfig;
ParameterType
namestring
defaults (optional)RcConfig | string
argv (optional)RcConfig
parseWith (optional)RcParse
options (optional)RcOptions

Returns RcConfig

parse

rc's own cc.parse: a document starting with { is JSON — comments allowed — and anything else is INI, which this package does not bundle a parser for (constraint 3). The refusal names parse, rc's fourth parameter, so supplying ini.parse is one argument.

function parse(content: string): RcConfig;
ParameterType
contentstring

Returns RcConfig

rc

rc, with its world as an argument.

defaults may be a string, which rc reads as a JSON document — cc.json — and that form is kept because it is how rc's own README tells you to pass a default config.

function rc(name: string, defaults?: RcConfig | string, argv?: RcConfig, parseWith?: RcParse, options?: RcOptions): RcConfig;
ParameterType
namestring
defaults (optional)RcConfig | string
argv (optional)RcConfig
parseWith (optional)RcParse
options (optional)RcOptions

Returns RcConfig

Interfaces

RcOptions

The world, as an argument (R11). Every field has a default that touches no process: cwd resolves the empty path, home asks os, and env is empty — because guessing an environment is worse than not having one, which is the call seniority/dotenv already makes for processEnv.

interface RcOptions {
    /** The environment to read `<NAME>_*` from; the process's own when omitted, as rc does (D-135). */
    env?: Record<string, string | undefined>;
    /** Where the upward walk for `.<name>rc` starts. */
    cwd?: string;
    /** The home directory the four `~` places hang off. */
    home?: string;
    /** Skip the `/etc` places, as rc does on Windows. */
    win?: boolean;
}

Types

RcConfig

A parsed config document. rc places no shape on it, and neither does this.

type RcConfig = Record<string, unknown>;

RcParse

rc's fourth parameter: turn a file's text into an object.

type RcParse = (content: string) => RcConfig;

On this page