aggregate-map
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Aggregate Map

npm downloads build codecov dependencies node code style: prettier semantic-release license

A read-only ES6 Map implementation that aggregates results from multiple Maps in O(n)

📖 API Documentation

Simple Example:

const maps = [new Map([['foo', 'bar']]), new Map([['baz', 'qux']])]

const aggregate = new AggregateMap(maps)

aggregate.get('baz') // 'qux'
aggregate.has('foo') // true

for (const [key, value] of aggregate) {
  console.log(key, value) // ['foo', 'bar'] ['baz', 'qux']
}

Advanced Example:

import iterate from 'iterare'

class Repository {
  public pullRequests: ReadonlyMap<string, PullRequest> = new AggregateMap({
    [Symbol.iterator]: () => iterate(this.remotes).map(remote => remote.pullRequests),
  })
  private remotes = new Map<string, RepositoryRemote>()
}

class RepositoryRemote {
  public pullRequests = new Map<string, PullRequest>()
}

Readme

Keywords

none

Package Sidebar

Install

npm i aggregate-map

Weekly Downloads

8

Version

1.0.0

License

ISC

Last publish

Collaborators

  • felixfbecker