Comparing version 0.3.21 to 0.3.23
@@ -72,2 +72,57 @@ // Generated by CoffeeScript 1.6.2 | ||
ModelCollection.prototype.reset = function(src) { | ||
var esrc, existingItem, found, i, item, newItem, src2, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _results; | ||
src2 = src.concat(); | ||
esrc = this.source().concat(); | ||
for (_i = 0, _len = esrc.length; _i < _len; _i++) { | ||
existingItem = esrc[_i]; | ||
for (i = _j = 0, _len1 = src.length; _j < _len1; i = ++_j) { | ||
newItem = src[i]; | ||
if (this._compare(existingItem, newItem)) { | ||
if (this.field.options.ref) { | ||
existingItem.set(newItem); | ||
src.splice(i, 1); | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
for (i = _k = 0, _len2 = esrc.length; _k < _len2; i = ++_k) { | ||
existingItem = esrc[i]; | ||
found = false; | ||
for (_l = 0, _len3 = src2.length; _l < _len3; _l++) { | ||
newItem = src2[_l]; | ||
if (this._compare(existingItem, newItem)) { | ||
found = true; | ||
break; | ||
} | ||
} | ||
if (!found) { | ||
this.splice(i, 1); | ||
} | ||
} | ||
_results = []; | ||
for (_m = 0, _len4 = src.length; _m < _len4; _m++) { | ||
item = src[_m]; | ||
_results.push(this.push(item)); | ||
} | ||
return _results; | ||
}; | ||
/* | ||
*/ | ||
ModelCollection.prototype._compare = function(a, b) { | ||
var aid; | ||
aid = a.get("_id"); | ||
return (aid === b._id) || (aid === b); | ||
}; | ||
/* | ||
*/ | ||
ModelCollection.prototype._onInsert = function(model) { | ||
@@ -74,0 +129,0 @@ var _this = this; |
@@ -42,3 +42,3 @@ // Generated by CoffeeScript 1.6.2 | ||
} | ||
c = new ModelCollection(this, model); | ||
c = model.get(this.field.path) || new ModelCollection(this, model); | ||
c.reset(toarray(source)); | ||
@@ -45,0 +45,0 @@ return c; |
@@ -68,2 +68,5 @@ // Generated by CoffeeScript 1.6.2 | ||
}; | ||
model.fetch = function(next) { | ||
return _this.load(model, next); | ||
}; | ||
model.reload = function(next) { | ||
@@ -70,0 +73,0 @@ return _this.reload(model, next); |
{ | ||
"name": "linen", | ||
"version": "0.3.21", | ||
"version": "0.3.23", | ||
"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.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
8105249
141
243146
57