nodejs-google-adwords
Version:
Google Ads API Client Library for Node.js
34 lines (33 loc) • 930 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* TODO: improve the static types
*
* @author dulin
* @class RegistryService
* @template T
*/
var RegistryService = /** @class */ (function () {
function RegistryService(registry) {
this.registry = registry;
}
RegistryService.init = function () {
if (this.instance) {
return this.instance;
}
this.instance = new RegistryService({});
return this.instance;
};
RegistryService.prototype.register = function (service) {
this.registry[service.name] = service;
return this;
};
RegistryService.prototype.get = function (key) {
if (!(key in this.registry)) {
throw new Error("No service found for " + key);
}
return this.registry[key];
};
return RegistryService;
}());
exports.RegistryService = RegistryService;