map

Provides a polyfill-style Map class compatible with legacy JavaScript environments such as Rhino or RingoJS.

The Map module implements an ES6-inspired key-value store with predictable iteration order,
offering modern APIs like set, get, delete, has, forEach, entries, and functional utilities.
It is designed for environments lacking native Map support, such as embedded test runners, script engines, or early JavaScript runtimes.

Core Features:

  • Key-based storage with insertion-order tracking.
  • Chainable and iterable methods including forEach, map, reduce, and filter.
  • Full support for functional transformations and merging/cloning operations.
  • Compatible keys(), values(), entries() for data traversal.
  • Custom sort methods: sortKeys(), sortValues(), and ordering control via reverse().

Usage Overview:

  1. Instantiate with const m = new Map();
  2. Add or update entries with set(key, value)
  3. Query data using get(key), has(key), or delete(key)
  4. Use forEach, entries, or reduce for iteration or processing

API Highlights:

  • set(key, value): Add or overwrite entries
  • get(key), has(key), delete(key): Access and manage keys
  • map(fn), filter(fn), reduce(fn, init): Functional utilities
  • clone(), merge(map): Shallow copy and merging
  • sortKeys(fn), sortValues(fn), reverse(): Ordering and control

Classes

Map