# deprecated-obj

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

Latest version **2.0.0** (published 2020-08-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install deprecated-obj
pnpm add deprecated-obj
yarn add deprecated-obj
bun add deprecated-obj
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2020-08-18 |
| First published | 2019-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Lars Kappert |
| Maintainers | webpro |
| Keywords | deprecate, deprecated, configuration |

## Links

- npm: https://www.npmjs.com/package/deprecated-obj
- Repository: https://github.com/webpro/deprecated-obj
- Homepage: https://github.com/webpro/deprecated-obj#readme
- Issues: https://github.com/webpro/deprecated-obj/issues
- npm.io page: https://npm.io/package/deprecated-obj

## Dependencies (2)

- [flat](https://npm.io/package/flat.md) ^5.0.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.20

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2020-08-18
- 1.0.1 — 2019-05-28
- 1.0.0 — 2019-01-03

## README

# deprecated-obj

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

## Usage

```js
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()`

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

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

### `Deprecation::getViolations()`

```js
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:

```js
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](https://github.com/webpro/release-it/blob/master/lib/deprecated.js) for a real-world example.

---
_Source: https://npm.io/package/deprecated-obj · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
