# @esfx/collections-hashmap

> Provides 'HashMap', a collection class that utilizes '@esfx/collection-core' and '@esfx/equatable'.

Latest version **1.0.2** (published 2022-11-01) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @esfx/collections-hashmap
pnpm add @esfx/collections-hashmap
yarn add @esfx/collections-hashmap
bun add @esfx/collections-hashmap
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-11-01 |
| First published | 2019-05-16 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 76.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 234 |
| Author | Ron Buckton |
| Maintainers | rbuckton |

## Links

- npm: https://www.npmjs.com/package/@esfx/collections-hashmap
- Repository: https://github.com/esfx/esfx
- Homepage: https://github.com/esfx/esfx#readme
- Issues: https://github.com/esfx/esfx/issues
- npm.io page: https://npm.io/package/@esfx/collections-hashmap

## Dependencies (2)

- [@esfx/equatable](https://npm.io/package/@esfx/equatable.md) ^1.0.2
- [@esfx/collection-core](https://npm.io/package/@esfx/collection-core.md) ^1.0.0

## Recent versions

- 1.0.2 (latest) — 2022-11-01
- 1.1.0-alpha.202307260322 (next) — 2023-07-26
- 1.0.0-dev.8 (dev) — 2022-10-20
- 1.1.0-alpha.202306080253 — 2023-06-08
- 1.1.0-alpha.202306061406 — 2023-06-06
- 1.1.0-alpha.202306061316 — 2023-06-06
- 1.1.0-alpha.202306051228 — 2023-06-05
- 1.1.0-alpha.202305082104 — 2023-05-08
- 1.1.0-alpha.202302091715 — 2023-02-09
- 1.1.0-alpha.202302071935 — 2023-02-07
- 1.1.0-alpha.202211291446 — 2022-11-29
- 1.1.0-alpha.202211221509 — 2022-11-22
- 1.1.0-alpha.202210252139 — 2022-10-25
- 1.0.0 — 2022-10-20
- 1.0.0-dev.7 — 2022-10-20
- … 33 more at https://npm.io/package/@esfx/collections-hashmap/versions

## README

# `@esfx/collections-hashmap`

The `@esfx/collections-hashmap` package provides `HashMap`, a collection class that utilizes `@esfx/collection-core` and `@esfx/equatable`.

# Overview

* [Installation](#installation)
* [Usage](#usage)
* [API](#api)

# Installation

```sh
npm i @esfx/collections-hashmap
```

# Usage

> NOTE: The examples below use the following definition of `Person`:
> ```ts
> import { Equatable, Equaler, Comparable, Comparer } from "@esfx/equatable";
>
> class Person {
>     constructor(firstName, lastName) {
>         this.firstName = firstName;
>         this.lastName = lastName;
>     }
>
>     toString() {
>         return `${this.firstName} ${this.lastName}`;
>     }
>
>     [Equatable.equals](other) {
>         return other instanceof Person
>             && this.lastName === other.lastName
>             && this.firstName === other.firstName;
>     }
>
>     [Equatable.hash]() {
>         return Equaler.defaultEqualer.hash(this.lastName)
>              ^ Equaler.defaultEqualer.hash(this.firstName);
>     }
>
>     [Comparable.compareTo](other) {
>         if (!(other instanceof Person)) throw new TypeError();
>         return Comparer.defaultComparer.compare(this.lastName, other.lastName)
>             || Comparer.defaultComparer.compare(this.firstName, other.firstName);
>     }
> }
> ```

## HashMap

```ts
import { HashMap } from "@esfx/collections-hashmap";

// NOTE: see definition of Person above
const obj1 = new Person("Bob", "Clark");
const obj2 = new Person("Bob", "Clark");

const set = new Map(); // native ECMAScript Map
set.set(obj1, "obj1");
set.set(obj2, "obj2");
set.size; // 2

const hashMap = new HashMap();
hashMap.set(obj1, "obj1");
hashMap.set(obj2, "obj2");
hashMap.size; // 1
```

# API

You can read more about the API [here](https://esfx.js.org/esfx/api/collections-hashmap.html).

---
_Source: https://npm.io/package/@esfx/collections-hashmap · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
