Backwards compatibility (2.4.0 → 3.0.0)

August 6, 2026 · View on GitHub

Audit date: 2026-08-06. Reference: hashmap 3.0.0.

Import patterns

Pattern2.4.03.0.0Notes
const HashMap = require('hashmap')CJS patch makes export the constructor
require('hashmap').HashMapSame function as default export
import HashMap from 'hashmap'⚠️ESM default; 2.4 was CJS-only publish
import { HashMap } from 'hashmap'Named export added in 3.0
import * as NS from 'hashmap'; new NS.default()Bare namespace is not constructible
<script> / IIFE new HashMap()dist/hashmap.iife.js
require('hashmap/index.js')Use package root; exports field blocks deep paths

API

API2.4.03.0.0Notes
remove()deprecated✅ alias of delete()Kept
count()deprecated✅ alias of sizeKept
type()✅ deprecatedKept
hash()❌ removedNo known dependents
sizePreferred over count()
Object keys by identity_hmuid_ expandoWeakMap side tableNo property added to user objects
clone() / copy() entry isolationshared Entry refs (bug)deep-copied entriesMatches documented 2.4 intent

TypeScript / @types/hashmap

@types/hashmap@2.3.4hashmap@3.0.0 bundled
Module shapeexport = HashMapexport default + export { HashMap }
GenericsHashMap<TKey, TValue>HashMap with unknown keys/values (use inference at call sites)
hash()presentremoved
sizenot in DT typessize: number
count()primary in DTdeprecated

Migration: npm uninstall @types/hashmap. Types ship with the package since 3.0.0.

// Before (@types/hashmap)
import HashMap = require('hashmap')
const map = new HashMap<string, number>()

// After (bundled types)
import HashMap from 'hashmap'
const map = new HashMap<string, number>()  // still works; keys/values are typed at use sites

Smoke tests (built artifact)

Run after npm run build:

node -e "const H=require('./dist/hashmap.cjs'); console.assert(typeof H==='function'&&H===H.HashMap)"
node -e "const {HashMap}=require('./dist/hashmap.cjs'); console.assert(typeof HashMap==='function')"
node --input-type=module -e "import H,{HashMap as N} from './dist/hashmap.js'; console.assert(H===N)"

Encoded in src/hashmap.test.tspackage import interop.

Dependent audit commands

gh search code "require('hashmap')" --limit 50
gh search code "from 'hashmap'" --limit 50
npm view hashmap version
npm view @types/hashmap version