1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | (function (factory) {
|
---|
9 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
10 | var v = factory(require, exports);
|
---|
11 | if (v !== undefined) module.exports = v;
|
---|
12 | }
|
---|
13 | else if (typeof define === "function" && define.amd) {
|
---|
14 | define("@angular/compiler/testing/src/pipe_resolver_mock", ["require", "exports", "tslib", "@angular/compiler"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.MockPipeResolver = void 0;
|
---|
20 | var tslib_1 = require("tslib");
|
---|
21 | var compiler_1 = require("@angular/compiler");
|
---|
22 | var MockPipeResolver = /** @class */ (function (_super) {
|
---|
23 | tslib_1.__extends(MockPipeResolver, _super);
|
---|
24 | function MockPipeResolver(refector) {
|
---|
25 | var _this = _super.call(this, refector) || this;
|
---|
26 | _this._pipes = new Map();
|
---|
27 | return _this;
|
---|
28 | }
|
---|
29 | /**
|
---|
30 | * Overrides the {@link Pipe} for a pipe.
|
---|
31 | */
|
---|
32 | MockPipeResolver.prototype.setPipe = function (type, metadata) {
|
---|
33 | this._pipes.set(type, metadata);
|
---|
34 | };
|
---|
35 | /**
|
---|
36 | * Returns the {@link Pipe} for a pipe:
|
---|
37 | * - Set the {@link Pipe} to the overridden view when it exists or fallback to the
|
---|
38 | * default
|
---|
39 | * `PipeResolver`, see `setPipe`.
|
---|
40 | */
|
---|
41 | MockPipeResolver.prototype.resolve = function (type, throwIfNotFound) {
|
---|
42 | if (throwIfNotFound === void 0) { throwIfNotFound = true; }
|
---|
43 | var metadata = this._pipes.get(type);
|
---|
44 | if (!metadata) {
|
---|
45 | metadata = _super.prototype.resolve.call(this, type, throwIfNotFound);
|
---|
46 | }
|
---|
47 | return metadata;
|
---|
48 | };
|
---|
49 | return MockPipeResolver;
|
---|
50 | }(compiler_1.PipeResolver));
|
---|
51 | exports.MockPipeResolver = MockPipeResolver;
|
---|
52 | });
|
---|
53 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGlwZV9yZXNvbHZlcl9tb2NrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXIvdGVzdGluZy9zcmMvcGlwZV9yZXNvbHZlcl9tb2NrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRzs7Ozs7Ozs7Ozs7Ozs7SUFFSCw4Q0FBdUU7SUFFdkU7UUFBc0MsNENBQVk7UUFHaEQsMEJBQVksUUFBMEI7WUFBdEMsWUFDRSxrQkFBTSxRQUFRLENBQUMsU0FDaEI7WUFKTyxZQUFNLEdBQUcsSUFBSSxHQUFHLEVBQXdCLENBQUM7O1FBSWpELENBQUM7UUFFRDs7V0FFRztRQUNILGtDQUFPLEdBQVAsVUFBUSxJQUFlLEVBQUUsUUFBbUI7WUFDMUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsSUFBSSxFQUFFLFFBQVEsQ0FBQyxDQUFDO1FBQ2xDLENBQUM7UUFFRDs7Ozs7V0FLRztRQUNNLGtDQUFPLEdBQWhCLFVBQWlCLElBQWUsRUFBRSxlQUFzQjtZQUF0QixnQ0FBQSxFQUFBLHNCQUFzQjtZQUN0RCxJQUFJLFFBQVEsR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsQ0FBQztZQUNyQyxJQUFJLENBQUMsUUFBUSxFQUFFO2dCQUNiLFFBQVEsR0FBRyxpQkFBTSxPQUFPLFlBQUMsSUFBSSxFQUFFLGVBQWUsQ0FBRSxDQ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