aggregate-map
v1.0.0
Published
Read-only ES6 Map implementation that aggregates results from multiple Maps in O(n)
Downloads
5
Readme
Aggregate Map
A read-only ES6 Map implementation that aggregates results from multiple Maps in O(n)
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>()
}