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

backbone.rel

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone.rel - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

36

backbone.rel.js

@@ -10,3 +10,2 @@ /**

, root = this
, cache = {}
, _ = root._;

@@ -24,25 +23,2 @@

/**
* Computes the caching key
*
* @param {Model|Collection} self
* @param {String} key
* @return {String}
*/
function cacheId(self, key) {
return [self.cid, key].join('-');
}
/**
* Creates a handler that cleans the cache
*
* @param {String} cache_id
* @return {Function}
*/
function expireCache(cache_id) {
return function () {
delete cache[cache_id];
};
}
/**
* Get the relationship options

@@ -131,4 +107,3 @@ *

RelHandler.prototype.handleHasMany = function () {
var options = getOptions(this.self, 'hasMany', this.key)
, cache_id;
var options = getOptions(this.self, 'hasMany', this.key);

@@ -147,10 +122,3 @@ function filter(el) {

cache_id = cacheId(this.self, this.key);
if (!cache[cache_id]) {
cache[cache_id] = options.collection.filter(_.bind(options.filter || filter, this.self));
options.collection.bind('all', expireCache(cache_id));
}
return cache[cache_id];
return options.collection.filter(_.bind(options.filter || filter, this.self));
};

@@ -157,0 +125,0 @@

2

package.json
{
"name": "backbone.rel",
"description": "Lightweight relationship assistant for your backbone applications",
"version": "0.1.1",
"version": "0.1.2",
"author": "Pau ramon <masylum@gmail.com>",

@@ -6,0 +6,0 @@ "contributors": ["Maxim lolls <collsmaxim@gmail.com>"],

@@ -28,10 +28,2 @@ /*global it, describe, before, beforeEach*/

it('should expire the cache', function () {
assert.deepEqual(_.pluck(users.get(0).rel('tasks'), 'id'), [2, 4]);
tasks.add({id: 6, user_id: 0}, {silent: true});
assert.deepEqual(_.pluck(users.get(0).rel('tasks'), 'id'), [2, 4]);
tasks.add({id: 7, user_id: 0});
assert.deepEqual(_.pluck(users.get(0).rel('tasks'), 'id'), [2, 4, 6, 7]);
});
it('returns the owned projects for a given user', function () {

@@ -38,0 +30,0 @@ assert.deepEqual(_.pluck(users.get(0).rel('owned_projects'), 'id'), [0, 1]);

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