registerPlugins(plugins)
Registers plugins and returns new instance of self (cacheInstance) extended with functionalities provided by plugins.
Arguments
plugins
(array): Array of plugins.
Returns
(cacheInstance): A new instance of cacheInstance. New instance of cache, like the original one, is immutable (using Object.freeze).
Throws
When plugins are not passed as an array.
When any of the plugins won't contain either
hooks
orcreateExtensions
method.When any of the plugins will try do add a method that already exists (which would overwrite it).
Example
// assuming that you already have cache instance and some plugins prepared
// plugin adds additional method `foo`
const cacheWithPlugins = cache.registerPlugins([ plugin ]);
cacheWithPlugins === cache; // false
typeof cacheWithPlugins.foo; // function
typeof cache.foo; // undefined
Last updated