deprecated-obj
Simple utility to help making the transition from deprecated configuration objects to compliant ones.
Usage
const Deprecation = ; const myConfig = fine: true old: deprecated: true 'remove.me': 1; const deprecations = old: deprecated: 'new.shiny' 'remove.me': null; // Or flat:const deprecations = 'old.deprecated': 'new.shiny' 'remove.me': null ; const deprecation = deprecations myConfig;
API
Deprecation::getCompliant()
const myCompliant = deprecation;→ fine: true new: shiny: true
Returns a new, compliant object. The null
values in deprecations
are excluded.
Deprecation::getViolations()
const violations = deprecation;→ 'old.deprecated': 'new.shiny' 'remove.me': null
The violations can be used to inform the user about the deprecations, for example:
if Objectlength > 0 console;for let deprecated in violations console;
Example
See github.com/release-it/.../deprecated.js for a real-world example.