New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-resource

Package Overview
Dependencies
Maintainers
3
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-resource - npm Package Compare versions

Comparing version 1.5.0-beta.2 to 1.5.0-rc.0

137

angular-resource.js
/**
* @license AngularJS v1.5.0-beta.2
* @license AngularJS v1.5.0-rc.0
* (c) 2010-2015 Google, Inc. http://angularjs.org

@@ -71,2 +71,4 @@ * License: MIT

* @requires $http
* @requires ng.$log
* @requires $q
*

@@ -106,3 +108,3 @@ * @description

* @param {Object=} paramDefaults Default values for `url` parameters. These can be overridden in
* `actions` methods. If any of the parameter value is a function, it will be executed every time
* `actions` methods. If a parameter value is a function, it will be executed every time
* when a param value needs to be obtained for a request (unless the param was overridden).

@@ -117,5 +119,5 @@ *

* If the parameter value is prefixed with `@` then the value for that parameter will be extracted
* from the corresponding property on the `data` object (provided when calling an action method). For
* example, if the `defaultParam` object is `{someParam: '@someProp'}` then the value of `someParam`
* will be `data.someProp`.
* from the corresponding property on the `data` object (provided when calling an action method).
* For example, if the `defaultParam` object is `{someParam: '@someProp'}` then the value of
* `someParam` will be `data.someProp`.
*

@@ -154,5 +156,5 @@ * @param {Object.<Object>=} actions Hash with declaration of custom actions that should extend

* response body and headers and returns its transformed (typically deserialized) version.
* By default, transformResponse will contain one function that checks if the response looks like
* a JSON string and deserializes it using `angular.fromJson`. To prevent this behavior, set
* `transformResponse` to an empty array: `transformResponse: []`
* By default, transformResponse will contain one function that checks if the response looks
* like a JSON string and deserializes it using `angular.fromJson`. To prevent this behavior,
* set `transformResponse` to an empty array: `transformResponse: []`
* - **`cache`** – `{boolean|Cache}` – If true, a default $http cache will be used to cache the

@@ -162,4 +164,11 @@ * GET request, otherwise if a cache instance built with

* caching.
* - **`timeout`** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise} that
* should abort the request when resolved.
* - **`timeout`** – `{number}` – timeout in milliseconds.<br />
* **Note:** In contrast to {@link ng.$http#usage $http.config}, {@link ng.$q promises} are
* **not** supported in $resource, because the same value would be used for multiple requests.
* If you are looking for a way to cancel requests, you should use the `cancellable` option.
* - **`cancellable`** – `{boolean}` – if set to true, the request made by a "non-instance" call
* will be cancelled (if not already completed) by calling `$cancelRequest()` on the call's
* return value. Calling `$cancelRequest()` for a non-cancellable or an already
* completed/cancelled request will have no effect.<br />
* **Note:** If a timeout is specified in millisecondes, `cancellable` is ignored.
* - **`withCredentials`** - `{boolean}` - whether to set the `withCredentials` flag on the

@@ -176,8 +185,9 @@ * XHR object. See

* @param {Object} options Hash with custom settings that should extend the
* default `$resourceProvider` behavior. The only supported option is
* default `$resourceProvider` behavior. The supported options are:
*
* Where:
*
* - **`stripTrailingSlashes`** – {boolean} – If true then the trailing
* slashes from any calculated URL will be stripped. (Defaults to true.)
* - **`cancellable`** – {boolean} – If true, the request made by a "non-instance" call will be
* cancelled (if not already completed) by calling `$cancelRequest()` on the call's return value.
* This can be overwritten per action. (Defaults to false.)
*

@@ -230,3 +240,3 @@ * @returns {Object} A resource "class" object with methods for the default set of resource actions

*
* The Resource instances and collection have these additional properties:
* The Resource instances and collections have these additional properties:
*

@@ -251,2 +261,7 @@ * - `$promise`: the {@link ng.$q promise} of the original server interaction that created this

*
* The Resource instances and collections have these additional methods:
*
* - `$cancelRequest`: If there is a cancellable, pending request related to the instance or
* collection, calling this method will abort the request.
*
* @example

@@ -296,2 +311,7 @@ *

* `headers`.
*
* @example
*
* # User resource
*
* When the data is returned from the server then the object is an instance of the resource type and

@@ -315,6 +335,6 @@ * all of the non-GET methods are available with `$` prefix. This allows you to easily support CRUD

var User = $resource('/user/:userId', {userId:'@id'});
User.get({userId:123}, function(u, getResponseHeaders){
u.abc = true;
u.$save(function(u, putResponseHeaders) {
//u => saved user object
User.get({userId:123}, function(user, getResponseHeaders){
user.abc = true;
user.$save(function(user, putResponseHeaders) {
//user => saved user object
//putResponseHeaders => $http header getter

@@ -334,4 +354,7 @@ });

```
*
* @example
*
* # Creating a custom 'PUT' request
*
* In this example we create a custom method on our resource to make a PUT request

@@ -364,2 +387,30 @@ * ```js

* ```
*
* @example
*
* # Cancelling requests
*
* If an action's configuration specifies that it is cancellable, you can cancel the request related
* to an instance or collection (as long as it is a result of a "non-instance" call):
*
```js
// ...defining the `Hotel` resource...
var Hotel = $resource('/api/hotel/:id', {id: '@id'}, {
// Let's make the `query()` method cancellable
query: {method: 'get', isArray: true, cancellable: true}
});
// ...somewhere in the PlanVacationController...
...
this.onDestinationChanged = function onDestinationChanged(destination) {
// We don't care about any pending request for hotels
// in a different destination any more
this.availableHotels.$cancelRequest();
// Let's query for hotels in '<destination>'
// (calls: /api/hotel?location=<destination>)
this.availableHotels = Hotel.query({location: destination});
};
```
*
*/

