Fast Map built for keys that are always fixed size uniformly distributed buffers.

Related tags

Maps turbo-hash-map
Overview

turbo-hash-map

Fast Map built for keys that are always fixed size uniformly distributed buffers.

npm install turbo-hash-map

Uses a prefix trie to map hashes to values in an effectice manner.

Usage

const HashMap = require('turbo-hash-map')

const map = new HashMap()

map.set(hash('hello world'), 'a value')

function hash (val) { // any hash algo without practical collisions will work
  return crypto.createHash('sha256').update(val).digest()
}

API

const m = new HashMap()

Create a new HashMap. The HashMap follows the api of a JS map, except keys are buffers containing hashes.

m.set(hash, value)

Insert a value with a hash as the key. Hash should be a fixed size buffer.

const value = m.get(hash)

Get the value out. Returns undefined if the value cannot be found.

const bool = m.has(hash)

Does the map have it?

const deleted = m.delete(hash)

Delete an entry.

m.size

How many entries?

m.clear()

Delete all entries.

...m

Iterate the map. Yields arrays of [hash, value].

...m.keys()

Key (hash) iterator.

...m.values()

Value iterator.

Performance

There is a bench included. On my macbook this yields

turbo-hash-map-set: 2.068s
turbo-hash-map-get: 1.931s
js-map-set: 16.078s
js-map-get: 6.626s

License

MIT

You might also like...

A map tool with real-time collaboration 🗺️

Mapus Maps with real-time collaboration 🗺️ Mapus is a tool to explore and annotate collaboratively on a map. You can draw, add markers, lines, areas,

Jan 4, 2023

3D web map rendering engine written in TypeScript using three.js

3D web map rendering engine written in TypeScript using three.js

3D web map rendering engine written in TypeScript using three.js

Dec 30, 2022

Mind elixir is a free open source mind map core.

Mind elixir is a free open source mind map core.

Mind-elixir is a framework agnostic mind map core

Jan 2, 2023

A library that makes Image Map Area responsive

A library that makes Image Map Area responsive

Jan 21, 2022

Greasemonkey script to allow marking items on the interactive map of Elden Ring as completed.

Greasemonkey script to allow marking items on the interactive map of Elden Ring as completed.

Greasemonkey script (or Tampermonkey) to allow marking items on the interactive map of Elden Ring as completed. The interactive map is a Fextralife-project, all credits for the map go to them.

Jun 19, 2022

Interactive map overlay for finding secrets hidden around the world of Lost Ark.

Interactive map overlay for finding secrets hidden around the world of Lost Ark.

Lostark Map Overlay This is an interactive map overlay which is resizable, movable and can be kept up during gameplay for finding secrets hidden aroun

Dec 29, 2022

:ukraine: A self-hosted app for keeping track of employee wellbeing and dislocation during the Russo-Ukrainian war, with an interactive map.

:ukraine: A self-hosted app for keeping track of employee wellbeing and dislocation during the Russo-Ukrainian war, with an interactive map.

Helping organizations stay together and help their members in times of disaster On February 24th, 2022, the lives of the entire Ukrainian nation were

Dec 15, 2022

Generates an embeddable map that displays business info from an OSM object id.

# OSM Business Card Generates an embeddable map that displays business info from an OSM object id. Loads object type (n/w/r) and id from url parameter

May 26, 2022

Simple location picker on Leaflet map

Simple location picker on Leaflet map

Leaflet Location Picker Simple location picker with Leaflet map Usage: labelInsert a Geo Location input id="geoloc" type="text" value="" / /lab

Nov 17, 2022
Comments
  • Potential Usecases

    Potential Usecases

    Hey, thanks for sharing this openly. I wanted to check if I can extend this to create an in-memory key-value DB or would that be a really bad idea?

    • How will it perform for larger values
    • Any checks for memory overflow when setting data and how would I implement those

    Thanks.

    opened by ChakshuGautam 0
Owner
Mathias Buus
Rød grød med fløde
Mathias Buus
Converts geojson to svg string given svg viewport size and maps extent.

geojson2svg Converts geojson to svg string given svg viewport size and maps extent. Check world map, SVG scaled map and color coded map examples to de

Gagan Bansal 163 Dec 17, 2022
jQuery Vector Map Library

This project is a heavily modified version of jVectorMap as it was in April of 2012. I chose to start fresh rather than fork their project as my inten

10 Best Design 1.8k Dec 28, 2022
jQuery Vector Map Library

This project is a heavily modified version of jVectorMap as it was in April of 2012. I chose to start fresh rather than fork their project as my inten

10 Best Design 1.8k Dec 28, 2022
JavaScript WebGL 3D map rendering engine

VTS Browser JS is a powerful JavaScript 3D map rendering engine with a very small footprint (about 163 kB of gziped JS code). It provides almost all f

Melown Technologies, SE 203 Dec 7, 2022
Mapbox Visual for Power BI - High performance, custom map visuals for Power BI dashboards

Mapbox Visual for Microsoft Power BI Make sense of your big & dynamic location data with the Mapbox Visual for Power BI. Quickly design high-performan

Mapbox 121 Nov 22, 2022
A Node.js map tile library for PostGIS and torque.js, with CartoCSS styling

Windshaft A Node.js map tile library for PostGIS and torque.js, with CartoCSS styling. Can render arbitrary SQL queries Generates image and UTFGrid in

CARTO 306 Dec 22, 2022
Add time dimension capabilities on a Leaflet map.

Leaflet TimeDimension Add time dimension capabilities on a Leaflet map. Examples and basic usage API L.Map L.TimeDimension L.TimeDimension.Layer L.Tim

SOCIB public code 379 Dec 23, 2022
Serverless raster and vector map tile generation using Mapnik and AWS Lambda

tilegarden ??️ ?? Contents About Usage Deployment to AWS Additional Configuration Options Required AWS Permissions Features Configuration Selection an

Azavea 89 Dec 22, 2022
Lightweight Node.js isochrone map server

Galton Lightweight Node.js isochrone server. Build isochrones using OSRM, Turf and concaveman. Francis Galton is the author of the first known isochro

Urbica 266 Dec 17, 2022
A pluggable Node.js map tile server.

TileStrata TileStrata is a pluggable "slippy map" tile server that emphasizes code-as-configuration. The primary goal is painless extendability. It's

Natural Atlas 409 Dec 30, 2022