Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/firstandthird/aug
- Owner: firstandthird
- License: mit
- Created: 2011-10-25T21:41:09.000Z (over 13 years ago)
- Default Branch: main
- Last Pushed: 2023-01-07T03:16:30.000Z (about 2 years ago)
- Last Synced: 2025-01-09T10:18:50.310Z (24 days ago)
- Language: JavaScript
- Homepage:
- Size: 962 KB
- Stars: 18
- Watchers: 13
- Forks: 5
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
aug
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_