<commit_before># array
Indexed javascript object list

## About
This is an Array prototype extension, adding index support for use in javascript arrays with similar objects.

### Features
* All you can do with a [native Array](http://www.w3schools.com/jsref/jsref_obj_array.asp "Array methods"), you can do with a indexed one
* Single or multiple field indexes, defined before or after storing objects
* Fast obtaining items matching pattern sought
* Search using a string, or a regular expression

### Installation
Just require ```array.js``` file.

### Run tests
```
npm install
make test
```

## Usage

### Activate indexing in your array
```js
var users = new Array();
users.ensureIndex();
```
You can also activate indexing in a already filled array
```js
var users = [
  {'id': '50d2548dcaf0245c6f000001', 'name': '<NAME>', 'office': 1},
  {'id': '5124610c408b231968000001', 'name': '<NAME>', 'office': 2},
  {'id': '50bca975acceb00d3d000001', 'name': '<NAME>', 'office': 1}
];
users.ensureIndex();
```

### Define fields you want to index
Index are defined by "ensureIndex" method. You can call it right in index activation, or later.
```js
users.ensureIndex(['id', 'office']);
```

### Find items in Array
```js
var query = {'name': /^\w+ niemeyer/i, 'office': 2};
var results = users.find(query);
```
If the field is indexed results will be faster, but not indexed fields works too.<commit_msg>npm test<commit_after># array
Indexed javascript object list

## About
This is an Array prototype extension, adding index support for use in javascript arrays with similar objects.

### Features
* All you can do with a [native Array](http://www.w3schools.com/jsref/jsref_obj_array.asp "Array methods"), you can do with a indexed one
* Single or multiple field indexes, defined before or after storing objects
* Fast obtaining items matching pattern sought
* Search using a string, or a regular expression

### Installation
Just require ```array.js``` file.

### Run tests
```
npm install
npm test
```

## Usage

### Activate indexing in your array
```js
var users = new Array();
users.ensureIndex();
```
You can also activate indexing in a already filled array
```js
var users = [
  {'id': '50d2548dcaf0245c6f000001', 'name': '<NAME>', 'office': 1},
  {'id': '5124610c408b231968000001', 'name': '<NAME>', 'office': 2},
  {'id': '50bca975acceb00d3d000001', 'name': '<NAME>', 'office': 1}
];
users.ensureIndex();
```

### Define fields you want to index
Index are defined by "ensureIndex" method. You can call it right in index activation, or later.
```js
users.ensureIndex(['id', 'office']);
```

### Find items in Array
```js
var query = {'name': /^\w+ niemeyer/i, 'office': 2};
var results = users.find(query);
```
If the field is indexed results will be faster, but not indexed fields works too.
{'fraction_non_alphanumeric': 0.14357142857142857, 'fraction_numerical': 0.041428571428571426, 'mean_word_length': 4.959574468085107, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5572711', 'n_tokens_mistral': 957, 'n_tokens_neox': 828, 'n_words': 354}