UNPKG

superhash

Version:

HashMap that supports using one or more keys of any type.

59 lines (41 loc) 1.4 kB
SuperHash ======== [![Build Status](https://travis-ci.org/esco/superhash.svg?branch=master)](https://travis-ci.org/esco/superhash) [![Coverage Status](https://coveralls.io/repos/esco/superhash/badge.png)](https://coveralls.io/r/esco/superhash) [![Code Climate](https://codeclimate.com/github/esco/superhash/badges/gpa.svg)](https://codeclimate.com/github/esco/superhash) ![superhash](http://i.imgur.com/JcPuyeW.png) HashMap that supports using one or more keys of any type* >Hash keys are generated using [multikey-hash](https://github.com/esco/multikey-hash) ## Installation ``` $ npm install superhash ``` ## Examples ```js var SuperHash = require('superhash'); var hashMap = new SuperHash(); var data = 'value'; ``` Single key: ```js hashMap.set(/.*/g, data); hashMap.get("/.*/g"); // returns undefined hashMap.get(/.*/g); // returns 'value' hashMap.delete(/.*/g); // returns true ``` Multiple keys: ```js hashMap.set(1,{ name: 'foo' }, true, data); hashMap.get(1,{ name: 'foo' }, "true"); // returns undefined hashMap.get(1,{ name: 'foo' }, true); // returns 'value' hashMap.delete(1,{ name: 'foo' }, true); // returns true ``` ## API [See API.md][api-url] ## FAQ ### What types of keys can be used? Any primitive or mutable object can be used as a key. ### Who named this module? [@nik](http://github.com/nik) ## LICENSE [MIT][license-url] [license-url]: LICENSE [api-url]: API.md