Comparing version 1.0.4 to 1.0.5
@@ -37,12 +37,13 @@ "use strict"; | ||
BiMap.prototype.set = function (key, value) { | ||
var oldVal = this.left.get(key); | ||
var oldKey = this.right.get(value); | ||
if (this.left.has(key)) { | ||
this.right.delete(oldVal); | ||
var _a = this, left = _a.left, right = _a.right; | ||
var oldVal = left.get(key); | ||
var oldKey = right.get(value); | ||
if (left.has(key)) { | ||
right.delete(oldVal); | ||
} | ||
if (this.right.has(value)) { | ||
this.left.delete(oldKey); | ||
if (right.has(value)) { | ||
left.delete(oldKey); | ||
} | ||
this.left.set(key, value); | ||
this.right.set(value, key); | ||
left.set(key, value); | ||
right.set(value, key); | ||
return this; | ||
@@ -118,12 +119,13 @@ }; | ||
WeakBiMap.prototype.set = function (key, value) { | ||
var oldVal = this.left.get(key); | ||
var oldKey = this.right.get(value); | ||
if (this.left.has(key)) { | ||
this.right.delete(oldVal); | ||
var _a = this, left = _a.left, right = _a.right; | ||
var oldVal = left.get(key); | ||
var oldKey = right.get(value); | ||
if (left.has(key)) { | ||
right.delete(oldVal); | ||
} | ||
if (this.right.has(value)) { | ||
this.left.delete(oldKey); | ||
if (right.has(value)) { | ||
left.delete(oldKey); | ||
} | ||
this.left.set(key, value); | ||
this.right.set(value, key); | ||
left.set(key, value); | ||
right.set(value, key); | ||
return this; | ||
@@ -130,0 +132,0 @@ }; |
{ | ||
"name": "bim", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A bidirectional map based on the ES6 Map object containing additional methods to retrive keys by values, delete key-value pairs by values and check the existence of keys by values.", | ||
@@ -27,2 +27,2 @@ "main": "index.js", | ||
} | ||
} | ||
} |
@@ -46,12 +46,13 @@ export class BiMap<K, V> implements Map<K, V> { | ||
set(key: K, value: V): this { | ||
const oldVal = this.left.get(key) | ||
const oldKey = this.right.get(value) | ||
if (this.left.has(key)) { | ||
this.right.delete(oldVal) | ||
const { left, right } = this | ||
const oldVal = left.get(key) | ||
const oldKey = right.get(value) | ||
if (left.has(key)) { | ||
right.delete(oldVal) | ||
} | ||
if (this.right.has(value)) { | ||
this.left.delete(oldKey) | ||
if (right.has(value)) { | ||
left.delete(oldKey) | ||
} | ||
this.left.set(key, value) | ||
this.right.set(value, key) | ||
left.set(key, value) | ||
right.set(value, key) | ||
return this | ||
@@ -132,12 +133,13 @@ } | ||
set(key: K, value: V): this { | ||
const oldVal = this.left.get(key) | ||
const oldKey = this.right.get(value) | ||
if (this.left.has(key)) { | ||
this.right.delete(oldVal) | ||
const { left, right } = this | ||
const oldVal = left.get(key) | ||
const oldKey = right.get(value) | ||
if (left.has(key)) { | ||
right.delete(oldVal) | ||
} | ||
if (this.right.has(value)) { | ||
this.left.delete(oldKey) | ||
if (right.has(value)) { | ||
left.delete(oldKey) | ||
} | ||
this.left.set(key, value) | ||
this.right.set(value, key) | ||
left.set(key, value) | ||
right.set(value, key) | ||
return this | ||
@@ -144,0 +146,0 @@ } |
@@ -6,3 +6,3 @@ { | ||
"sourceMap": false, | ||
"watch": true, | ||
// "watch": true, | ||
"pretty": true, | ||
@@ -9,0 +9,0 @@ "lib": [ "dom", "es7" ], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13941
11
383
1
1