# @mangar2/configuration

> Sanitizes configurations

Latest version **1.2.0** (published 2020-12-09) · LGPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @mangar2/configuration
pnpm add @mangar2/configuration
yarn add @mangar2/configuration
bun add @mangar2/configuration
```

## 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 | 1.2.0 |
| Published | 2020-12-09 |
| First published | 2020-01-18 |
| Weekly downloads | 0 |
| License | LGPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Volker Böhm |
| Maintainers | mangar2 |
| Keywords | config, NODE_ENV |

## Links

- npm: https://www.npmjs.com/package/@mangar2/configuration
- Repository: https://github.com/Mangar2/yaha/tree/master/node_modules/@mangar2/configuration
- Homepage: https://github.com/Mangar2/yaha.git
- npm.io page: https://npm.io/package/@mangar2/configuration

## Dependencies (2)

- [@mangar2/types](https://npm.io/package/@mangar2/types.md) latest
- [@mangar2/checkinput](https://npm.io/package/@mangar2/checkinput.md) latest

## 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

- 1.2.0 (latest) — 2020-12-09
- 1.1.3 — 2020-01-19
- 1.1.2 — 2020-01-18

## README

<!-- This file is generated by jsmddoc version 0.1 -->

# Abstract

Provides a function to sanitize configuration file input and to provide default values

## Contents

- [Meta](#Meta)
- [Global Functions](#Global-functions)
  - [sanitize](#sanitize)

## Meta

| | |
| --- | --- |
| **File** | configuration.js |
| **Abstract** | Provides a function to sanitize configuration file input and to provide default values |
| **Author** | Volker Böhm |
| **Copyright** | Copyright ( c ) 2020 Volker Böhm |
| **License** | This software is licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 . It is furnished "as is" , without any support , and with no warranty , express or implied , as to its usefulness for any purpose . |

## Global functions

### sanitize

`sanitize (configuration, defaultValues, checkInput) => {Object}`

Sanitizes configuration input and merges it with default values , if not provided in configuration

#### Example

```javascript
const configuration = { one: 'one', two: 'not two' }
const defaultValues = { two: 'two', three: 3 }
const checkInput = new CheckInput({
    type: 'object',
    properties: {
        one: { type: 'string' },
        two: { type: 'string' },
        three: { type: 'number' }
    },
    required: ['one', 'two', 'trhee']
})
configuration = sanitize(configuration, defaultValues, checkInput)
// configuration is now { one: 'one', two: 'not two', three: 3 }
```

#### sanitize Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `configuration` | `Object` | provided configuration ( from configuration file ) , the function changes this object directly , you may ignore the return value | |
| `defaultValues` | `Object` | configuration subset with default values | |
| `checkInput` | `CheckInput` | check function to sanitize the configuration . Please set all attributes as mandatory , they get optional by providing default values | |

#### sanitize returns

| Type | Description |
| ---- | ----------- |
| `Object` | merged configuration in provided configuration object |

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