Hashmap.js is an Javascript lib to add Hashmaps to Javascript.
To import Hashmap.js you need to add it in your html file by using:
<script src="https://cdn.zffu.ml/js/@hashmap-js/1.0/Hashmap-js-1.0.js"></script>
You can create an Hashmap by making a new HashMap object instance:
let myHashMap = new HashMap();
If you want you can specify specific required types for your HashMap:
myHashMap.setRequiredTypes(String, Number);
If you want to remove the required types you can use
myHashMap.removeRequiredTypes();
To add content to your hashmap, you will need to use the put function:
myHashMap.put(myKey, myValue);
To clear every data that is in your Hashmap you can use the clear() function:
myHashMap.clear();
You can get a value by using the get(key) function:
let myValue = myHashMap.get(myKey);
You can also get every key that are in your hashmap by doing:
let keys = myHashMap.getKeys();
You can also get every values that are in your hashmap by doing:
let values = myHashMap.getValues();
If you need to get everything that is in your hashmap you can use:
// Normal Format
let data = myHashMap.getAll();
// Json Format
let json = myHashMap.getAllInJson();
You can check if your hashmap has an key or an value by using:
// KEY
let doesKeyExists = myHashMap.keyExists(myKey);
// VALUE
let doesValueExists = myHashMap.valueExists(myValue);