MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / set

Method set

lib/host.js:558–578  ·  view source on GitHub ↗

* Adds a new item to the map. * @param {String} key The key of the host * @param {Host} value The host to be added * @fires HostMap#remove * @fires HostMap#add

(key, value)

Source from the content-addressed store, hash-verified

556 * @fires HostMap#add
557 */
558 set(key, value) {
559 // Clear values cache
560 this._values = null;
561
562 const originalValue = this._items.get(key);
563 if (originalValue) {
564 //The internal structure does not change
565 this._items.set(key, value);
566 //emit a remove followed by a add
567 this.emit('remove', originalValue);
568 this.emit('add', value);
569 return;
570 }
571
572 // Copy the values
573 const copy = new Map(this._items);
574 copy.set(key, value);
575 this._items = copy;
576 this.emit('add', value);
577 return value;
578 }
579
580 /**
581 * Returns a shallow copy of a portion of the items into a new array object.

Callers 15

pushMethod · 0.95
createHostMapFunction · 0.95
createHostMapFunction · 0.95
_addContactPointMethod · 0.80
_setLocalInfoMethod · 0.80
setPeersInfoMethod · 0.80
prepareOnceMethod · 0.80
_writeMethod · 0.80
prepareAllQueriesMethod · 0.80
getExecutorFromQueryMethod · 0.80
constructorMethod · 0.80
parseMethod · 0.80

Calls 1

getMethod · 0.65

Tested by

no test coverage detected