1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const lifecycle_1 = require("@stoplight/lifecycle");
|
4 | class SpecProviderRegistry {
|
5 | constructor() {
|
6 | this.contentIdentifiersRegistry = [];
|
7 | this.pathIdentifiersRegistry = [];
|
8 | }
|
9 | register(identifier) {
|
10 | const identifiersRegistry = 'path' in identifier ? this.pathIdentifiersRegistry : this.contentIdentifiersRegistry;
|
11 | identifiersRegistry.push(identifier);
|
12 | return lifecycle_1.createDisposable(() => void identifiersRegistry.splice(identifiersRegistry.indexOf(identifier), 1));
|
13 | }
|
14 | provideByContent(parsed) {
|
15 | var _a;
|
16 | return (_a = this.contentIdentifiersRegistry.find(identifier => !!identifier.content(parsed))) === null || _a === void 0 ? void 0 : _a.spec;
|
17 | }
|
18 | provideByPath(path) {
|
19 | var _a;
|
20 | return (_a = this.pathIdentifiersRegistry.find(identifier => identifier.path.test(path))) === null || _a === void 0 ? void 0 : _a.spec;
|
21 | }
|
22 | }
|
23 | exports.SpecProviderRegistry = SpecProviderRegistry;
|
24 |
|
\ | No newline at end of file |