Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bim

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bim - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

.eslintrc.yaml

4

dist/BiMap.d.ts

@@ -1,2 +0,3 @@

export default class BiMap<K, V> implements Map<K, V> {
import ReverseMap from './ReverseMap';
declare class BiMap<K, V> implements Map<K, V>, ReverseMap<K, V> {
#private;

@@ -20,1 +21,2 @@ constructor(iterable?: Iterable<[K, V]>);

}
export default BiMap;

@@ -1,5 +0,5 @@

export default class WeakBiMap<K extends object, V extends object> implements WeakMap<K, V> {
import ReverseMap from './ReverseMap';
declare class WeakBiMap<K extends object, V extends object> implements WeakMap<K, V>, ReverseMap<K, V> {
#private;
constructor(iterable?: Iterable<[K, V]>);
clear(): void;
delete(key: K): boolean;

@@ -14,1 +14,2 @@ get(key: K): V | undefined;

}
export default WeakBiMap;

@@ -31,6 +31,2 @@ "use strict";

}
// eslint-disable-next-line class-methods-use-this
clear() {
console.error('method clear is deprecated');
}
delete(key) {

@@ -37,0 +33,0 @@ const val = __classPrivateFieldGet(this, _left).get(key);

{
"name": "bim",
"version": "1.2.0",
"version": "1.3.0",
"description": "A bidirectional map based on the ES6 Map & WeakMap objects",

@@ -28,3 +28,3 @@ "main": "dist/index.js",

"devDependencies": {
"@calipsa/eslint-config-typescript": "^1.6.0",
"@inker/eslint-config-typescript": "^1.0.0",
"@types/jest": "^25.2.1",

@@ -31,0 +31,0 @@ "eslint": "^6.8.0",

@@ -1,7 +0,9 @@

export default class BiMap<K, V> implements Map<K, V> {
#left: Map<K, V>
#right: Map<V, K>
import ReverseMap from './ReverseMap'
class BiMap<K, V> implements Map<K, V>, ReverseMap<K, V> {
readonly #left: Map<K, V>
readonly #right: Map<V, K>
constructor(iterable?: Iterable<[K, V]>) {
this.#left = new Map<K, V>(iterable as Iterable<[K, V]>)
this.#left = new Map<K, V>(iterable!)
this.#right = new Map<V, K>()

@@ -18,4 +20,4 @@ for (const [k, v] of this.#left) {

delete(key: K): boolean {
const val = this.#left.get(key) as V
delete(key: K) {
const val = this.#left.get(key)!
if (!this.#right.has(val)) {

@@ -28,27 +30,27 @@ return false

entries(): IterableIterator<[K, V]> {
entries() {
return this.#left.entries()
}
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void {
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any) {
this.#left.forEach(callbackfn, thisArg)
}
get(key: K): V | undefined {
get(key: K) {
return this.#left.get(key)
}
has(key: K): boolean {
has(key: K) {
return this.#left.has(key)
}
keys(): IterableIterator<K> {
keys() {
return this.#left.keys()
}
set(key: K, value: V): this {
set(key: K, value: V) {
const left = this.#left
const right = this.#right
const oldVal = left.get(key) as V
const oldKey = right.get(value) as K
const oldVal = left.get(key)!
const oldKey = right.get(value)!
if (left.has(key)) {

@@ -65,7 +67,7 @@ right.delete(oldVal)

get size(): number {
get size() {
return this.#left.size
}
values(): IterableIterator<V> {
values() {
return this.#left.values()

@@ -82,3 +84,3 @@ }

deleteValue(value: V): boolean {
deleteValue(value: V) {
const key = this.#right.get(value) as K

@@ -92,9 +94,11 @@ if (!this.#left.has(key)) {

getKey(value: V): K | undefined {
getKey(value: V) {
return this.#right.get(value)
}
hasValue(value: V): boolean {
hasValue(value: V) {
return this.#right.has(value)
}
}
export default BiMap

@@ -1,5 +0,7 @@

export default class WeakBiMap<K extends object, V extends object> implements WeakMap<K, V> {
#left: WeakMap<K, V>
#right: WeakMap<V, K>
import ReverseMap from './ReverseMap'
class WeakBiMap<K extends object, V extends object> implements WeakMap<K, V>, ReverseMap<K, V> {
readonly #left: WeakMap<K, V>
readonly #right: WeakMap<V, K>
constructor(iterable?: Iterable<[K, V]>) {

@@ -17,9 +19,4 @@ this.#left = new WeakMap<K, V>()

// eslint-disable-next-line class-methods-use-this
clear(): void {
console.error('method clear is deprecated')
}
delete(key: K): boolean {
const val = this.#left.get(key) as V
delete(key: K) {
const val = this.#left.get(key)!
if (!this.#right.has(val)) {

@@ -32,15 +29,15 @@ return false

get(key: K): V | undefined {
get(key: K) {
return this.#left.get(key)
}
has(key: K): boolean {
has(key: K) {
return this.#left.has(key)
}
set(key: K, value: V): this {
set(key: K, value: V) {
const left = this.#left
const right = this.#right
const oldVal = left.get(key) as V
const oldKey = right.get(value) as K
const oldVal = left.get(key)!
const oldKey = right.get(value)!
if (left.has(key)) {

@@ -61,4 +58,4 @@ right.delete(oldVal)

deleteValue(value: V): boolean {
const key = this.#right.get(value) as K
deleteValue(value: V) {
const key = this.#right.get(value)!
if (!this.#left.has(key)) {

@@ -71,9 +68,11 @@ return false

getKey(value: V): K | undefined {
getKey(value: V) {
return this.#right.get(value)
}
hasValue(value: V): boolean {
hasValue(value: V) {
return this.#right.has(value)
}
}
export default WeakBiMap

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc