Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/ui/info-helper/src/ |
Upload File : |
import { FeaturePromoter } from './feature-promoter'; import type { FeaturePromoterConfiguration } from './types/configurations'; export class FeaturePromotersRegistry { static #promoters: Array<FeaturePromoter> = []; static register(promoter: FeaturePromoter): void { if (!FeaturePromotersRegistry.exist(promoter)) { FeaturePromotersRegistry.#promoters.push(promoter); } } static exist(promoter: FeaturePromoter): boolean { return FeaturePromotersRegistry.#promoters.find((savedPromoter) => savedPromoter === promoter); } static getPromoter(config: FeaturePromoterConfiguration): FeaturePromoter { let promoter; FeaturePromotersRegistry.#promoters.forEach((savedPromoter) => { let isSavedPromoter = true; Object.keys(savedPromoter.getOptions()).forEach((key) => { if (savedPromoter.getOptions()[key] !== config[key]) { isSavedPromoter = false; } }); if (isSavedPromoter) { promoter = savedPromoter; } }); if (promoter instanceof FeaturePromoter) { return promoter; } promoter = new FeaturePromoter(config); FeaturePromotersRegistry.register(promoter); return promoter; } static getLastPromoter(): ?FeaturePromoter { const count = this.#promoters.length; return this.#promoters[count - 1] ?? null; } }