Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaup authored Dec 16, 2024
1 parent dbf58f4 commit e2cd06f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

A wrapper around Map for hashing complex object keys by value. This allows you to reference the same Map value using objects that are deep equal but not referentially equal.

Defaults to using [hash-it](https://github.com/planttheidea/hash-it) for its key hashing function. You can supply a different hashing function in DopeMap's config (as long as it returns a `string` or `number`).

## Installation

```bash
yarn add dope-map
yarn add dope-map hash-it
```

## Usage
Expand All @@ -18,12 +20,19 @@ const dopeMap = new DopeMap();
dopeMap.set({ foo: "bar", to: "fu" }, [1, 2, 3, 4, 5]);

dopeMap.get({ foo: "bar", to: "fu" }); // [1, 2, 3, 4, 5]
dopeMap.get({ to: "fu", foo: "bar" }); // [1, 2, 3, 4, 5]
dopeMap.get({ to: "fu", foo: "bar" }); // [1, 2, 3, 4, 5], same reference
```

```javascript
import DopeMap from "dope-map";
import blazeHasher from "blazing-fast-hash-package";

const dopeMap = new DopeMap({ hashFunction: blazeHasher });
```

## Benchmark Results

This library comes with performance tradeoffs, so if your main goal is performance over efficiency, this likely isn't the right approach, especially when you are processing a large amount of data.
This library comes with performance tradeoffs that grow as the Map does.

#### 1,000 Iterations

Expand Down

0 comments on commit e2cd06f

Please sign in to comment.