serviceCollection.js 828 B

1234567891011121314151617181920212223
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. export class ServiceCollection {
  6. constructor(...entries) {
  7. this._entries = new Map();
  8. for (let [id, service] of entries) {
  9. this.set(id, service);
  10. }
  11. }
  12. set(id, instanceOrDescriptor) {
  13. const result = this._entries.get(id);
  14. this._entries.set(id, instanceOrDescriptor);
  15. return result;
  16. }
  17. has(id) {
  18. return this._entries.has(id);
  19. }
  20. get(id) {
  21. return this._entries.get(id);
  22. }
  23. }