Skip to content

Commit

Permalink
feat: Add define method to set a default value
Browse files Browse the repository at this point in the history
docs: Add
docs: Update manual
test: Add test for define
chore: Update semantic-release dev-dependency
  • Loading branch information
liqueurdetoile committed Mar 17, 2018
1 parent b8fd177 commit 33f5ff6
Show file tree
Hide file tree
Showing 20 changed files with 25,266 additions and 21,529 deletions.
95 changes: 51 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,10 @@ For three reasons :
## Features
DOA is an object with a set of methods to :
- Check, push, get and store data with ease regardless of its level
- Brings some array-like behaviours for convenience (you know <tt>forEach</tt>, eh ?)
- Easy to use data serializers and parsers
- Bring some array-like behaviours for convenience (you know `forEach` for arrays, eh ?)
- Provide data serializers and parsers
- Work as well on a whole dataset or a key-based sub-selection of the dataset

## Installation
### Module
The ObjectArray class is provided as a UMD module.
```
npm install dot-object-array
```
or
```
yarn add dot-object-array
```
Then simply require/import it :
```javascript
import ObjectArray from 'dot-object-array';
const ObjectArray = require('dot-object-array').default;
```
ObjectArray have been built on a ECMA6 class with webpack a named default export.

### Browser
DOA is available as CDN external link or can easily be installed locally.
#### Bundle
```html
<script type="text/javascript" src="https://bundle.run/dot-object-array@latest"></script>
```
#### JsDelivr
```html
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/dot-object-array@latest"></script>
```
#### Unpkg
```html
<script type="text/javascript" src="https://unpkg.com/dot-object-array@latest"></script>
```
#### Local install
For browser install, you can simply fetch file `dist/objectarray.min.js` in this repo or clone it and load it :
```html
<script type="text/javascript" src="myJsFolder/objectarray.min.js"></script>
```
An ObjectArray constructor will be added to global (window) scope.
- Ease management of options default values

## Quick examples
```javascript
Expand All @@ -76,16 +39,20 @@ var doa = new ObjectArray({
item3: 5
});

//Add data
// Add data
doa.push('item4', 4); // Single item or dataset
doa.import({
item5: 5,
item6: 6
});

//Add data with dotted notations
// Add data with dotted notations
doa.push('dat.long.darn.key','isntIt?'); // Will automatically create each keys

// Define default values
// Will keep value if existent or create keys with value if not
doa.define('options.section1.item14', true);

//Iterate on keys at root level or in sub dataset
doa.forEach(function(value, key, index) {
[...]
Expand All @@ -101,13 +68,51 @@ doa.import({
subitem3: {obj: really}
}, 'dat.long.and.far.away.key');

//sub dataset access
// sub dataset access
doa.dataset('dat.long.and.far.away.key');
// or
doa.pull('dat.long.and.far.away.key');

// And many more !
```
## Installation
### Module
The ObjectArray class is provided as a UMD module.
```
npm install dot-object-array
```
or
```
yarn add dot-object-array
```
Then simply require/import it :
```javascript
import ObjectArray from 'dot-object-array';
const ObjectArray = require('dot-object-array').default;
```
ObjectArray have been coded with ECMA6 class standard.

### Browser
DOA is available as CDN external link or can easily be installed locally.
#### Bundle
```html
<script type="text/javascript" src="https://bundle.run/dot-object-array@latest"></script>
```
#### JsDelivr
```html
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/dot-object-array@latest"></script>
```
#### Unpkg
```html
<script type="text/javascript" src="https://unpkg.com/dot-object-array@latest"></script>
```
#### Local install
For browser install, you can simply fetch file `dist/objectarray.min.js` in this repo or clone it and load it :
```html
<script type="text/javascript" src="myJsFolder/objectarray.min.js"></script>
```
An ObjectArray constructor will be added to global (window) scope.

## Configuring ObjectArray behaviour when a required key doesn't exist
In version 1.x, a non-existent key yields to an `undefined` returned value.

Expand All @@ -122,7 +127,9 @@ Please check [API reference](https://liqueurdetoile.github.io/DotObjectArray/doc
If you want to go further and try a bit, you [can go to the playground](https://jsfiddle.net/dx03k9sL/19/).

## Documentation
A full documentation (manual and API reference) set is available : [https://liqueurdetoile.github.io/DotObjectArray](https://liqueurdetoile.github.io/DotObjectArray)
A full documentation (manual and API reference) set is available :
- [Manual](https://liqueurdetoile.github.io/DotObjectArray/manual/index.html)
- [API reference](https://liqueurdetoile.github.io/DotObjectArray/identifiers.html)

## JSON support
You can easily use ObjectArrays to manipulate JSON data. Just rely on JSON native object to import your JSON structure, manipulate it with ObjectArray ease and get it back at the end :wink:
Expand Down
2 changes: 1 addition & 1 deletion dist/objectarray.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@

h3 .right-info {
font-size: 0.6em;
position: relative;
display: block;
text-align: right;
float: right;
margin-left: 1em;
padding-top: 1em;
padding-top: 0.5em;
}

.version, .since {
Expand Down
Loading

0 comments on commit 33f5ff6

Please sign in to comment.