Comparing version 0.0.3 to 0.0.4
'use strict'; | ||
var Cache = module.exports = function Cache() { | ||
this._cache = {}; | ||
this._cache = {}; | ||
}; | ||
Cache.prototype.put = function Cache_put(key, value) { | ||
this._cache[key] = value; | ||
this._cache[key] = value; | ||
}; | ||
Cache.prototype.get = function Cache_get(key) { | ||
return this._cache[key]; | ||
return this._cache[key]; | ||
}; | ||
Cache.prototype.del = function Cache_del(key) { | ||
delete this._cache[key]; | ||
delete this._cache[key]; | ||
}; | ||
Cache.prototype.clear = function Cache_clear() { | ||
this._cache = {}; | ||
this._cache = {}; | ||
}; |
@@ -27,2 +27,5 @@ 'use strict'; | ||
function addItemType(name, template) { | ||
if (this._registry.get(name)) | ||
throw new Error('IsoForm.addItemType: type already exists'); | ||
var processName = 'process' + capitalizeFirstLetter(name); | ||
@@ -46,2 +49,5 @@ var processKeyword = {}; | ||
function addGroupType(name, template, closeTemplate) { | ||
if (this._registry.get(name)) | ||
throw new Error('IsoForm.addItemType: type already exists'); | ||
var processName = 'process' + capitalizeFirstLetter(name); | ||
@@ -115,2 +121,1 @@ var closeName = 'close' + capitalizeFirstLetter(name); | ||
} | ||
{ | ||
"name": "iso-form", | ||
"version": "0.0.3", | ||
"description": "An isometric, schema based form generator that can be used in the client, on the server, or even to pre-compile forms in the build phase. This is the core library that is used to register form types.", | ||
"version": "0.0.4", | ||
"description": "Generate form html, js, and json-schema all from one master schema.", | ||
"main": "lib/iso-form.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -31,2 +31,8 @@ 'use strict'; | ||
it('should throw when attempting to overwrite type', function () { | ||
should.throw(function () { | ||
isoForm.addItemType('test', 'SHOULD FAIL'); | ||
}); | ||
}); | ||
it('should create build function', function () { | ||
@@ -38,2 +44,15 @@ var form = isoForm.build({ type:'test' }); | ||
it('should recompile build function when new type added', function () { | ||
var form = isoForm.build({ type:'test' }); | ||
isoForm.addItemType('test2', 'TEST2'); | ||
var form2 = isoForm.build({ type:'test2' }); | ||
form2.isValidSchema.should.equal(true); | ||
form2.html.should.equal('TEST2'); | ||
}); | ||
it('should fail validation when unknown type used', function () { | ||
var form = isoForm.build({ type:'notatype' }); | ||
form.isValidSchema.should.equal(false); | ||
}); | ||
it('should support strings and template functions', function () { | ||
@@ -40,0 +59,0 @@ isoForm.addItemType('stringtest', 'A STRING TEMPLATE'); |
10723
216