<commit_before># query-object

[![Build Status](https://travis-ci.org/fernandofleury/query-object.svg?branch=master)](https://travis-ci.org/fernandofleury/query-object)

A lightweight lib to work with query strings (1kb uglified)


## Install
You can install via npm or via Bower, query-object is also provided as AMD if you use requireJS:

```javascript
npm install query-object
bower install query-object
```

## API

### useHistory
Defines the usage of HTML5HistoryAPI for modifier methods.
DEFAULT: false

```javascript
queryObject.useHistory = true;
```

### setContext(object)
High-convenience test method to set current context since we can't reload using old location.search during tests.

```javascript
fakeContext = {};
fakeContext.location = {};
queryObject.setContext(fakeContext);
// returns the new context;
``` 

### clear()
Clears the current query string

```javascript
queryObject.clear();
// returns undefined
```

### get(string|array)
Returns the current query string as a key/value object. If an array was provided then an object with the matched keys will be returned, otherwise a string or undefined will be returned.

```javascript
// ?foo=foo&bar=bar&baz

queryObject.get();
// returns {foo: 'foo', bar: 'bar', baz: undefined}

queryObject.get('foo');<commit_msg>updated readme for setContext<commit_after># query-object

[![Build Status](https://travis-ci.org/fernandofleury/query-object.svg?branch=master)](https://travis-ci.org/fernandofleury/query-object)

A lightweight lib to work with query strings (1kb uglified)


## Install
You can install via npm or via Bower, query-object is also provided as AMD if you use requireJS:

```javascript
npm install query-object
bower install query-object
```

## API

### useHistory
Defines the usage of HTML5HistoryAPI for modifier methods.
DEFAULT: false

```javascript
queryObject.useHistory = true;
```

### setContext(object)
High-convenience test method to set current context since we can't reload using old location.search during tests. Returns the new context.

```javascript
fakeContext = {};
fakeContext.location = {};

queryObject.setContext(fakeContext);
// returns {}
``` 

### clear()
Clears the current query string

```javascript
queryObject.clear();
// returns undefined
```

### get(string|array)
Returns the current query string as a key/value object. If an array was provided then an object with the matched keys will be returned, otherwise a string or undefined will be returned.

```javascript
// ?foo=foo&bar=bar&baz

queryObject.get();
// returns {foo: 'foo', bar: 'bar', baz: undefined}

queryObject.get('foo');
{'fraction_non_alphanumeric': 0.11972371450498849, 'fraction_numerical': 0.0015349194167306216, 'mean_word_length': 5.119718309859155, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '2571958', 'n_tokens_mistral': 781, 'n_tokens_neox': 744, 'n_words': 271}