Skip to content

hax/maps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM Version Build Status Coverage Status Downloads

maps

Some special Map implementations for ES6+

Install

npm install maps

Usage

import {HashMap} from 'maps'

class Entity {
	constructor(id) {
		this.id = id
	}
	[Symbol.for('hashCode')]() {
		return this.id
	}
	[Symbol.for('equals')](x) {
		return x instanceof Entity && x.id === this.id
	}
}

const m = new HashMap
const e1 = new Entity(42)
const e2 = new Entity(42)
const test = {}
assert(e1 !== e2)
m.set(e1, test)
assert(m.get(e2) === test)

API

Same as standard Map.

About

Some special Map implementations for ES6+

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published