# defaulty

> Copies missing properties to the target object.

Latest version **2.1.0** (published 2018-01-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install defaulty
pnpm add defaulty
yarn add defaulty
bun add defaulty
```

## 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.1.0 |
| Published | 2018-01-07 |
| First published | 2017-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Fabio Ricali |
| Maintainers | fabioricali |
| Keywords | copy, clone, object, deep, defaults, config, extend, set, array, values, missing, properties |

## Links

- npm: https://www.npmjs.com/package/defaulty
- Repository: https://github.com/fabioricali/defaulty
- Homepage: https://github.com/fabioricali/defaulty#readme
- Issues: https://github.com/fabioricali/defaulty/issues
- npm.io page: https://npm.io/package/defaulty

## Dependencies (1)

- [deep-copy](https://npm.io/package/deep-copy.md) ^1.4.1

## 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.1.0 (latest) — 2018-01-07
- 2.0.0 — 2017-12-09
- 1.2.2 — 2017-11-04
- 1.2.1 — 2017-08-26
- 1.1.0 — 2017-08-20
- 1.0.3 — 2017-08-20
- 1.0.2 — 2017-08-11
- 1.0.1 — 2017-08-11

## README

<div align="center">
<h1>defaulty</h1>
Copies deep missing properties to the target object.
<br/><br/>
<a href="https://travis-ci.org/fabioricali/defaulty" target="_blank"><img src="https://travis-ci.org/fabioricali/defaulty.svg?branch=master" title="Build Status"/></a>
<a href="https://coveralls.io/github/fabioricali/defaulty?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/fabioricali/defaulty/badge.svg?branch=master&1" title="Coverage Status"/></a>
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" title="License: MIT"/></a>
<img src="https://img.shields.io/badge/team-terrons-orange.svg" title="Team Terrons"/>
</div>

## Installation

### Node.js
```
npm install defaulty --save
```

## Example

```javascript
const defaulty = require('defaulty');

const defaultObj = {a: 1, b: 2, c: 3, d: {a: 5, b: 2}};
let targetObj = {a: 4, b: 5, d: {a: 1}};

defaulty(targetObj, defaultObj);

console.log(targetObj); //=> {a: 4, b: 5, c: 3, d: {a: 1, b: 2}};
```

### Exclude default properties
```javascript
const defaultObj = {a: 1, b: 2, c: 3, d: {a: 5, b: 2}, x: 1, y: 2};
let targetObj = {a: 4, b: 5, d: {a: 1}};

defaulty(targetObj, defaultObj, ['x', 'y']);

console.log(targetObj); //=> {a: 4, b: 5, c: 3, d: {a: 1, b: 2}};
```

### Copy target object
```javascript
const defaultObj = {a: 1, b: 2, c: 3, d: {a: 5, b: 2}};
const targetObj = {a: 4, b: 5, d: {a: 1}};

const newTargetObject = defaulty.copy(targetObj, defaultObj);

console.log(newTargetObject); //=> {a: 4, b: 5, c: 3, d: {a: 1, b: 2}};
console.log(targetObj); //=> {a: 4, b: 5, d: {a: 1}};
```

## Changelog
You can view the changelog <a target="_blank" href="https://github.com/fabioricali/defaulty/blob/master/CHANGELOG.md">here</a>

## License
Defaulty is open-sourced software licensed under the <a target="_blank" href="http://opensource.org/licenses/MIT">MIT license</a>

## Author
<a target="_blank" href="http://rica.li">Fabio Ricali</a>

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