Comparing version 1.0.15 to 1.1.1
@@ -9,3 +9,3 @@ export declare class BiMap<K, V> implements Map<K, V> { | ||
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void; | ||
get(key: K): V; | ||
get(key: K): V | undefined; | ||
has(key: K): boolean; | ||
@@ -19,6 +19,6 @@ keys(): IterableIterator<K>; | ||
deleteValue(value: V): boolean; | ||
getKey(value: V): K; | ||
getKey(value: V): K | undefined; | ||
hasValue(value: V): boolean; | ||
} | ||
export declare class WeakBiMap<K, V> implements WeakMap<K, V> { | ||
export declare class WeakBiMap<K extends object, V extends object> implements WeakMap<K, V> { | ||
private left; | ||
@@ -29,3 +29,3 @@ private right; | ||
delete(key: K): boolean; | ||
get(key: K): V; | ||
get(key: K): V | undefined; | ||
has(key: K): boolean; | ||
@@ -35,4 +35,4 @@ set(key: K, value: V): this; | ||
deleteValue(value: V): boolean; | ||
getKey(value: V): K; | ||
getKey(value: V): K | undefined; | ||
hasValue(value: V): boolean; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var BiMap = (function () { | ||
@@ -7,3 +8,3 @@ function BiMap(iterable) { | ||
this.right = new Map(); | ||
this.left.forEach(function (i) { return _this.right.set(i); }); | ||
this.left.forEach(function (v, k) { return _this.right.set(v, k); }); | ||
} | ||
@@ -10,0 +11,0 @@ BiMap.prototype.clear = function () { |
{ | ||
"name": "bim", | ||
"version": "1.0.15", | ||
"version": "1.1.1", | ||
"description": "A bidirectional map based on the ES6 Map & WeakMap objects", | ||
@@ -26,4 +26,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"typescript": "^2.1.5" | ||
"typescript": "^2.2.1" | ||
} | ||
} |
@@ -6,5 +6,5 @@ export class BiMap<K, V> implements Map<K, V> { | ||
constructor(iterable?: Iterable<[K, V]>) { | ||
this.left = new Map<K, V>(iterable) | ||
this.left = new Map<K, V>(iterable as Iterable<[K, V]>) | ||
this.right = new Map<V, K>() | ||
this.left.forEach(i => this.right.set(i)) | ||
this.left.forEach((v, k) => this.right.set(v, k)) | ||
} | ||
@@ -18,3 +18,3 @@ | ||
delete(key: K): boolean { | ||
const val = this.left.get(key) | ||
const val = this.left.get(key) as V | ||
if (!this.right.has(val)) { | ||
@@ -35,3 +35,3 @@ return false | ||
get(key: K): V { | ||
get(key: K): V|undefined { | ||
return this.left.get(key) | ||
@@ -50,4 +50,4 @@ } | ||
const { left, right } = this | ||
const oldVal = left.get(key) | ||
const oldKey = right.get(value) | ||
const oldVal = left.get(key) as V | ||
const oldKey = right.get(value) as K | ||
if (left.has(key)) { | ||
@@ -80,4 +80,4 @@ right.delete(oldVal) | ||
deleteValue(value: V) { | ||
const key = this.right.get(value) | ||
deleteValue(value: V): boolean { | ||
const key = this.right.get(value) as K | ||
if (!this.left.has(key)) { | ||
@@ -90,7 +90,7 @@ return false | ||
getKey(value: V) { | ||
getKey(value: V): K|undefined { | ||
return this.right.get(value) | ||
} | ||
hasValue(value: V) { | ||
hasValue(value: V): boolean { | ||
return this.right.has(value) | ||
@@ -100,3 +100,3 @@ } | ||
export class WeakBiMap<K, V> implements WeakMap<K, V> { | ||
export class WeakBiMap<K extends object, V extends object> implements WeakMap<K, V> { | ||
private left: WeakMap<K, V> | ||
@@ -122,3 +122,3 @@ private right: WeakMap<V, K> | ||
delete(key: K): boolean { | ||
const val = this.left.get(key) | ||
const val = this.left.get(key) as V | ||
if (!this.right.has(val)) { | ||
@@ -131,3 +131,3 @@ return false | ||
get(key: K): V { | ||
get(key: K): V|undefined { | ||
return this.left.get(key) | ||
@@ -142,4 +142,4 @@ } | ||
const { left, right } = this | ||
const oldVal = left.get(key) | ||
const oldKey = right.get(value) | ||
const oldVal = left.get(key) as V | ||
const oldKey = right.get(value) as K | ||
if (left.has(key)) { | ||
@@ -160,4 +160,4 @@ right.delete(oldVal) | ||
deleteValue(value: V) { | ||
const key = this.right.get(value) | ||
deleteValue(value: V): boolean { | ||
const key = this.right.get(value) as K | ||
if (!this.left.has(key)) { | ||
@@ -170,7 +170,7 @@ return false | ||
getKey(value: V) { | ||
getKey(value: V): K|undefined { | ||
return this.right.get(value) | ||
} | ||
hasValue(value: V) { | ||
hasValue(value: V): boolean { | ||
return this.right.has(value) | ||
@@ -177,0 +177,0 @@ } |
@@ -11,2 +11,3 @@ { | ||
"alwaysStrict": true, | ||
"strictNullChecks": true, | ||
"outDir": "lib" | ||
@@ -13,0 +14,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
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
19043
386