* @param {string} key * @param {*} value
(key, value)
| 49 | * @param {*} value |
| 50 | */ |
| 51 | set(key, value) { |
| 52 | const keyHash = this.hash(key); |
| 53 | this.keys[key] = keyHash; |
| 54 | const bucketLinkedList = this.buckets[keyHash]; |
| 55 | const node = bucketLinkedList.find({ callback: (nodeValue) => nodeValue.key === key }); |
| 56 | |
| 57 | if (!node) { |
| 58 | // Insert new node. |
| 59 | bucketLinkedList.append({ key, value }); |
| 60 | } else { |
| 61 | // Update value of existing node. |
| 62 | node.value.value = value; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * @param {string} key |
no test coverage detected