Skip to content

Commit

Permalink
README update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Luce committed Aug 9, 2016
1 parent 4400a99 commit dbef875
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,35 @@

[![Build Status](https://travis-ci.org/allenluce/node-autovivify.svg?branch=master)](https://travis-ci.org/allenluce/node-autovivify)

Are you tired of having to type things like this?
Does this ever happen to you?

``` javascript
let subarray = []
subarray[2] = {
myvalue: 'coolio'
}

let subobj = []
subobj[4] = {
subarray: subarray
}

const obj = {
subobj: subobj
}
```
> cars = {}
{}
> cars.mercedes.sl600.color = 'blue'
TypeError: Cannot read property 'sl600' of undefined
```

Wouldn't you rather just do this?
Well now there's *node-autovivify*!

``` javascript
obj.subobj[4].subarray[2].myvalue = 'coolio'
```
> Av = require('autovivify')
> cars = new Av()
{}
> cars.mercedes.sl600.color = 'blue'
'blue'
```

It also works with arrays!

Well, now you can!
``` javascript
Av = require('autovivify')
> cars = new Av()
> cars.mercedes.sl600.color = 'blue'
'blue'
> cars.carlist[0] = cars.mercedes
{ sl600: { color: 'blue' } }
```

## Installation

Expand Down

0 comments on commit dbef875

Please sign in to comment.