angular-resource
Advanced tools
Comparing version 1.3.3 to 1.3.4-build.3587
/** | ||
* @license AngularJS v1.3.3 | ||
* @license AngularJS v1.2.27 | ||
* (c) 2010-2014 Google, Inc. http://angularjs.org | ||
@@ -38,3 +38,3 @@ * License: MIT | ||
angular.forEach(dst, function(value, key) { | ||
angular.forEach(dst, function(value, key){ | ||
delete dst[key]; | ||
@@ -82,14 +82,2 @@ }); | ||
* | ||
* By default, trailing slashes will be stripped from the calculated URLs, | ||
* which can pose problems with server backends that do not expect that | ||
* behavior. This can be disabled by configuring the `$resourceProvider` like | ||
* this: | ||
* | ||
* ```js | ||
app.config(['$resourceProvider', function($resourceProvider) { | ||
// Don't strip trailing slashes from calculated URLs | ||
$resourceProvider.defaults.stripTrailingSlashes = false; | ||
}]); | ||
* ``` | ||
* | ||
* @param {string} url A parametrized URL template with parameters prefixed by `:` as in | ||
@@ -123,3 +111,3 @@ * `/user/:username`. If you are using a URL with a port number (e.g. | ||
* the default set of resource actions. The declaration should be created in the format of {@link | ||
* ng.$http#usage $http.config}: | ||
* ng.$http#usage_parameters $http.config}: | ||
* | ||
@@ -173,10 +161,2 @@ * {action1: {method:?, params:?, isArray:?, headers:?, ...}, | ||
* | ||
* @param {Object} options Hash with custom settings that should extend the | ||
* default `$resourceProvider` behavior. The only supported option is | ||
* | ||
* Where: | ||
* | ||
* - **`stripTrailingSlashes`** – {boolean} – If true then the trailing | ||
* slashes from any calculated URL will be stripped. (Defaults to true.) | ||
* | ||
* @returns {Object} A resource "class" object with methods for the default set of resource actions | ||
@@ -357,22 +337,12 @@ * optionally extended with custom `actions`. The default set contains these actions: | ||
angular.module('ngResource', ['ng']). | ||
provider('$resource', function() { | ||
var provider = this; | ||
factory('$resource', ['$http', '$q', function($http, $q) { | ||
this.defaults = { | ||
// Strip slashes by default | ||
stripTrailingSlashes: true, | ||
// Default actions configuration | ||
actions: { | ||
'get': {method: 'GET'}, | ||
'save': {method: 'POST'}, | ||
'query': {method: 'GET', isArray: true}, | ||
'remove': {method: 'DELETE'}, | ||
'delete': {method: 'DELETE'} | ||
} | ||
var DEFAULT_ACTIONS = { | ||
'get': {method:'GET'}, | ||
'save': {method:'POST'}, | ||
'query': {method:'GET', isArray:true}, | ||
'remove': {method:'DELETE'}, | ||
'delete': {method:'DELETE'} | ||
}; | ||
this.$get = ['$http', '$q', function($http, $q) { | ||
var noop = angular.noop, | ||
var noop = angular.noop, | ||
forEach = angular.forEach, | ||
@@ -383,50 +353,50 @@ extend = angular.extend, | ||
/** | ||
* We need our custom method because encodeURIComponent is too aggressive and doesn't follow | ||
* http://www.ietf.org/rfc/rfc3986.txt with regards to the character set | ||
* (pchar) allowed in path segments: | ||
* segment = *pchar | ||
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@" | ||
* pct-encoded = "%" HEXDIG HEXDIG | ||
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" | ||
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" | ||
* / "*" / "+" / "," / ";" / "=" | ||
*/ | ||
function encodeUriSegment(val) { | ||
return encodeUriQuery(val, true). | ||
replace(/%26/gi, '&'). | ||
replace(/%3D/gi, '='). | ||
replace(/%2B/gi, '+'); | ||
} | ||
/** | ||
* We need our custom method because encodeURIComponent is too aggressive and doesn't follow | ||
* http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path | ||
* segments: | ||
* segment = *pchar | ||
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@" | ||
* pct-encoded = "%" HEXDIG HEXDIG | ||
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" | ||
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" | ||
* / "*" / "+" / "," / ";" / "=" | ||
*/ | ||
function encodeUriSegment(val) { | ||
return encodeUriQuery(val, true). | ||
replace(/%26/gi, '&'). | ||
replace(/%3D/gi, '='). | ||
replace(/%2B/gi, '+'); | ||
} | ||
/** | ||
* This method is intended for encoding *key* or *value* parts of query component. We need a | ||
* custom method because encodeURIComponent is too aggressive and encodes stuff that doesn't | ||
* have to be encoded per http://tools.ietf.org/html/rfc3986: | ||
* query = *( pchar / "/" / "?" ) | ||
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@" | ||
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" | ||
* pct-encoded = "%" HEXDIG HEXDIG | ||
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" | ||
* / "*" / "+" / "," / ";" / "=" | ||
*/ | ||
function encodeUriQuery(val, pctEncodeSpaces) { | ||
return encodeURIComponent(val). | ||
replace(/%40/gi, '@'). | ||
replace(/%3A/gi, ':'). | ||
replace(/%24/g, '$'). | ||
replace(/%2C/gi, ','). | ||
replace(/%20/g, (pctEncodeSpaces ? '%20' : '+')); | ||
} | ||
/** | ||
* This method is intended for encoding *key* or *value* parts of query component. We need a | ||
* custom method because encodeURIComponent is too aggressive and encodes stuff that doesn't | ||
* have to be encoded per http://tools.ietf.org/html/rfc3986: | ||
* query = *( pchar / "/" / "?" ) | ||
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@" | ||
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" | ||
* pct-encoded = "%" HEXDIG HEXDIG | ||
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" | ||
* / "*" / "+" / "," / ";" / "=" | ||
*/ | ||
function encodeUriQuery(val, pctEncodeSpaces) { | ||
return encodeURIComponent(val). | ||
replace(/%40/gi, '@'). | ||
replace(/%3A/gi, ':'). | ||
replace(/%24/g, '$'). | ||
replace(/%2C/gi, ','). | ||
replace(/%20/g, (pctEncodeSpaces ? '%20' : '+')); | ||
} | ||
function Route(template, defaults) { | ||
this.template = template; | ||
this.defaults = extend({}, provider.defaults, defaults); | ||
this.urlParams = {}; | ||
} | ||
function Route(template, defaults) { | ||
this.template = template; | ||
this.defaults = defaults || {}; | ||
this.urlParams = {}; | ||
} | ||
Route.prototype = { | ||
setUrlParams: function(config, params, actionUrl) { | ||
var self = this, | ||
Route.prototype = { | ||
setUrlParams: function(config, params, actionUrl) { | ||
var self = this, | ||
url = actionUrl || self.template, | ||
@@ -436,199 +406,190 @@ val, | ||
var urlParams = self.urlParams = {}; | ||
forEach(url.split(/\W/), function(param) { | ||
if (param === 'hasOwnProperty') { | ||
throw $resourceMinErr('badname', "hasOwnProperty is not a valid parameter name."); | ||
} | ||
if (!(new RegExp("^\\d+$").test(param)) && param && | ||
(new RegExp("(^|[^\\\\]):" + param + "(\\W|$)").test(url))) { | ||
urlParams[param] = true; | ||
} | ||
}); | ||
url = url.replace(/\\:/g, ':'); | ||
var urlParams = self.urlParams = {}; | ||
forEach(url.split(/\W/), function(param){ | ||
if (param === 'hasOwnProperty') { | ||
throw $resourceMinErr('badname', "hasOwnProperty is not a valid parameter name."); | ||
} | ||
if (!(new RegExp("^\\d+$").test(param)) && param && | ||
(new RegExp("(^|[^\\\\]):" + param + "(\\W|$)").test(url))) { | ||
urlParams[param] = true; | ||
} | ||
}); | ||
url = url.replace(/\\:/g, ':'); | ||
params = params || {}; | ||
forEach(self.urlParams, function(_, urlParam) { | ||
val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam]; | ||
if (angular.isDefined(val) && val !== null) { | ||
encodedVal = encodeUriSegment(val); | ||
url = url.replace(new RegExp(":" + urlParam + "(\\W|$)", "g"), function(match, p1) { | ||
return encodedVal + p1; | ||
}); | ||
} else { | ||
url = url.replace(new RegExp("(\/?):" + urlParam + "(\\W|$)", "g"), function(match, | ||
leadingSlashes, tail) { | ||
if (tail.charAt(0) == '/') { | ||
return tail; | ||
} else { | ||
return leadingSlashes + tail; | ||
} | ||
}); | ||
} | ||
}); | ||
// strip trailing slashes and set the url (unless this behavior is specifically disabled) | ||
if (self.defaults.stripTrailingSlashes) { | ||
url = url.replace(/\/+$/, '') || '/'; | ||
params = params || {}; | ||
forEach(self.urlParams, function(_, urlParam){ | ||
val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam]; | ||
if (angular.isDefined(val) && val !== null) { | ||
encodedVal = encodeUriSegment(val); | ||
url = url.replace(new RegExp(":" + urlParam + "(\\W|$)", "g"), function(match, p1) { | ||
return encodedVal + p1; | ||
}); | ||
} else { | ||
url = url.replace(new RegExp("(\/?):" + urlParam + "(\\W|$)", "g"), function(match, | ||
leadingSlashes, tail) { | ||
if (tail.charAt(0) == '/') { | ||
return tail; | ||
} else { | ||
return leadingSlashes + tail; | ||
} | ||
}); | ||
} | ||
}); | ||
// then replace collapse `/.` if found in the last URL path segment before the query | ||
// E.g. `http://url.com/id./format?q=x` becomes `http://url.com/id.format?q=x` | ||
url = url.replace(/\/\.(?=\w+($|\?))/, '.'); | ||
// replace escaped `/\.` with `/.` | ||
config.url = url.replace(/\/\\\./, '/.'); | ||
// strip trailing slashes and set the url | ||
url = url.replace(/\/+$/, '') || '/'; | ||
// then replace collapse `/.` if found in the last URL path segment before the query | ||
// E.g. `http://url.com/id./format?q=x` becomes `http://url.com/id.format?q=x` | ||
url = url.replace(/\/\.(?=\w+($|\?))/, '.'); | ||
// replace escaped `/\.` with `/.` | ||
config.url = url.replace(/\/\\\./, '/.'); | ||
// set params - delegate param encoding to $http | ||
forEach(params, function(value, key) { | ||
if (!self.urlParams[key]) { | ||
config.params = config.params || {}; | ||
config.params[key] = value; | ||
} | ||
}); | ||
} | ||
}; | ||
// set params - delegate param encoding to $http | ||
forEach(params, function(value, key){ | ||
if (!self.urlParams[key]) { | ||
config.params = config.params || {}; | ||
config.params[key] = value; | ||
} | ||
}); | ||
} | ||
}; | ||
function resourceFactory(url, paramDefaults, actions, options) { | ||
var route = new Route(url, options); | ||
function resourceFactory(url, paramDefaults, actions) { | ||
var route = new Route(url); | ||
actions = extend({}, provider.defaults.actions, actions); | ||
actions = extend({}, DEFAULT_ACTIONS, actions); | ||
function extractParams(data, actionParams) { | ||
var ids = {}; | ||
actionParams = extend({}, paramDefaults, actionParams); | ||
forEach(actionParams, function(value, key) { | ||
if (isFunction(value)) { value = value(); } | ||
ids[key] = value && value.charAt && value.charAt(0) == '@' ? | ||
lookupDottedPath(data, value.substr(1)) : value; | ||
}); | ||
return ids; | ||
} | ||
function extractParams(data, actionParams){ | ||
var ids = {}; | ||
actionParams = extend({}, paramDefaults, actionParams); | ||
forEach(actionParams, function(value, key){ | ||
if (isFunction(value)) { value = value(); } | ||
ids[key] = value && value.charAt && value.charAt(0) == '@' ? | ||
lookupDottedPath(data, value.substr(1)) : value; | ||
}); | ||
return ids; | ||
} | ||
function defaultResponseInterceptor(response) { | ||
return response.resource; | ||
} | ||
function defaultResponseInterceptor(response) { | ||
return response.resource; | ||
} | ||
function Resource(value) { | ||
shallowClearAndCopy(value || {}, this); | ||
} | ||
function Resource(value){ | ||
shallowClearAndCopy(value || {}, this); | ||
} | ||
Resource.prototype.toJSON = function() { | ||
var data = extend({}, this); | ||
delete data.$promise; | ||
delete data.$resolved; | ||
return data; | ||
}; | ||
forEach(actions, function(action, name) { | ||
var hasBody = /^(POST|PUT|PATCH)$/i.test(action.method); | ||
forEach(actions, function(action, name) { | ||
var hasBody = /^(POST|PUT|PATCH)$/i.test(action.method); | ||
Resource[name] = function(a1, a2, a3, a4) { | ||
var params = {}, data, success, error; | ||
Resource[name] = function(a1, a2, a3, a4) { | ||
var params = {}, data, success, error; | ||
/* jshint -W086 */ /* (purposefully fall through case statements) */ | ||
switch(arguments.length) { | ||
case 4: | ||
error = a4; | ||
success = a3; | ||
//fallthrough | ||
case 3: | ||
case 2: | ||
if (isFunction(a2)) { | ||
if (isFunction(a1)) { | ||
success = a1; | ||
error = a2; | ||
break; | ||
} | ||
/* jshint -W086 */ /* (purposefully fall through case statements) */ | ||
switch (arguments.length) { | ||
case 4: | ||
error = a4; | ||
success = a3; | ||
success = a2; | ||
error = a3; | ||
//fallthrough | ||
case 3: | ||
case 2: | ||
if (isFunction(a2)) { | ||
if (isFunction(a1)) { | ||
success = a1; | ||
error = a2; | ||
break; | ||
} | ||
success = a2; | ||
error = a3; | ||
//fallthrough | ||
} else { | ||
params = a1; | ||
data = a2; | ||
success = a3; | ||
break; | ||
} | ||
case 1: | ||
if (isFunction(a1)) success = a1; | ||
else if (hasBody) data = a1; | ||
else params = a1; | ||
break; | ||
case 0: break; | ||
default: | ||
throw $resourceMinErr('badargs', | ||
"Expected up to 4 arguments [params, data, success, error], got {0} arguments", | ||
arguments.length); | ||
} else { | ||
params = a1; | ||
data = a2; | ||
success = a3; | ||
break; | ||
} | ||
/* jshint +W086 */ /* (purposefully fall through case statements) */ | ||
case 1: | ||
if (isFunction(a1)) success = a1; | ||
else if (hasBody) data = a1; | ||
else params = a1; | ||
break; | ||
case 0: break; | ||
default: | ||
throw $resourceMinErr('badargs', | ||
"Expected up to 4 arguments [params, data, success, error], got {0} arguments", | ||
arguments.length); | ||
} | ||
/* jshint +W086 */ /* (purposefully fall through case statements) */ | ||
var isInstanceCall = this instanceof Resource; | ||
var value = isInstanceCall ? data : (action.isArray ? [] : new Resource(data)); | ||
var httpConfig = {}; | ||
var responseInterceptor = action.interceptor && action.interceptor.response || | ||
defaultResponseInterceptor; | ||
var responseErrorInterceptor = action.interceptor && action.interceptor.responseError || | ||
undefined; | ||
var isInstanceCall = this instanceof Resource; | ||
var value = isInstanceCall ? data : (action.isArray ? [] : new Resource(data)); | ||
var httpConfig = {}; | ||
var responseInterceptor = action.interceptor && action.interceptor.response || | ||
defaultResponseInterceptor; | ||
var responseErrorInterceptor = action.interceptor && action.interceptor.responseError || | ||
undefined; | ||
forEach(action, function(value, key) { | ||
if (key != 'params' && key != 'isArray' && key != 'interceptor') { | ||
httpConfig[key] = copy(value); | ||
} | ||
}); | ||
forEach(action, function(value, key) { | ||
if (key != 'params' && key != 'isArray' && key != 'interceptor') { | ||
httpConfig[key] = copy(value); | ||
} | ||
}); | ||
if (hasBody) httpConfig.data = data; | ||
route.setUrlParams(httpConfig, | ||
extend({}, extractParams(data, action.params || {}), params), | ||
action.url); | ||
if (hasBody) httpConfig.data = data; | ||
route.setUrlParams(httpConfig, | ||
extend({}, extractParams(data, action.params || {}), params), | ||
action.url); | ||
var promise = $http(httpConfig).then(function(response) { | ||
var data = response.data, | ||
promise = value.$promise; | ||
var promise = $http(httpConfig).then(function (response) { | ||
var data = response.data, | ||
promise = value.$promise; | ||
if (data) { | ||
// Need to convert action.isArray to boolean in case it is undefined | ||
// jshint -W018 | ||
if (angular.isArray(data) !== (!!action.isArray)) { | ||
throw $resourceMinErr('badcfg', | ||
'Error in resource configuration for action `{0}`. Expected response to ' + | ||
'contain an {1} but got an {2}', name, action.isArray ? 'array' : 'object', | ||
angular.isArray(data) ? 'array' : 'object'); | ||
} | ||
// jshint +W018 | ||
if (action.isArray) { | ||
value.length = 0; | ||
forEach(data, function(item) { | ||
if (typeof item === "object") { | ||
value.push(new Resource(item)); | ||
} else { | ||
// Valid JSON values may be string literals, and these should not be converted | ||
// into objects. These items will not have access to the Resource prototype | ||
// methods, but unfortunately there | ||
value.push(item); | ||
} | ||
}); | ||
} else { | ||
shallowClearAndCopy(data, value); | ||
value.$promise = promise; | ||
} | ||
if (data) { | ||
// Need to convert action.isArray to boolean in case it is undefined | ||
// jshint -W018 | ||
if (angular.isArray(data) !== (!!action.isArray)) { | ||
throw $resourceMinErr('badcfg', | ||
'Error in resource configuration. Expected ' + | ||
'response to contain an {0} but got an {1}', | ||
action.isArray ? 'array' : 'object', | ||
angular.isArray(data) ? 'array' : 'object'); | ||
} | ||
// jshint +W018 | ||
if (action.isArray) { | ||
value.length = 0; | ||
forEach(data, function (item) { | ||
if (typeof item === "object") { | ||
value.push(new Resource(item)); | ||
} else { | ||
// Valid JSON values may be string literals, and these should not be converted | ||
// into objects. These items will not have access to the Resource prototype | ||
// methods, but unfortunately there | ||
value.push(item); | ||
} | ||
}); | ||
} else { | ||
shallowClearAndCopy(data, value); | ||
value.$promise = promise; | ||
} | ||
} | ||
value.$resolved = true; | ||
value.$resolved = true; | ||
response.resource = value; | ||
response.resource = value; | ||
return response; | ||
}, function(response) { | ||
value.$resolved = true; | ||
return response; | ||
}, function(response) { | ||
value.$resolved = true; | ||
(error || noop)(response); | ||
(error||noop)(response); | ||
return $q.reject(response); | ||
}); | ||
return $q.reject(response); | ||
}); | ||
promise = promise.then( | ||
promise = promise.then( | ||
function(response) { | ||
var value = responseInterceptor(response); | ||
(success || noop)(value, response.headers); | ||
(success||noop)(value, response.headers); | ||
return value; | ||
@@ -638,38 +599,37 @@ }, | ||
if (!isInstanceCall) { | ||
// we are creating instance / collection | ||
// - set the initial promise | ||
// - return the instance / collection | ||
value.$promise = promise; | ||
value.$resolved = false; | ||
if (!isInstanceCall) { | ||
// we are creating instance / collection | ||
// - set the initial promise | ||
// - return the instance / collection | ||
value.$promise = promise; | ||
value.$resolved = false; | ||
return value; | ||
} | ||
return value; | ||
} | ||
// instance call | ||
return promise; | ||
}; | ||
// instance call | ||
return promise; | ||
}; | ||
Resource.prototype['$' + name] = function(params, success, error) { | ||
if (isFunction(params)) { | ||
error = success; success = params; params = {}; | ||
} | ||
var result = Resource[name].call(this, params, this, success, error); | ||
return result.$promise || result; | ||
}; | ||
}); | ||
Resource.bind = function(additionalParamDefaults) { | ||
return resourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions); | ||
Resource.prototype['$' + name] = function(params, success, error) { | ||
if (isFunction(params)) { | ||
error = success; success = params; params = {}; | ||
} | ||
var result = Resource[name].call(this, params, this, success, error); | ||
return result.$promise || result; | ||
}; | ||
}); | ||
return Resource; | ||
} | ||
Resource.bind = function(additionalParamDefaults){ | ||
return resourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions); | ||
}; | ||
return resourceFactory; | ||
}]; | ||
}); | ||
return Resource; | ||
} | ||
return resourceFactory; | ||
}]); | ||
})(window, window.angular); |
/* | ||
AngularJS v1.3.3 | ||
AngularJS v1.2.27 | ||
(c) 2010-2014 Google, Inc. http://angularjs.org | ||
License: MIT | ||
*/ | ||
(function(I,d,B){'use strict';function D(f,q){q=q||{};d.forEach(q,function(d,h){delete q[h]});for(var h in f)!f.hasOwnProperty(h)||"$"===h.charAt(0)&&"$"===h.charAt(1)||(q[h]=f[h]);return q}var w=d.$$minErr("$resource"),C=/^(\.[a-zA-Z_$][0-9a-zA-Z_$]*)+$/;d.module("ngResource",["ng"]).provider("$resource",function(){var f=this;this.defaults={stripTrailingSlashes:!0,actions:{get:{method:"GET"},save:{method:"POST"},query:{method:"GET",isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"}}}; | ||
this.$get=["$http","$q",function(q,h){function t(d,g){this.template=d;this.defaults=s({},f.defaults,g);this.urlParams={}}function v(x,g,l,m){function c(b,k){var c={};k=s({},g,k);r(k,function(a,k){u(a)&&(a=a());var d;if(a&&a.charAt&&"@"==a.charAt(0)){d=b;var e=a.substr(1);if(null==e||""===e||"hasOwnProperty"===e||!C.test("."+e))throw w("badmember",e);for(var e=e.split("."),n=0,g=e.length;n<g&&d!==B;n++){var h=e[n];d=null!==d?d[h]:B}}else d=a;c[k]=d});return c}function F(b){return b.resource}function e(b){D(b|| | ||
{},this)}var G=new t(x,m);l=s({},f.defaults.actions,l);e.prototype.toJSON=function(){var b=s({},this);delete b.$promise;delete b.$resolved;return b};r(l,function(b,k){var g=/^(POST|PUT|PATCH)$/i.test(b.method);e[k]=function(a,y,m,x){var n={},f,l,z;switch(arguments.length){case 4:z=x,l=m;case 3:case 2:if(u(y)){if(u(a)){l=a;z=y;break}l=y;z=m}else{n=a;f=y;l=m;break}case 1:u(a)?l=a:g?f=a:n=a;break;case 0:break;default:throw w("badargs",arguments.length);}var t=this instanceof e,p=t?f:b.isArray?[]:new e(f), | ||
A={},v=b.interceptor&&b.interceptor.response||F,C=b.interceptor&&b.interceptor.responseError||B;r(b,function(b,a){"params"!=a&&"isArray"!=a&&"interceptor"!=a&&(A[a]=H(b))});g&&(A.data=f);G.setUrlParams(A,s({},c(f,b.params||{}),n),b.url);n=q(A).then(function(a){var c=a.data,g=p.$promise;if(c){if(d.isArray(c)!==!!b.isArray)throw w("badcfg",k,b.isArray?"array":"object",d.isArray(c)?"array":"object");b.isArray?(p.length=0,r(c,function(a){"object"===typeof a?p.push(new e(a)):p.push(a)})):(D(c,p),p.$promise= | ||
g)}p.$resolved=!0;a.resource=p;return a},function(a){p.$resolved=!0;(z||E)(a);return h.reject(a)});n=n.then(function(a){var b=v(a);(l||E)(b,a.headers);return b},C);return t?n:(p.$promise=n,p.$resolved=!1,p)};e.prototype["$"+k]=function(a,b,c){u(a)&&(c=b,b=a,a={});a=e[k].call(this,a,this,b,c);return a.$promise||a}});e.bind=function(b){return v(x,s({},g,b),l)};return e}var E=d.noop,r=d.forEach,s=d.extend,H=d.copy,u=d.isFunction;t.prototype={setUrlParams:function(f,g,l){var m=this,c=l||m.template,h, | ||
e,q=m.urlParams={};r(c.split(/\W/),function(b){if("hasOwnProperty"===b)throw w("badname");!/^\d+$/.test(b)&&b&&(new RegExp("(^|[^\\\\]):"+b+"(\\W|$)")).test(c)&&(q[b]=!0)});c=c.replace(/\\:/g,":");g=g||{};r(m.urlParams,function(b,k){h=g.hasOwnProperty(k)?g[k]:m.defaults[k];d.isDefined(h)&&null!==h?(e=encodeURIComponent(h).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"%20").replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+"),c=c.replace(new RegExp(":"+ | ||
k+"(\\W|$)","g"),function(b,a){return e+a})):c=c.replace(new RegExp("(/?):"+k+"(\\W|$)","g"),function(b,a,c){return"/"==c.charAt(0)?c:a+c})});m.defaults.stripTrailingSlashes&&(c=c.replace(/\/+$/,"")||"/");c=c.replace(/\/\.(?=\w+($|\?))/,".");f.url=c.replace(/\/\\\./,"/.");r(g,function(b,c){m.urlParams[c]||(f.params=f.params||{},f.params[c]=b)})}};return v}]})})(window,window.angular); | ||
(function(H,a,A){'use strict';function D(p,g){g=g||{};a.forEach(g,function(a,c){delete g[c]});for(var c in p)!p.hasOwnProperty(c)||"$"===c.charAt(0)&&"$"===c.charAt(1)||(g[c]=p[c]);return g}var v=a.$$minErr("$resource"),C=/^(\.[a-zA-Z_$][0-9a-zA-Z_$]*)+$/;a.module("ngResource",["ng"]).factory("$resource",["$http","$q",function(p,g){function c(a,c){this.template=a;this.defaults=c||{};this.urlParams={}}function t(n,w,l){function r(h,d){var e={};d=x({},w,d);s(d,function(b,d){u(b)&&(b=b());var k;if(b&& | ||
b.charAt&&"@"==b.charAt(0)){k=h;var a=b.substr(1);if(null==a||""===a||"hasOwnProperty"===a||!C.test("."+a))throw v("badmember",a);for(var a=a.split("."),f=0,c=a.length;f<c&&k!==A;f++){var g=a[f];k=null!==k?k[g]:A}}else k=b;e[d]=k});return e}function e(a){return a.resource}function f(a){D(a||{},this)}var F=new c(n);l=x({},B,l);s(l,function(h,d){var c=/^(POST|PUT|PATCH)$/i.test(h.method);f[d]=function(b,d,k,w){var q={},n,l,y;switch(arguments.length){case 4:y=w,l=k;case 3:case 2:if(u(d)){if(u(b)){l= | ||
b;y=d;break}l=d;y=k}else{q=b;n=d;l=k;break}case 1:u(b)?l=b:c?n=b:q=b;break;case 0:break;default:throw v("badargs",arguments.length);}var t=this instanceof f,m=t?n:h.isArray?[]:new f(n),z={},B=h.interceptor&&h.interceptor.response||e,C=h.interceptor&&h.interceptor.responseError||A;s(h,function(a,b){"params"!=b&&("isArray"!=b&&"interceptor"!=b)&&(z[b]=G(a))});c&&(z.data=n);F.setUrlParams(z,x({},r(n,h.params||{}),q),h.url);q=p(z).then(function(b){var d=b.data,k=m.$promise;if(d){if(a.isArray(d)!==!!h.isArray)throw v("badcfg", | ||
h.isArray?"array":"object",a.isArray(d)?"array":"object");h.isArray?(m.length=0,s(d,function(b){"object"===typeof b?m.push(new f(b)):m.push(b)})):(D(d,m),m.$promise=k)}m.$resolved=!0;b.resource=m;return b},function(b){m.$resolved=!0;(y||E)(b);return g.reject(b)});q=q.then(function(b){var a=B(b);(l||E)(a,b.headers);return a},C);return t?q:(m.$promise=q,m.$resolved=!1,m)};f.prototype["$"+d]=function(b,a,k){u(b)&&(k=a,a=b,b={});b=f[d].call(this,b,this,a,k);return b.$promise||b}});f.bind=function(a){return t(n, | ||
x({},w,a),l)};return f}var B={get:{method:"GET"},save:{method:"POST"},query:{method:"GET",isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"}},E=a.noop,s=a.forEach,x=a.extend,G=a.copy,u=a.isFunction;c.prototype={setUrlParams:function(c,g,l){var r=this,e=l||r.template,f,p,h=r.urlParams={};s(e.split(/\W/),function(a){if("hasOwnProperty"===a)throw v("badname");!/^\d+$/.test(a)&&(a&&RegExp("(^|[^\\\\]):"+a+"(\\W|$)").test(e))&&(h[a]=!0)});e=e.replace(/\\:/g,":");g=g||{};s(r.urlParams,function(d, | ||
c){f=g.hasOwnProperty(c)?g[c]:r.defaults[c];a.isDefined(f)&&null!==f?(p=encodeURIComponent(f).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"%20").replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+"),e=e.replace(RegExp(":"+c+"(\\W|$)","g"),function(a,c){return p+c})):e=e.replace(RegExp("(/?):"+c+"(\\W|$)","g"),function(a,c,d){return"/"==d.charAt(0)?d:c+d})});e=e.replace(/\/+$/,"")||"/";e=e.replace(/\/\.(?=\w+($|\?))/,".");c.url=e.replace(/\/\\\./, | ||
"/.");s(g,function(a,e){r.urlParams[e]||(c.params=c.params||{},c.params[e]=a)})}};return t}])})(window,window.angular); | ||
//# sourceMappingURL=angular-resource.min.js.map |
{ | ||
"name": "angular-resource", | ||
"version": "1.3.3", | ||
"version": "1.2.27", | ||
"main": "./angular-resource.js", | ||
"ignore": [], | ||
"dependencies": { | ||
"angular": "1.3.3" | ||
"angular": "1.2.27" | ||
} | ||
} |
{ | ||
"name": "angular-resource", | ||
"version": "1.3.3", | ||
"version": "1.3.4-build.3587+sha.eab2718", | ||
"description": "AngularJS module for interacting with RESTful server-side data sources", | ||
@@ -5,0 +5,0 @@ "main": "angular-resource.js", |
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
0
40277
598
2
1