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

backbone-hypermedia

Package Overview
Dependencies
Maintainers
6
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-hypermedia - npm Package Compare versions

Comparing version 0.4.3 to 0.4.4

2

package.json

@@ -55,3 +55,3 @@ {

"main": "src/backbone-hypermedia-amd.js",
"version": "0.4.3",
"version": "0.4.4",
"license": "MIT",

@@ -58,0 +58,0 @@ "repository": {

@@ -371,3 +371,5 @@ define(function (require) {

expect(json.scope[0]['some-rel']).toBeDefined();
expect(json.scope[0]['some-rel'] instanceof Backbone.Model).toBeFalsy();
expect(json.scope[1]['some-rel']).toBeDefined();
expect(json.scope[1]['some-rel'] instanceof Backbone.Model).toBeFalsy();
});

@@ -374,0 +376,0 @@ });

@@ -153,2 +153,8 @@ /*!

}
} else if (context && context instanceof Array) {
for (var j = 0; j < context.length; j++) {
if(context[j][key]){
jsonContext[j][key] = context[j][key].toJSON();
}
}
}

@@ -155,0 +161,0 @@ });

@@ -1,2 +0,2 @@

!function(a){"object"==typeof exports?module.exports=a(require("backbone"),require("underscore"),require("jquery")):"function"==typeof define&&define.amd&&define(["backbone","underscore","jquery"],a)}(function(a,b,c){a.HypermediaModel=a.Model.extend({initialize:function(){this.followed=!1},follow:function(g){var h=[],i=this;if(this.links)for(var j=b.keys(this.links),k=0;k<j.length;k++){var l,m,n=j[k];if(!g||b.contains(g,n)){if(n.split(".").length>1){var o,p=n.split(".")[0];if(n=n.split(".")[1],l=this.get(p),!l)continue;if(l instanceof Array){for(var q=0;q<l.length;q++)o=l[q],m=o.links,f(h,m,d(i.links[j[k]]),o,n,e(i.links[j[k]]));continue}if(l instanceof a.Collection){for(var r=0;r<l.length;r++)o=l[r],m=o.get("links"),f(h,m,d(i.links[j[k]]),o,n,e(i.links[j[k]]));continue}m=l instanceof a.Model?l.get("links"):l.links}else l=this,m=this.get("links");f(h,m,d(this.links[j[k]]),l,n,e(this.links[j[k]]))}}if(h.length)return c.when.apply(c,h).then(function(){i.followed=!0,i.trigger("follow",i)});var s=c.Deferred();return s.resolve(),s.promise()},fetch:function(b){var c=this;return a.Model.prototype.fetch.call(this,b).then(function(){return b?c.follow(b.follow):c.follow()})},sync:function(b,c,d){return this.mediaType&&(d.accepts={json:this.mediaType},("create"===b||"update"===b||"patch"===b)&&(d.contentType=this.mediaType)),a.sync(b,c,d)},toJSON:function(){var d=a.Model.prototype.toJSON.apply(this,arguments);if(d=c.extend(!0,{},d),this.links){var e=b.keys(this.links),f=this;b.each(e,function(a){var b,c;if(a.split(".").length>1){var e=a.split(".")[0];a=a.split(".")[1],b=f.get(e),c=d[e]}else b=f,c=d;var g=-1!==a.indexOf("[]",a.length-2);if(g&&(a=a.substr(0,a.length-2)),b&&b[a])if(g){c[a]=[];for(var h=0;h<b[a].length;h++)c[a].push(b[a][h].toJSON())}else c[a]=b[a].toJSON()})}return d}}),a.HypermediaCollection=a.Collection.extend({fetch:function(b){var d=this;return a.Collection.prototype.fetch.call(this,b).then(function(){return c.when.apply(c,d.chain().filter(function(b){return b instanceof a.HypermediaModel}).map(function(a){return b&&b.follow?a.follow(b.follow):a.follow()}).value())}).then(function(){d.trigger("follow",d)})},sync:function(b,c,d){return this.mediaType&&(d.accepts={json:this.mediaType}),a.sync(b,c,d)}});var d=function(a){return b.isFunction(a)?a:a?a.model:void 0},e=function(a){return b.isFunction(a)?{}:a?a.options:void 0},f=function(a,c,d,e,f,g){var h=-1!==f.indexOf("[]",f.length-2);h&&(f=f.substr(0,f.length-2));var i=b.filter(c,function(a){return a.rel==f});if(i.length>1&&!h)throw new Error("Found more than one link with rel '"+f+"', but the link was not specified as allowing multiple values. To allow multiple values, suffix the link key with '[]'.");for(var j=0;j<i.length;j++){var k=new d,l=b.isFunction(k.urlFactory)?k.urlFactory:b.identity;h?(e[f]||(e[f]=[]),e[f].push(k)):e[f]=k;var m=b.extend({},g,{url:l.call(k,i[j].href)});a.push(k.fetch(m))}}});
!function(a){"object"==typeof exports?module.exports=a(require("backbone"),require("underscore"),require("jquery")):"function"==typeof define&&define.amd&&define(["backbone","underscore","jquery"],a)}(function(a,b,c){a.HypermediaModel=a.Model.extend({initialize:function(){this.followed=!1},follow:function(g){var h=[],i=this;if(this.links)for(var j=b.keys(this.links),k=0;k<j.length;k++){var l,m,n=j[k];if(!g||b.contains(g,n)){if(n.split(".").length>1){var o,p=n.split(".")[0];if(n=n.split(".")[1],l=this.get(p),!l)continue;if(l instanceof Array){for(var q=0;q<l.length;q++)o=l[q],m=o.links,f(h,m,d(i.links[j[k]]),o,n,e(i.links[j[k]]));continue}if(l instanceof a.Collection){for(var r=0;r<l.length;r++)o=l[r],m=o.get("links"),f(h,m,d(i.links[j[k]]),o,n,e(i.links[j[k]]));continue}m=l instanceof a.Model?l.get("links"):l.links}else l=this,m=this.get("links");f(h,m,d(this.links[j[k]]),l,n,e(this.links[j[k]]))}}if(h.length)return c.when.apply(c,h).then(function(){i.followed=!0,i.trigger("follow",i)});var s=c.Deferred();return s.resolve(),s.promise()},fetch:function(b){var c=this;return a.Model.prototype.fetch.call(this,b).then(function(){return b?c.follow(b.follow):c.follow()})},sync:function(b,c,d){return this.mediaType&&(d.accepts={json:this.mediaType},"create"!==b&&"update"!==b&&"patch"!==b||(d.contentType=this.mediaType)),a.sync(b,c,d)},toJSON:function(){var d=a.Model.prototype.toJSON.apply(this,arguments);if(d=c.extend(!0,{},d),this.links){var e=b.keys(this.links),f=this;b.each(e,function(a){var b,c;if(a.split(".").length>1){var e=a.split(".")[0];a=a.split(".")[1],b=f.get(e),c=d[e]}else b=f,c=d;var g=-1!==a.indexOf("[]",a.length-2);if(g&&(a=a.substr(0,a.length-2)),b&&b[a])if(g){c[a]=[];for(var h=0;h<b[a].length;h++)c[a].push(b[a][h].toJSON())}else c[a]=b[a].toJSON();else if(b&&b instanceof Array)for(var i=0;i<b.length;i++)b[i][a]&&(c[i][a]=b[i][a].toJSON())})}return d}}),a.HypermediaCollection=a.Collection.extend({fetch:function(b){var d=this;return a.Collection.prototype.fetch.call(this,b).then(function(){return c.when.apply(c,d.chain().filter(function(b){return b instanceof a.HypermediaModel}).map(function(a){return b&&b.follow?a.follow(b.follow):a.follow()}).value())}).then(function(){d.trigger("follow",d)})},sync:function(b,c,d){return this.mediaType&&(d.accepts={json:this.mediaType}),a.sync(b,c,d)}});var d=function(a){return b.isFunction(a)?a:a?a.model:void 0},e=function(a){return b.isFunction(a)?{}:a?a.options:void 0},f=function(a,c,d,e,f,g){var h=-1!==f.indexOf("[]",f.length-2);h&&(f=f.substr(0,f.length-2));var i=b.filter(c,function(a){return a.rel==f});if(i.length>1&&!h)throw new Error("Found more than one link with rel '"+f+"', but the link was not specified as allowing multiple values. To allow multiple values, suffix the link key with '[]'.");for(var j=0;j<i.length;j++){var k=new d,l=b.isFunction(k.urlFactory)?k.urlFactory:b.identity;h?(e[f]||(e[f]=[]),e[f].push(k)):e[f]=k;var m=b.extend({},g,{url:l.call(k,i[j].href)});a.push(k.fetch(m))}}});
//# sourceMappingURL=backbone-hypermedia-amd.min.map

Sorry, the diff of this file is not supported yet

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