UNPKG

@exadel/esl

Version:

Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components

40 lines (39 loc) 1.51 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { memoize } from '../../esl-utils/decorators'; /** * ESLShareActionRegistry class to store share actions * @author Dmytro Shovchko */ export class ESLShareActionRegistry { /** Returns action registry instance */ static get instance() { return new ESLShareActionRegistry(); } constructor() { this.actionsMap = new Map(); } /** Registers action */ register(action) { if (!action.is) throw new Error('[ESL]: `ESLAction.is` is not defined'); this.actionsMap.set(action.is, new action()); } /** Checks if action is registered for passed name */ has(name) { return this.actionsMap.has(name); } /** Gets the action by name */ get(name) { if (!name) return null; return this.actionsMap.get(name.toLowerCase()) || null; } } __decorate([ memoize() ], ESLShareActionRegistry, "instance", null);