UNPKG

injection-js

Version:

Dependency Injection library for JavaScript and TypeScript

52 lines 1.56 kB
/** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { stringify } from './facade/lang'; var _THROW_IF_NOT_FOUND = new Object(); export var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND; // tslint:disable-next-line:class-name no-use-before-declare var _NullInjector = /** @class */ (function () { function _NullInjector() { } _NullInjector.prototype.get = function (token, notFoundValue) { if (notFoundValue === void 0) { notFoundValue = _THROW_IF_NOT_FOUND; } if (notFoundValue === _THROW_IF_NOT_FOUND) { throw new Error("No provider for " + stringify(token) + "!"); } return notFoundValue; }; return _NullInjector; }()); /** * @whatItDoes Injector interface * @howToUse * ``` * const injector: Injector = ...; * injector.get(...); * ``` * * @description * For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}. * * ### Example * * {@example core/di/ts/injector_spec.ts region='Injector'} * * `Injector` returns itself when given `Injector` as a token: * {@example core/di/ts/injector_spec.ts region='injectInjector'} * * @stable */ var Injector = /** @class */ (function () { function Injector() { } Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND; Injector.NULL = new _NullInjector(); return Injector; }()); export { Injector }; //# sourceMappingURL=injector.js.map