Comparing version 0.3.13 to 0.3.15
@@ -12,3 +12,5 @@ // Generated by CoffeeScript 1.6.2 | ||
*/ | ||
function Cache() { | ||
function Cache(model, _prepData) { | ||
this.model = model; | ||
this._prepData = _prepData; | ||
this._data = {}; | ||
@@ -18,5 +20,19 @@ } | ||
/* | ||
this is more of an optimization - primes the | ||
caches before persisting - only necessary if the model | ||
is being fetched a remote service | ||
*/ | ||
Cache.prototype.prepare = function() { | ||
if (this._prepared) { | ||
return; | ||
} | ||
return this.store(JSON.parse(JSON.stringify(this._prepData))); | ||
}; | ||
/* | ||
*/ | ||
Cache.prototype.clear = function() { | ||
@@ -55,3 +71,3 @@ this._data = {}; | ||
for (key in compData) { | ||
if (this._data[key] == compData[key]) { | ||
if (this._data[key] === compData[key]) { | ||
continue; | ||
@@ -58,0 +74,0 @@ } |
@@ -44,2 +44,3 @@ // Generated by CoffeeScript 1.6.2 | ||
options.model._cache.prepare(); | ||
payload = this._getPayload(options); | ||
@@ -46,0 +47,0 @@ model = payload.model; |
@@ -60,3 +60,3 @@ // Generated by CoffeeScript 1.6.2 | ||
model._memos = new MemoDictionary(); | ||
model._cache = new Cache(); | ||
model._cache = new Cache(model, data); | ||
model.load = function(next) { | ||
@@ -68,4 +68,3 @@ return _this.load(model, next); | ||
}; | ||
model._cache.store(JSON.parse(JSON.stringify(data))); | ||
return model.on("watching", function(property) { | ||
return model._watching = function(property) { | ||
var _ref; | ||
@@ -78,3 +77,3 @@ | ||
}, function() {}) : void 0; | ||
}); | ||
}; | ||
}; | ||
@@ -81,0 +80,0 @@ |
{ | ||
"name": "linen", | ||
"version": "0.3.13", | ||
"version": "0.3.15", | ||
"description": "Linen (line-in) maps API's to [bindable](/classdojo/bindable.js) `objects`, and `collections`. At [classdojo](http://classdojo.com), we use `linen` to abstract our API from front-end, so we don't necessarily depend on any sort of API while developing new components. This allows us to rapidly build prototypes which can be wired up later.", | ||
@@ -23,3 +23,4 @@ "main": "./lib/index.js", | ||
"expect.js": "~0.2.0", | ||
"mocha": "~1.12.0" | ||
"mocha": "~1.12.0", | ||
"benchmark": "~1.0.0" | ||
}, | ||
@@ -26,0 +27,0 @@ "dependencies": { |
@@ -29,2 +29,21 @@ var linen = require("../.."), | ||
}); | ||
it("can cast fields with a map", function() { | ||
var m = linen.schema({ | ||
"bool": "boolean", | ||
"str": "string", | ||
"num": "number", | ||
$map: function() { | ||
return { | ||
bool: 0, | ||
str: 0, | ||
num: "0" | ||
} | ||
} | ||
}).model(); | ||
expect(m.get("bool")).to.be(false) | ||
expect(m.get("str")).to.be("0") | ||
expect(m.get("num")).to.be(0); | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
115121
111
2837
3