OrdMap
Map data structure that remembers the order keys/values are set. Allows for easy access of first and last keys/values and iteration in order of insertion. Comes with type declarations for TypeScript and extends native Map class.
npm
npm i --save ord-map
yarn
yarn add ord-map
Usage
; ; // The order of keys set are rememberedmap.set"b", 3;map.set"_", 01;map.set"a", 1;console.assertmap.firstKey === "b";console.assertmap.firstValue === 3;console.assertmap.lastKey === "a";console.assertmap.lastValue === 1; // Supports any key and value that built-in map supportsmap.settrue, Number; // Setting existing keys will not change their positionmap.set"b", 4;console.assertmap.firstKey === "b"; // Iterating will iterate values in the order they were setfor of map.entries
For full API reference, see OrdMap.ts.
Testing
Run npm run test
.
Building
Run npm run build
. The built files will be in dist
.