@@ -385,3 +436,3 @@ angular.module('ngResource', ['ng']).

this.$get = ['$http', '$q', function($http, $q) {
this.$get = ['$http', '$log', '$q', function($http, $log, $q) {

@@ -545,3 +596,18 @@ var noop = angular.noop,

var hasBody = /^(POST|PUT|PATCH)$/i.test(action.method);
var cancellable = false;
if (!angular.isNumber(action.timeout)) {
if (action.timeout) {
$log.debug('ngResource:\n' +
' Only numeric values are allowed as `timeout`.\n' +
' Promises are not supported in $resource, because the same value would ' +
'be used for multiple requests. If you are looking for a way to cancel ' +
'requests, you should use the `cancellable` option.');
delete action.timeout;
}
cancellable = angular.isDefined(action.cancellable) ? action.cancellable :
(options && angular.isDefined(options.cancellable)) ? options.cancellable :
provider.defaults.cancellable;
}
Resource[name] = function(a1, a2, a3, a4) {

@@ -594,2 +660,3 @@ var params = {}, data, success, error;

undefined;
var timeoutDeferred;

@@ -604,9 +671,12 @@ forEach(action, function(value, key) {

case 'interceptor':
case 'cancellable':
break;
case 'timeout':
httpConfig[key] = value;
break;
}
});
if (!isInstanceCall && cancellable) {
timeoutDeferred = $q.defer();
httpConfig.timeout = timeoutDeferred.promise;
}
if (hasBody) httpConfig.data = data;

@@ -618,4 +688,3 @@ route.setUrlParams(httpConfig,

var promise = $http(httpConfig).then(function(response) {
var data = response.data,
promise = value.$promise;
var data = response.data;

@@ -645,9 +714,7 @@ if (data) {

} else {
var promise = value.$promise; // Save the promise
shallowClearAndCopy(data, value);
value.$promise = promise;
value.$promise = promise; // Restore the promise
}
}
value.$resolved = true;
response.resource = value;

@@ -657,9 +724,14 @@

}, function(response) {
value.$resolved = true;
(error || noop)(response);
return $q.reject(response);
});
promise.finally(function() {
value.$resolved = true;
if (!isInstanceCall && cancellable) {
value.$cancelRequest = angular.noop;
timeoutDeferred = httpConfig.timeout = null;
}
});
promise = promise.then(

@@ -679,2 +751,3 @@ function(response) {

value.$resolved = false;
if (cancellable) value.$cancelRequest = timeoutDeferred.resolve;

@@ -681,0 +754,0 @@ return value;

/*
AngularJS v1.5.0-beta.2
AngularJS v1.5.0-rc.0
(c) 2010-2015 Google, Inc. http://angularjs.org
License: MIT
*/
(function(J,f,C){'use strict';function D(s,e){e=e||{};f.forEach(e,function(f,g){delete e[g]});for(var g in s)!s.hasOwnProperty(g)||"$"===g.charAt(0)&&"$"===g.charAt(1)||(e[g]=s[g]);return e}var x=f.$$minErr("$resource"),G=/^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/;f.module("ngResource",["ng"]).provider("$resource",function(){var s=/^https?:\/\/[^\/]*/,e=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(g,F){function v(f,a){return encodeURIComponent(f).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,a?"%20":"+")}function y(f,a){this.template=f;this.defaults=r({},e.defaults,a);this.urlParams={}}function z(l,a,n,h){function d(c,q){var d={};q=r({},a,q);t(q,function(b,q){w(b)&&(b=b());var p;if(b&&b.charAt&&"@"==b.charAt(0)){p=c;var a=b.substr(1);if(null==a||""===a||"hasOwnProperty"===a||!G.test("."+a))throw x("badmember",
a);for(var a=a.split("."),k=0,e=a.length;k<e&&f.isDefined(p);k++){var g=a[k];p=null!==p?p[g]:C}}else p=b;d[q]=p});return d}function H(c){return c.resource}function k(c){D(c||{},this)}var s=new y(l,h);n=r({},e.defaults.actions,n);k.prototype.toJSON=function(){var c=r({},this);delete c.$promise;delete c.$resolved;return c};t(n,function(c,q){var a=/^(POST|PUT|PATCH)$/i.test(c.method);k[q]=function(b,A,p,e){var h={},l,n,B;switch(arguments.length){case 4:B=e,n=p;case 3:case 2:if(w(A)){if(w(b)){n=b;B=A;
break}n=A;B=p}else{h=b;l=A;n=p;break}case 1:w(b)?n=b:a?l=b:h=b;break;case 0:break;default:throw x("badargs",arguments.length);}var v=this instanceof k,m=v?l:c.isArray?[]:new k(l),u={},y=c.interceptor&&c.interceptor.response||H,z=c.interceptor&&c.interceptor.responseError||C;t(c,function(c,b){switch(b){default:u[b]=I(c);break;case "params":case "isArray":case "interceptor":break;case "timeout":u[b]=c}});a&&(u.data=l);s.setUrlParams(u,r({},d(l,c.params||{}),h),c.url);h=g(u).then(function(b){var a=b.data,
d=m.$promise;if(a){if(f.isArray(a)!==!!c.isArray)throw x("badcfg",q,c.isArray?"array":"object",f.isArray(a)?"array":"object",u.method,u.url);c.isArray?(m.length=0,t(a,function(b){"object"===typeof b?m.push(new k(b)):m.push(b)})):(D(a,m),m.$promise=d)}m.$resolved=!0;b.resource=m;return b},function(b){m.$resolved=!0;(B||E)(b);return F.reject(b)});h=h.then(function(b){var a=y(b);(n||E)(a,b.headers);return a},z);return v?h:(m.$promise=h,m.$resolved=!1,m)};k.prototype["$"+q]=function(b,a,c){w(b)&&(c=a,
a=b,b={});b=k[q].call(this,b,this,a,c);return b.$promise||b}});k.bind=function(c){return z(l,r({},a,c),n)};return k}var E=f.noop,t=f.forEach,r=f.extend,I=f.copy,w=f.isFunction;y.prototype={setUrlParams:function(l,a,e){var h=this,d=e||h.template,g,k,r="",c=h.urlParams={};t(d.split(/\W/),function(a){if("hasOwnProperty"===a)throw x("badname");!/^\d+$/.test(a)&&a&&(new RegExp("(^|[^\\\\]):"+a+"(\\W|$)")).test(d)&&(c[a]={isQueryParamValue:(new RegExp("\\?.*=:"+a+"(?:\\W|$)")).test(d)})});d=d.replace(/\\:/g,
":");d=d.replace(s,function(a){r=a;return""});a=a||{};t(h.urlParams,function(c,e){g=a.hasOwnProperty(e)?a[e]:h.defaults[e];f.isDefined(g)&&null!==g?(k=c.isQueryParamValue?v(g,!0):v(g,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+"),d=d.replace(new RegExp(":"+e+"(\\W|$)","g"),function(a,c){return k+c})):d=d.replace(new RegExp("(/?):"+e+"(\\W|$)","g"),function(a,c,d){return"/"==d.charAt(0)?d:c+d})});h.defaults.stripTrailingSlashes&&(d=d.replace(/\/+$/,"")||"/");d=d.replace(/\/\.(?=\w+($|\?))/,
".");l.url=r+d.replace(/\/\\\./,"/.");t(a,function(a,c){h.urlParams[c]||(l.params=l.params||{},l.params[c]=a)})}};return z}]})})(window,window.angular);
(function(N,e,E){'use strict';function F(t,b){b=b||{};e.forEach(b,function(e,g){delete b[g]});for(var g in t)!t.hasOwnProperty(g)||"$"===g.charAt(0)&&"$"===g.charAt(1)||(b[g]=t[g]);return b}var y=e.$$minErr("$resource"),K=/^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/;e.module("ngResource",["ng"]).provider("$resource",function(){var t=/^https?:\/\/[^\/]*/,b=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","$log","$q",function(g,J,G){function z(e,f){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,f?"%20":"+")}function A(e,f){this.template=e;this.defaults=r({},b.defaults,f);this.urlParams={}}function H(u,f,m,h){function d(a,c){var d={};c=r({},f,c);v(c,function(c,k){x(c)&&(c=c());var q;if(c&&c.charAt&&"@"==c.charAt(0)){q=a;var n=c.substr(1);if(null==n||""===n||"hasOwnProperty"===n||!K.test("."+n))throw y("badmember",
n);for(var n=n.split("."),f=0,l=n.length;f<l&&e.isDefined(q);f++){var h=n[f];q=null!==q?q[h]:E}}else q=c;d[k]=q});return d}function L(a){return a.resource}function l(a){F(a||{},this)}var t=new A(u,h);m=r({},b.defaults.actions,m);l.prototype.toJSON=function(){var a=r({},this);delete a.$promise;delete a.$resolved;return a};v(m,function(a,c){var f=/^(POST|PUT|PATCH)$/i.test(a.method),u=!1;e.isNumber(a.timeout)||(a.timeout&&(J.debug("ngResource:\n Only numeric values are allowed as `timeout`.\n Promises are not supported in $resource, because the same value would be used for multiple requests. If you are looking for a way to cancel requests, you should use the `cancellable` option."),
delete a.timeout),u=e.isDefined(a.cancellable)?a.cancellable:h&&e.isDefined(h.cancellable)?h.cancellable:b.defaults.cancellable);l[c]=function(k,q,n,h){var b={},m,w,B;switch(arguments.length){case 4:B=h,w=n;case 3:case 2:if(x(q)){if(x(k)){w=k;B=q;break}w=q;B=n}else{b=k;m=q;w=n;break}case 1:x(k)?w=k:f?m=k:b=k;break;case 0:break;default:throw y("badargs",arguments.length);}var C=this instanceof l,p=C?m:a.isArray?[]:new l(m),s={},z=a.interceptor&&a.interceptor.response||L,A=a.interceptor&&a.interceptor.responseError||
E,D;v(a,function(a,c){switch(c){default:s[c]=M(a);case "params":case "isArray":case "interceptor":case "cancellable":}});!C&&u&&(D=G.defer(),s.timeout=D.promise);f&&(s.data=m);t.setUrlParams(s,r({},d(m,a.params||{}),b),a.url);b=g(s).then(function(d){var k=d.data;if(k){if(e.isArray(k)!==!!a.isArray)throw y("badcfg",c,a.isArray?"array":"object",e.isArray(k)?"array":"object",s.method,s.url);if(a.isArray)p.length=0,v(k,function(a){"object"===typeof a?p.push(new l(a)):p.push(a)});else{var b=p.$promise;
F(k,p);p.$promise=b}}d.resource=p;return d},function(a){(B||I)(a);return G.reject(a)});b.finally(function(){p.$resolved=!0;!C&&u&&(p.$cancelRequest=e.noop,D=s.timeout=null)});b=b.then(function(a){var c=z(a);(w||I)(c,a.headers);return c},A);return C?b:(p.$promise=b,p.$resolved=!1,u&&(p.$cancelRequest=D.resolve),p)};l.prototype["$"+c]=function(a,d,b){x(a)&&(b=d,d=a,a={});a=l[c].call(this,a,this,d,b);return a.$promise||a}});l.bind=function(a){return H(u,r({},f,a),m)};return l}var I=e.noop,v=e.forEach,
r=e.extend,M=e.copy,x=e.isFunction;A.prototype={setUrlParams:function(b,f,m){var h=this,d=m||h.template,g,l,r="",a=h.urlParams={};v(d.split(/\W/),function(c){if("hasOwnProperty"===c)throw y("badname");!/^\d+$/.test(c)&&c&&(new RegExp("(^|[^\\\\]):"+c+"(\\W|$)")).test(d)&&(a[c]={isQueryParamValue:(new RegExp("\\?.*=:"+c+"(?:\\W|$)")).test(d)})});d=d.replace(/\\:/g,":");d=d.replace(t,function(a){r=a;return""});f=f||{};v(h.urlParams,function(a,b){g=f.hasOwnProperty(b)?f[b]:h.defaults[b];e.isDefined(g)&&
null!==g?(l=a.isQueryParamValue?z(g,!0):z(g,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+"),d=d.replace(new RegExp(":"+b+"(\\W|$)","g"),function(a,b){return l+b})):d=d.replace(new RegExp("(/?):"+b+"(\\W|$)","g"),function(a,b,c){return"/"==c.charAt(0)?c:b+c})});h.defaults.stripTrailingSlashes&&(d=d.replace(/\/+$/,"")||"/");d=d.replace(/\/\.(?=\w+($|\?))/,".");b.url=r+d.replace(/\/\\\./,"/.");v(f,function(a,d){h.urlParams[d]||(b.params=b.params||{},b.params[d]=a)})}};return H}]})})(window,
window.angular);
//# sourceMappingURL=angular-resource.min.js.map
{
"name": "angular-resource",
"version": "1.5.0-beta.2",
"version": "1.5.0-rc.0",
"main": "./angular-resource.js",
"ignore": [],
"dependencies": {
"angular": "1.5.0-beta.2"
"angular": "1.5.0-rc.0"
}
}
{
"name": "angular-resource",
"version": "1.5.0-beta.2",
"version": "1.5.0-rc.0",
"description": "AngularJS module for interacting with RESTful server-side data sources",

@@ -5,0 +5,0 @@ "main": "index.js",

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