Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backbone-relations

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-relations - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

56

dist/backbone-relations.js

@@ -46,15 +46,5 @@ // Generated by CoffeeScript 1.4.0

hasOne = function(model, name, rel) {
var ctor, mine, onChangeId, onChangeMine, onDestroy;
var changeId, ctor, destroy, mine;
ctor = getCtor(rel.hasOne);
mine = rel.myFk;
onChangeId = function(__, val) {
return model.set(mine, val);
};
onDestroy = function() {
model.get[name] = void 0;
if (rel.romeo) {
return model.trigger('destroy', model, model.collection);
}
return model.set(mine, null);
};
model.set[name] = function(next) {

@@ -67,4 +57,4 @@ var prev;

model.stopListening(prev, {
'change:id': onChangeId,
destroy: onDestroy
'change:id': changeId,
destroy: destroy
});

@@ -75,4 +65,4 @@ }

model.listenTo(next, {
'change:id': onChangeId,
destroy: onDestroy
'change:id': changeId,
destroy: destroy
});

@@ -82,11 +72,20 @@ }

};
(onChangeMine = function() {
return model.set[name](ctor.cache().get(model.get(mine)));
})();
ctor.cache().on('add', function(other) {
if (other.id == model.get(mine)) {
return model.set[name](other);
model.listenTo(ctor.cache(), 'add', function(other) {
if (other.id && other.id == model.get(mine)) {
return this.set[name](other);
}
});
return model.on("change:" + mine, onChangeMine);
model.on("change:" + mine, function(__, val) {
return this.set[name](ctor.cache().get(val));
});
changeId = function(__, val) {
return model.set(mine, val);
};
destroy = function() {
model.set[name](null);
if (rel.romeo) {
return model.trigger('destroy', model, model.collection);
}
};
return model.set[name](ctor.cache().get(model.get(mine)));
};

@@ -122,3 +121,3 @@ hasMany = function(model, name, rel) {

hasManyVia = function(model, name, rel) {
var attrs, ctor, mine, models, theirs, via, viaCtor,
var ctor, mine, models, theirs, via, viaCtor,
_this = this;

@@ -139,3 +138,2 @@ ctor = getCtor(rel.hasMany);

(via.filters = {})[mine] = model;
attrs = {};
via.listenTo(viaCtor.cache(), 'add', function(other) {

@@ -146,6 +144,14 @@ if (model.id && model.id == other.get(mine)) {

});
via.listenTo(viaCtor.cache(), "change:" + mine, function(other, val) {
if (model.id == val) {
return this.add(other);
}
});
via.on("change:" + mine, function(other, val) {
return this.remove(other);
});
models.listenTo(via, 'add', function(other) {
return this.add(ctor.cache().get(other.get(theirs)));
});
models.listenTo(via, 'remove', function(other, val) {
models.listenTo(via, 'remove', function(other) {
return this.remove(ctor.cache().get(other.get(theirs)));

@@ -152,0 +158,0 @@ });

{
"name": "backbone-relations",
"version": "0.0.10",
"version": "0.0.11",
"author": "Casey Foster <casey@caseywebdev.com>",

@@ -5,0 +5,0 @@ "licence": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc