biofriction-wp-theme/node_modules/undertaker/lib/registry.js

26 lines
474 B
JavaScript
Raw Permalink Normal View History

2021-10-26 14:18:09 +02:00
'use strict';
var reduce = require('object.reduce');
var validateRegistry = require('./helpers/validateRegistry');
function setTasks(inst, task, name) {
inst.set(name, task);
return inst;
}
function registry(newRegistry) {
if (!newRegistry) {
return this._registry;
}
validateRegistry(newRegistry);
var tasks = this._registry.tasks();
this._registry = reduce(tasks, setTasks, newRegistry);
this._registry.init(this);
}
module.exports = registry;