Registry / serialization / hashmap

hashmap

JSON →
library2.4.0jsnpmunverified

The `hashmap` package provides a `HashMap` class for JavaScript, designed to store key/value pairs where keys can be of *any* data type, including objects, numbers, and dates, without the implicit stringification that occurs with plain JavaScript objects. This was a key differentiator before the introduction of native `Map` in ES6. The current stable version is 2.4.0. Given its last update was over eight years ago, the package is effectively abandoned, with no active development or release cadence. It targets both Node.js and browser environments and differentiates itself by allowing complex objects as keys without coercion.

npm install hashmap
INSTALL
IMPORT
SIG · HASHMAP
H
hashmap
serializationjavascriptv2.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HashMap
const HashMap = require('hashmap');
import { HashMap } from 'hashmap';
This package is CommonJS-only. Attempting to use ES Modules `import` syntax directly will likely result in a runtime error or `undefined` in pure ESM environments without a CJS interop layer.

This example demonstrates how to import `HashMap` using CommonJS, set and retrieve values with various key types (string, number, object), check the map's size, delete entries, and iterate over its contents.

const HashMap = require('hashmap'); // Create a new HashMap instance const map = new HashMap(); // Basic key-value pair storage map.set('stringKey', 'Hello World'); map.set(123, 'Numeric Key'); console.log('Value for "stringKey":', map.get('stringKey')); // Expected: Hello World console.log('Value for 123:', map.get(123)); // Expected: Numeric Key // Demonstrating non-stringified object keys const objKey1 = { id: 1 }; const objKey2 = { id: 2 }; map.set(objKey1, 'First object'); map.set(objKey2, 'Second object'); console.log('Value for objKey1:', map.get(objKey1)); // Expected: First object console.log('Value for objKey2:', map.get(objKey2)); // Expected: Second object // Get current size console.log('Map size:', map.size); // Expected: 4 // Delete a key-value pair map.delete('stringKey'); console.log('Map size after deletion:', map.size); // Expected: 3 // Iterate over key-value pairs console.log('Map entries:'); map.forEach(function(value, key) { console.log(` Key: ${JSON.stringify(key)}, Value: ${value}`); });
Debug
Known issues
gotchaThe `hashmap` package has not been updated in over eight years (last publish date is 8 years ago as of April 2026). This indicates it is likely abandoned, may not be compatible with newer Node.js versions or browser features, and will not receive security patches or bug fixes.
fix
For new projects or if encountering issues, consider using the native JavaScript `Map` object, which provides similar arbitrary key-type functionality and is actively maintained as part of the JavaScript standard library.
affects: >=2.4.0
deprecatedThe methods `remove(key)` and `count()` are deprecated aliases. `remove(key)` is an alias for `delete(key)`, and `count()` is an alias for the `size` property.
fix
Use `map.delete(key)` instead of `map.remove(key)` and `map.size` instead of `map.count()` for consistency and to avoid deprecated API usage.
affects: >=2.0.0
gotchaThis package is designed for CommonJS (`require`) and does not natively support ES Modules (`import`). Attempting to use `import` syntax directly in a pure ESM environment without a CJS interop layer will fail.
fix
For Node.js projects, use `const HashMap = require('hashmap');`. If integrating into a modern frontend build system, ensure your bundler (e.g., Webpack, Rollup) is configured to handle CommonJS modules.
affects: *
gotchaThe package does not ship with TypeScript type definitions (`.d.ts` files). Users in TypeScript projects will need to provide their own type declarations or install community-maintained types (if available) to avoid type errors.
fix
Create a `declarations.d.ts` file with `declare module 'hashmap';` or more specific types if needed. Alternatively, search for `@types/hashmap` on npm, though it's unlikely to exist for an abandoned package.
affects: *
Errors
Common errors & fixes
TypeError: HashMap is not a constructor
Attempting to use `import HashMap from 'hashmap';` or `import { HashMap } from 'hashmap';` in a pure ES Modules environment where the package only exports CommonJS.
fix
Use the CommonJS `require` syntax: `const HashMap = require('hashmap');`.
TypeError: map.remove is not a function
Calling the deprecated `remove()` method.
fix
Use `map.delete(key)` instead of `map.remove(key)`.
TypeError: Cannot read properties of undefined (reading 'set')
Incorrect import or `require` leading to `map` being `undefined`.
fix
Ensure `const HashMap = require('hashmap');` correctly assigns the constructor and that `new HashMap()` is called to instantiate the map before attempting to use its methods.
Upgrade
Version history
2.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Perplexity
1
Resources