<commit_before># args2object

Node/JavaScript library to access an item in an object structure given function arguments as path.


## Install in Node

```bash
$ npm install args2object
```


## Manual installation for Browser apps

Take the browserified file at `dist/args2object.bundle.js` and include it in your HTML:

```html
<script src='js/args2object.bundle.js'></script>
```

The browserified file exports the `window.args2object` function.


## Usage

```js
var args2object = require('args2object');  // if Node

var myObject = {
  a: true,
  b: false,
  c: 'hello',
  d: {
    d1: 'foo',
    d2: [1,2,3,4]
  },
  true: {
    false: 0,
    bar: null
  }
};


var getter = args2object(myObject);

getter('a');             // => true
getter('b');             // => false
getter('c');             // => 'hello'
getter('d','d1');        // => 'foo'
getter('d','d2');        // => [1,2,3,4]
getter(true,false);      // => 0
getter(true,'bar');      // => null

getter('a','a1');        // => undefined
getter('a','a1','a11');  // => undefined
getter('e');             // => undefined
getter('e','e1');        // => undefined
getter(null,true,false); // => undefined

getter();                // => the full object


var getter = args2object(myObject, {failOnNotFound: true});

getter('a','a1');        // => throws an Error exception
getter('a','a1','a11');  // => throws an Error exception
getter('e');             // => throws an Error exception
getter('e','e1');        // => throws an Error exception
getter(false);           // => throws an Error exception
```


## API

### `getter = args2object(object, options)`

* param `{Object|Function}` **object**: The object to handle.
* param `{Object}` **options** *(optional)*:
  * `{Boolean}` **failOnNotFound**: Whether to throw an `Error` if the searched path does not exist in the object structure (default: `false`).

Returns a `getter` function.

### `getter(a,b,c)`

Retrieve the value at `object[a][b][c]`.

If the path does not exist it returns `undefined` (or throws an `Error` if `options.failOnNotFound` is set).


## Release History

### 0.1.1 (2014-11-20)
* Make it much more robust and allow retrieving the full object.

### 0.1.0 (2014-11-14)
* First release.

## License
<commit_msg>Add latests changelog in README.<commit_after># args2object

Node/JavaScript library to access an item in an object structure given function arguments as path.


## Install in Node

```bash
$ npm install args2object
```


## Manual installation for Browser apps

Take the browserified file at `dist/args2object.bundle.js` and include it in your HTML:

```html
<script src='js/args2object.bundle.js'></script>
```

The browserified file exports the `window.args2object` function.


## Usage

```js
var args2object = require('args2object');  // if Node

var myObject = {
  a: true,
  b: false,
  c: 'hello',
  d: {
    d1: 'foo',
    d2: [1,2,3,4]
  },
  true: {
    false: 0,
    bar: null
  }
};


var getter = args2object(myObject);

getter('a');             // => true
getter('b');             // => false
getter('c');             // => 'hello'
getter('d','d1');        // => 'foo'
getter('d','d2');        // => [1,2,3,4]
getter(true,false);      // => 0
getter(true,'bar');      // => null

getter('a','a1');        // => undefined
getter('a','a1','a11');  // => undefined
getter('e');             // => undefined
getter('e','e1');        // => undefined
getter(null,true,false); // => undefined

getter();                // => the full object


var getter = args2object(myObject, {failOnNotFound: true});

getter('a','a1');        // => throws an Error exception
getter('a','a1','a11');  // => throws an Error exception
getter('e');             // => throws an Error exception
getter('e','e1');        // => throws an Error exception
getter(false);           // => throws an Error exception
```


## API

### `getter = args2object(object, options)`

* param `{Object|Function}` **object**: The object to handle.
* param `{Object}` **options** *(optional)*:
  * `{Boolean}` **failOnNotFound**: Whether to throw an `Error` if the searched path does not exist in the object structure (default: `false`).

Returns a `getter` function.

### `getter(a,b,c)`

Retrieve the value at `object[a][b][c]`.

If the path does not exist it returns `undefined` (or throws an `Error` if `options.failOnNotFound` is set).


## Release History

### 0.1.2 (2014-11-23)

* Improve examples in README.

### 0.1.1 (2014-11-20)
* Make it much more robust and allow retrieving the full object.

### 0.1.0 (2014-11-14)
* First release.

## License

{'fraction_non_alphanumeric': 0.18296943231441049, 'fraction_numerical': 0.026855895196506552, 'mean_word_length': 3.0361233480176213, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3152647', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1498, 'n_words': 448}