mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-11 05:19:18 +00:00
19 lines
386 B
JavaScript
19 lines
386 B
JavaScript
|
'use strict';
|
||
|
|
||
|
var constructors = {
|
||
|
local: require('./local').Node
|
||
|
};
|
||
|
|
||
|
exports.register = function(type, constructor) {
|
||
|
constructor[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);
|
||
|
};
|