Skip to content

Commit

Permalink
feat: enforce unique names for node registration
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeKittens committed Oct 1, 2015
1 parent f79b812 commit a957efb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ var Gustav = (function () {
// TODO: new type of registration that's just a singleton
// Just calls NodeFactory and returns the symbol
Gustav.prototype.register = function (type, name, factory) {
var _this = this;
// TODO: Return some sort of object so this can be chained
// let splitText = SplitText()
// .addDep(fetchPageText);
var _this = this;
// Names must be unique
if (this.registeredNodes[type].indexOf(name)) {
throw new Error(name + ' already registered');
}
this.registeredNodes[type].push(name);
return function () {
var config = [];
Expand Down
5 changes: 5 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class Gustav {
// TODO: Return some sort of object so this can be chained
// let splitText = SplitText()
// .addDep(fetchPageText);

// Names must be unique
if (this.registeredNodes[type].indexOf(name)) {
throw new Error(name + ' already registered');
}
this.registeredNodes[type].push(name);

return (...config) => {
Expand Down

0 comments on commit a957efb

Please sign in to comment.