joetjen.net
EN DE
← All libraries
JavaScript

node-cooper

Loads CASC config files into native JavaScript values — the Node.js port of Cooper, reading the same files to the same structure.

Intention

A configuration language is only portable if every implementation agrees on what a file means. This port follows the reference grammar rule for rule, with a hand-written lexer and parser and no runtime dependencies, and is held to the same conformance cases as the Elixir original. Where JavaScript cannot say what CASC says — a tuple, a duration, a secret — it gets a small value class rather than an approximation.

Example
import { loadFile } from '@joetjen/cooper';

const config = await loadFile('config.casc', { env: { DB_PASSWORD: 'hunter2' } });

config.database.password;                 // [~~REDACTED~~]
config.database.password.reveal();        // 'hunter2'
config.database.timeout.toMilliseconds(); // 500
Install
npm install @joetjen/cooper
Node.jsConfigurationCASC