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 hashmapVerified import paths — ran on the pinned version, not inferred.
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.
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.
Use `map.delete(key)` instead of `map.remove(key)` and `map.size` instead of `map.count()` for consistency and to avoid deprecated API usage.
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.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.
Use the CommonJS `require` syntax: `const HashMap = require('hashmap');`.Use `map.delete(key)` instead of `map.remove(key)`.
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.No dependency data recorded yet.