ts-options-defaults
Options-defaults design pattern implementation for reliable configuration. It merges objects deeply, overrides arrays and classes (different than Object) and the result remains strongly typed.
Table of contents
Getting Started
npm i ts-options-defaults
Usage
Design pattern
;
Behavior
; ; ; ; options.console.log`log`; // "Call from TestLogger"options.console.debug`debug`; // "debug" // options will be: // someDefaults will not be mutated!
Features
Beats alternatives - better alternative to {...defaults, ...options}
destructing and lodash _.defaults
or _.merge
Secure - immune to prototype pollution attack
Simple - just 40 lines of clean TypeScript code
Strongly typed - result remains strongly typed