Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 3x 3x 3x 3x 3x 16x 16x 28x 28x 1x 27x 16x 16x | import {ERRORS} from '@grnsft/if-core/utils';
import {PluginInterface} from '@grnsft/if-core/types';
import {STRINGS} from '../config';
import {PluginStorage} from '../types/plugin-storage';
const {PluginInitializationError} = ERRORS;
const {NOT_INITALIZED_PLUGIN} = STRINGS;
/**
* Storage for maintaining plugins.
*/
export const pluginStorage = () => {
const storage: PluginStorage = {};
return {
/**
* Gets plugin by given `name`. If it's missing then throws error.
*/
get: (name: string) => {
const plugin = storage[name];
if (!plugin) {
throw new PluginInitializationError(NOT_INITALIZED_PLUGIN(name));
}
return plugin;
},
/**
* Saves given `plugin` with given `name`.
*/
set: function (name: string, plugin: PluginInterface) {
storage[name] = plugin;
return this;
},
};
};
|