1.0.0 ā€¢ Published 6 years ago

aggregate-map v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

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>()
}