Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deprecated-obj

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deprecated-obj

Compares deprecations against a configuration object, and returns a compliant object and violations

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
79K
decreased by-13.3%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 18 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc