helper.js 426 B

12345678910111213141516171819202122
  1. 'use strict';
  2. function Helper() {
  3. this.store = {};
  4. }
  5. Helper.prototype.list = function() {
  6. return this.store;
  7. };
  8. Helper.prototype.get = function(name) {
  9. return this.store[name];
  10. };
  11. Helper.prototype.register = function(name, fn) {
  12. if (!name) throw new TypeError('name is required');
  13. if (typeof fn !== 'function') throw new TypeError('fn must be a function');
  14. this.store[name] = fn;
  15. };
  16. module.exports = Helper;