Files
blog/node_modules/hexo/dist/extend/helper.js
2025-07-16 16:30:56 +00:00

34 lines
851 B
JavaScript

"use strict";
class Helper {
constructor() {
this.store = {};
}
/**
* @returns {Store} - The plugin store
*/
list() {
return this.store;
}
/**
* Get helper plugin function by name
* @param {String} name - The name of the helper plugin
* @returns {StoreFunction}
*/
get(name) {
return this.store[name];
}
/**
* Register a helper plugin
* @param {String} name - The name of the helper plugin
* @param {StoreFunction} fn - The helper plugin function
*/
register(name, fn) {
if (!name)
throw new TypeError('name is required');
if (typeof fn !== 'function')
throw new TypeError('fn must be a function');
this.store[name] = fn;
}
}
module.exports = Helper;
//# sourceMappingURL=helper.js.map