2.0.2 • Published 4 years ago

smartmap v2.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

SmartMap

SmartMap is a simple and efficient indexed map for Node and browser environments.

Build Status

Installation

You may install the package via:

  • npm npm install smartmap
  • git git clone https://github.com/emmorts/smartmap

Documentation is available here

Quick start

interface MyInterface {
  id: number;
  value: number;
}

const map = new SmartMap<MyInterface>("id");

map.add(...[
  { id: 1, value: 1 },
  { id: 2, value: 4 },
  { id: 3, value: 9 }
]);

for (const item in map) {
  console.log(item);
}

/*
{
  id: 1,
  value: 1
},
{
  id: 2,
  value: 4
},
{
  id: 3,
  value: 9
}
*/

Objects can also be mapped with multiple indexes.

const map = new SmartMap<MyInterface>("id", "value");

map.add(...[
  { id: 1, value: 1 },
  { id: 2, value: 4 },
  { id: 3, value: 9 }
]);

for (const item in map.iterateBy("value")) {
  console.log(item);
}

/*
{
  id: 1,
  value: 1
},
{
  id: 2,
  value: 4
},
{
  id: 3,
  value: 9
}
*/
2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago