index.js 633 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. function DefaultRegistry() {
  3. if (this instanceof DefaultRegistry === false) {
  4. return new DefaultRegistry();
  5. }
  6. this._tasks = {};
  7. }
  8. DefaultRegistry.prototype.init = function init(taker) {};
  9. DefaultRegistry.prototype.get = function get(name) {
  10. return this._tasks[name];
  11. };
  12. DefaultRegistry.prototype.set = function set(name, fn) {
  13. return this._tasks[name] = fn;
  14. };
  15. DefaultRegistry.prototype.tasks = function tasks() {
  16. var self = this;
  17. return Object.keys(this._tasks).reduce(function(tasks, name) {
  18. tasks[name] = self.get(name);
  19. return tasks;
  20. }, {});
  21. };
  22. module.exports = DefaultRegistry;