Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/firstandthird/aug

A javascript augment/extend library
https://github.com/firstandthird/aug

Last synced: 14 days ago
JSON representation

A javascript augment/extend library

Awesome Lists containing this project

README

        

aug



Test Status


Lint Status

NPM Version

aug is simple augment/extend library. If you've used jQuery's `$.extend`, then you will be familiar with it.

## Installation

```sh
npm install aug
```

or

```sh
yarn add aug
```

## Usage

__Deep Merge__

```javascript
import aug from 'aug';

const person = { info: { first: 'bob', last: 'smith' } };
const address = { info: { last: 'jones', age: 5 }, address: '123 main st' };
const pet = { pet: { name: 'sparky' } };

const merged = aug(person, address, pet);

//merged == { info: { first: 'bob', last: 'jones', age: 5 }, address: '123 main st ', pet: { name: 'sparky } };
//person, address, pet objects stay the same
```

__Defaults__

Only merge if it exists in the first argument

```javascript
import aug from 'aug';

const person = { info: { first: 'bob', last: 'smith' } , pet: { name: '' } };
const address = { info: { last: 'jones', age: 5 }, address: '123 main st' };
const pet = { pet: { name: 'sparky' } };

const merged = aug.defaults(person, address, pet);

//merged == { info: { first: 'bob', last: 'jones' }, pet: { name: 'sparky' }}
//person, address, pet objects stay the same
```

---

_A [First + Third](https://firstandthird.com) Project_