GitXplorerGitXplorer
w

deprecated-obj

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
623acd066fbf307a49f0f6b3968c608d814f9051

Release 1.0.1

wwebpro committed 6 years ago
Unverified
03c65945436da0ffb99f828ca4aca52f758e4a40

Update readme

wwebpro committed 6 years ago
Unverified
878edd7d5ce8e910a68e9dd008ae3500f0fc85e5

Never overwrite existing target prop

wwebpro committed 6 years ago
Unverified
e92cd58c53a99c20c4c0c5200f1aa088f7f099ee

Update readme

wwebpro committed 6 years ago
Unverified
4dbcaa2512b8114c77a8461795d739b6f4811432

Release 1.0.0

wwebpro committed 6 years ago
Unverified
009372631c4455c98eb7fb13ff80af938488527c

Initial commit

wwebpro committed 6 years ago

README

The README file for this repository.

deprecated-obj

Simple utility to help making the transition from deprecated configuration objects to compliant ones.

Usage

const Deprecation = require('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 = new Deprecation(deprecations, myConfig);

API

Deprecation::getCompliant()

const myCompliant = deprecation.getCompliant();
 { fine: true, new: { shiny: true } }

Returns a new, compliant object. The null values in deprecations are excluded.

Deprecation::getViolations()

const violations = deprecation.getViolations();
 { 'old.deprecated': 'new.shiny', 'remove.me': null }

The violations can be used to inform the user about the deprecations, for example:

if (Object.keys(violations).length > 0) {
  console.warn(`Deprecated configuration options found. Please migrate before the next major release.`);
}
for(let deprecated in violations) {
  console.warn(`The "${deprecated}" option is deprecated. Please use "${violations[deprecated]}" instead.`);
};

Example

See github.com/release-it/.../deprecated.js for a real-world example.