mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-10 06:49:19 +00:00
23 lines
458 B
JavaScript
23 lines
458 B
JavaScript
'use strict';
|
|
|
|
var BaseNode = require('./base').Node;
|
|
|
|
exports.BaseNode = BaseNode;
|
|
|
|
var constructors = {
|
|
local: require('./local').Node
|
|
};
|
|
|
|
exports.register = function(type, constructor) {
|
|
constructors[type] = constructor;
|
|
};
|
|
|
|
exports.createNode = function(params) {
|
|
if (params.type in constructors === false) {
|
|
throw new Error('Unknown node type: ' + params.type);
|
|
}
|
|
|
|
var Constructor = constructors[params.type];
|
|
return new Constructor(params);
|
|
};
|