<commit_before># Complete-Me

JavaScript library for autocompletes

### Dependencies

Nothing

### Demo

A demo of the library in action can be [found here](http://www.callumhart.com/open-source/complete-me).

### Supported browsers

So far tested on Chrome, Firefox and Safari.

### To run

```
$ cd Complete-Me
$ npm install
$ grunt watch
```

### To initialise

```javascript
var instance = new CompleteMe(element, { options });
```

> `element` can be a selector or a DOM element.

### Configuration options

- `data` Data that should show in the results dropdown, can be:
  - Empty array i.e `[]`
  - Flat array i.e `[“a”, “b”, “c”]`
  - Array of objects i.e `[{“key”: “id”, “value”: “ID”}, {“key”: “email_address”, “value” : “Email Address”}]`
- `placeholder` Placeholder text, *default* `Type here…`, *type* String
- `selectedValue` Select an existing result by its value, *type* String
- `selectedKey` Select an existing result by its key, *type* String
- `noResultsText` Text to show when there are no results., *default* `Couldn't find {{searchQuery}}`, *type* String
- `canAddNewRecords` Allow new records to be added to the list., *default* `False`, *type* Boolean
- `canAddNewRecordsText` Text / DOM element to show when there are no results.`canAddNewRecords` option has to be True., *default* `Hit <span class="cm-key">enter</span> to add`, *type* String
- `fetchingMoreResultsText` Text to show when remote data is being fetched – only shows when `onNoResults` callback is used., *default* `Fetching more results...`, *type* String
- `suggestResult` Show suggestion in placeholder, *default* `False`, *type* Boolean
- `saveByValue` When data is an array of objects set data-save-value to the selected object’s value attribute. When False data-save-value is set to the selected objects key attribute. *default* `True`, *type* Boolean

### Callbacks

- `onSelect: (value)` When a record in the results dropdown is selected. If data is array of objects then @params are `(value, key)`
- `onAdd: (newRecord)` When a new record is added to the list. `canAddNewRecords` option has to be True.
- `onNoResults: (value)` When the search query isn’t found in the data array.
- `onFocussed` When “focus” event is fired (within autocomplete).
- `onBlurred` When “blur” event is fired (within autocomplete).
- `onKeyedDown` When “keydown” event is fired (within autocomplete).
- `onKeyedUp` When “keyup” event is fired (within autocomplete).
- `onShowSuggestion` When suggestion is shown. `suggestSuggestion` option has to be True.
- `onClearSuggestion` When suggestion is hidden. `suggestSuggestion` option has to be True.
- `onSuggestionSelected: (value)` When user accepts suggestion. `suggestSuggestion` option has to be True.
- `updateData: (value)` Update the data that displays in the dropdown.
<commit_msg>Fixed typo in documentation<commit_after># Complete-Me

JavaScript library for autocompletes

### Dependencies

Nothing

### Demo

A demo of the library in action can be [found here](http://www.callumhart.com/open-source/complete-me).

### Supported browsers

So far tested on Chrome, Firefox and Safari.

### To run

```
$ cd Complete-Me
$ npm install
$ grunt watch
```

### To initialise

```javascript
var instance = new CompleteMe(element, { options });
```

> `element` can be a selector or a DOM element.

### Configuration options

- `data` Data that should show in the results dropdown, can be:
  - Empty array i.e `[]`
  - Flat array i.e `[“a”, “b”, “c”]`
  - Array of objects i.e `[{“key”: “id”, “value”: “ID”}, {“key”: “email_address”, “value” : “Email Address”}]`
- `placeholder` Placeholder text, *default* `Type here…`, *type* String
- `selectedValue` Select an existing result by its value, *type* String
- `selectedKey` Select an existing result by its key, *type* String
- `noResultsText` Text to show when there are no results., *default* `Couldn't find {{searchQuery}}`, *type* String
- `canAddNewRecords` Allow new records to be added to the list., *default* `False`, *type* Boolean
- `canAddNewRecordsText` Text / DOM element to show when there are no results.`canAddNewRecords` option has to be True., *default* `Hit <span class="cm-key">enter</span> to add`, *type* String
- `fetchingMoreResultsText` Text to show when remote data is being fetched – only shows when `onNoResults` callback is used., *default* `Fetching more results...`, *type* String
- `suggestResult` Show suggestion in placeholder, *default* `False`, *type* Boolean
- `saveByValue` When data is an array of objects set data-save-value to the selected object’s value attribute. When False data-save-value is set to the selected objects key attribute. *default* `True`, *type* Boolean

### Callbacks

- `onSelect: (value)` When a record in the results dropdown is selected. If data is array of objects then @params are `(value, key)`
- `onAdd: (newRecord)` When a new record is added to the list. `canAddNewRecords` option has to be True.
- `onNoResults: (value)` When the search query isn’t found in the data array.
- `onFocussed` When “focus” event is fired (within autocomplete).
- `onBlurred` When “blur” event is fired (within autocomplete).
- `onKeyedDown` When “keydown” event is fired (within autocomplete).
- `onKeyedUp` When “keyup” event is fired (within autocomplete).
- `onShowSuggestion` When suggestion is shown. `suggestResult` option has to be True.
- `onClearSuggestion` When suggestion is hidden. `suggestResult` option has to be True.
- `onSuggestionSelected: (value)` When user accepts suggestion. `suggestResult` option has to be True.
- `updateData: (value)` Update the data that displays in the dropdown.

{'fraction_non_alphanumeric': 0.12242725337118524, 'fraction_numerical': 0.0, 'mean_word_length': 4.60337972166998, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1128828', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1647, 'n_words': 729}