import { ServiceIdentifier } from './instantiation' ; import { Descriptor } from './descriptors' ; export class ServiceCollection { private _entries = new Map < ServiceIdentifier < any > , any > ( ) ; constructor ( ... entries ) { for ( let [ id , service ] of entries ) { this . set ( id , service ) ; } } set < T > ( id , instanceOrDescriptor ) { const result = this . _entries . get ( id ) ; this . _entries . set ( id , instanceOrDescriptor ) ; return result ; } forEach ( callback ) { this . _entries . forEach ( ( value , key ) => callback ( key , value ) ) ; } has ( id ) { return this . _entries . has ( id ) ; } get < T > ( id ) { return this . _entries . get ( id ) ; } }