<commit_before># hashset.js [![Build Status](https://travis-ci.org/capaj/hashset.js.svg?branch=master)](https://travis-ci.org/capaj/hashset.js)
simple hashset implementation aimed to working with DB entries on frontend. If it has primary keys, storing it in a hashset is probably a good idea.

## Installation
```
jspm i npm:hashset.js
npm i hashset.js
```

## Why not es6 Set?
Because it is not suited for working with DB objects, such as objects returned from mongoDB where primary keys are '_id' properties. It is not possible to tell the native set that two objects with the same _id are the same.

## API
With the API I tried to shadow ES6 Set, so it should feel almost as if you were working with the native Set implementation.

### Hashset
```
var hashFunction = '_id';
//or your hashFunction can be an actual function
var hashFunction = function(item){return item.a+item.b};
new Hashset(hashFunction) //returns new instance of a Hashset
```

### Methods
```
add(value) returns {boolean}
addMany(arr) returns {Number}
clear()
delete(valueOrKey) returns {boolean}
each(iteratorFunction, thisObjopt)
filter() returns {Hashset}
getValue(hash) returns {*}
has(valueOrKey) returns {boolean}
size() returns {number}
toArray() returns {Array}
upsert(value) returns {boolean}	//requires Object.assign
upsertArray(arr) returns {Number}<commit_msg>fixed readme method list<commit_after># hashset.js [![Build Status](https://travis-ci.org/capaj/hashset.js.svg?branch=master)](https://travis-ci.org/capaj/hashset.js)
simple hashset implementation aimed to working with DB entries on frontend. If it has primary keys, storing it in a hashset is probably a good idea.

## Installation
```
jspm i npm:hashset.js
npm i hashset.js
```

## Why not es6 Set?
Because it is not suited for working with DB objects, such as objects returned from mongoDB where primary keys are '_id' properties. It is not possible to tell the native set that two objects with the same _id are the same.

## API
With the API I tried to shadow ES6 Set, so it should feel almost as if you were working with the native Set implementation.

### Hashset
```
var hashFunction = '_id';
//or your hashFunction can be an actual function
var hashFunction = function(item){return item.a+item.b};
new Hashset(hashFunction) //returns new instance of a Hashset
```

### Methods
```
add(value) returns {boolean}
addArray(arr) returns {Number}
clear()
delete(valueOrKey) returns {boolean}
each(iteratorFunction, thisObjopt)
filter() returns {Hashset}
getValue(hash) returns {*}
has(valueOrKey) returns {boolean}
size() returns {number}
toArray() returns {Array}
upsert(value) returns {boolean}	//requires Object.assign
upsertArray(arr) returns {Number}
{'fraction_non_alphanumeric': 0.10510732790525537, 'fraction_numerical': 0.0014803849000740192, 'mean_word_length': 5.228110599078341, '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': '5572866', 'n_tokens_mistral': 803, 'n_tokens_neox': 783, 'n_words': 334}