backbone-jsonapi
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -1,2 +0,2 @@ | ||
/*! backbone-jsonapi - v 0.1.1 - Copyright guillaumervls 2013-10-14 */ | ||
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){var c=a("./toolbox");b.exports=function(a,d){if(!a||!d)throw new Error("Backbone and/or Lodash (or Underscore) are not loaded...");return c=c(d),a.Collection.prototype.parse=function(a){if(void 0!==a){var b=c.parse(a),d=c.getMainCollection(a);return b[d]}},a.Model.prototype.parse=function(a){if(void 0!==a){var b=c.parse(a),d=c.getMainCollection(a);return b[d][0]}},b.exports},b.exports.VERSION="0.1.1"},{"./toolbox":2}],2:[function(a,b){var c;b.exports=function(a){return c=a,c.forOwn=c.forOwn||function(a,b){var d;try{d=c.keys(a)}catch(e){return}c.each(d,function(c){b(a[c],c)})},b.exports};var d=b.exports.findById=function(a,b){return c.find(a,function(a){return a.id===b})},e=b.exports.applyTemplateUrl=function(a,b,c){var d=new RegExp("{"+a+"\\.(.+?)}","g"),e=d.exec(b);if(null!==e){if(void 0===c[e[1]]&&void 0===c.links[e[1]])throw new Error("Template required a property not present in data object");b=b.substr(0,e.index)+(c.links[e[1]]||c[e[1]])+b.substr(d.lastIndex)}return b},f=b.exports.processLink=function(a,b,f){var g=f.split("."),h=g[0],i=g[1];return c.each(a[h],function(c){if(c.links=c.links||{},void 0!==c.links[i]){var f=d(a[b.type],c.links[i]);void 0!==f&&(c[i]=f)}c.links[i]=e(h,b.href,c)}),a};b.exports.parse=function(a){return c.forOwn(a.links,function(b,c){f(a,b,c)}),a},b.exports.getMainCollection=function(a){var b=c.without(c.keys(a),"links","meta"),d=c.pluck(c.values(a.links),"type");return c.difference(b,d)[0]}},{}],3:[function(a,b){b.exports=a("./backbone-jsonapi"),"function"==typeof define&&define.amd?define(["Backbone","_"],function(a,c){return window.backboneJsonApi=b.exports(a,c),window.backboneJsonApi}):window.backboneJsonApi=b.exports(window.Backbone,window._)},{"./backbone-jsonapi":1}]},{},[3]); | ||
/*! backbone-jsonapi - v 0.1.5 - Copyright guillaumervls 2013-11-26 */ | ||
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){var c=a("./toolbox");b.exports=function(a,d){if(!a||!d)throw new Error("Backbone and/or Lodash (or Underscore) are not loaded...");return c=c(d),a.Collection.prototype.parse=function(a){if(void 0!==a){var b=c.parse(a),e=c.getMainCollection(a);return d.each(b[e],function(a){a._alreadyBBJSONAPIParsed=!0})}},a.Model.prototype.parse=function(a){if(void 0!==a){if(a._alreadyBBJSONAPIParsed)return delete a._alreadyBBJSONAPIParsed,a;var b=c.parse(a),d=c.getMainCollection(a);return b[d][0]}},b.exports},b.exports.VERSION="0.1.5"},{"./toolbox":2}],2:[function(a,b){var c;b.exports=function(a){return c=a,c.forOwn=c.forOwn||function(a,b){var d;try{d=c.keys(a)}catch(e){return}c.each(d,function(c){b(a[c],c)})},b.exports};var d=b.exports.findById=function(a,b){return c.find(a,function(a){return a.id===b})},e=b.exports.applyTemplateUrl=function(a,b,c){var d=new RegExp("{"+a+"\\.(.+?)}","g"),e=d.exec(b);if(null!==e){if(void 0===c[e[1]]&&void 0===c.links[e[1]])throw new Error("Template required a property not present in data object");b=b.substr(0,e.index)+(c.links[e[1]]||c[e[1]])+b.substr(d.lastIndex)}return b},f=b.exports.processLink=function(a,b,f){var g=f.split("."),h=g[0],i=g[1];return c.each(a[h],function(c){if(c.links=c.links||{},void 0!==c.links[i]){var f=d(a[b.type],c.links[i]);void 0!==f&&(c[i]=f)}c.links[i]=e(h,b.href,c)}),a};b.exports.parse=function(a){return c.forOwn(a.links,function(b,c){f(a,b,c)}),a},b.exports.getMainCollection=function(a){var b=c.without(c.keys(a),"links","meta"),d=c.pluck(c.values(a.links),"type");return c.difference(b,d)[0]}},{}],3:[function(a){var b=a("./backbone-jsonapi");"function"==typeof define&&define.amd?define(["Backbone","_"],function(a,c){return window.backboneJsonApi=b(a,c),window.backboneJsonApi}):window.backboneJsonApi=b(window.Backbone,window._)},{"./backbone-jsonapi":1}]},{},[3]); |
{ | ||
"name": "backbone-jsonapi", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Backbone Model & Collection .parse() functions for data from a JSON API", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -14,3 +14,5 @@ var toolbox = require('./toolbox'); | ||
var mainCollection = toolbox.getMainCollection(response); | ||
return output[mainCollection]; | ||
return _.each(output[mainCollection], function (obj) { | ||
obj._alreadyBBJSONAPIParsed = true; | ||
}); | ||
}; | ||
@@ -21,2 +23,6 @@ Backbone.Model.prototype.parse = function (response) { | ||
} | ||
if (response._alreadyBBJSONAPIParsed) { | ||
delete response._alreadyBBJSONAPIParsed; | ||
return response; | ||
} | ||
var output = toolbox.parse(response); | ||
@@ -29,2 +35,2 @@ var mainCollection = toolbox.getMainCollection(response); | ||
module.exports.VERSION = '0.1.1'; | ||
module.exports.VERSION = '0.1.5'; |
@@ -163,3 +163,4 @@ module.exports.input = { | ||
'vote': '/engine/videos/le-grand-detournement-la-classe-americaine-vous-savez-parler-comme-ca-e/votes' | ||
} | ||
}, | ||
'_alreadyBBJSONAPIParsed': true | ||
}, { | ||
@@ -192,3 +193,4 @@ 'voteCount': 1363, | ||
'vote': '/engine/videos/le-grand-detournement-la-classe-americaine-chips/votes' | ||
} | ||
}, | ||
'_alreadyBBJSONAPIParsed': true | ||
}, { | ||
@@ -221,3 +223,4 @@ 'voteCount': 1, | ||
'vote': '/engine/videos/la-classe-americaine-trailer/votes' | ||
} | ||
}, | ||
'_alreadyBBJSONAPIParsed': true | ||
}, { | ||
@@ -250,3 +253,4 @@ 'voteCount': 1, | ||
'vote': '/engine/videos/la-classe-americaine-mexican-food/votes' | ||
} | ||
}, | ||
'_alreadyBBJSONAPIParsed': true | ||
}, { | ||
@@ -279,3 +283,4 @@ 'voteCount': 1, | ||
'vote': '/engine/videos/la-classe-americaine-la-lettre/votes' | ||
} | ||
}, | ||
'_alreadyBBJSONAPIParsed': true | ||
}, { | ||
@@ -308,3 +313,4 @@ 'voteCount': 1, | ||
'vote': '/engine/videos/le-grand-detournement-la-classe-americaine-complet/votes' | ||
} | ||
}, | ||
'_alreadyBBJSONAPIParsed': true | ||
}]; |
@@ -41,4 +41,4 @@ var chai = require('chai'), | ||
input.videos = [input.videos[3]]; | ||
model.parse(input).should.deep.equal(samples.output[3]); | ||
model.parse(input).should.deep.equal(_.omit(samples.output[3], '_alreadyBBJSONAPIParsed')); | ||
}); | ||
}); |
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
22880
551