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

angular-resource

Package Overview
Dependencies
Maintainers
2
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.6.10 to 1.7.0-rc.0

408

angular-resource.js
/**
* @license AngularJS v1.6.10
* @license AngularJS v1.7.0-rc.0
* (c) 2010-2018 Google, Inc. http://angularjs.org

@@ -118,4 +118,4 @@ * License: MIT

* `actions` methods. If a parameter value is a function, it will be called every time
* a param value needs to be obtained for a request (unless the param was overridden). The function
* will be passed the current data value as an argument.
* a param value needs to be obtained for a request (unless the param was overridden). The
* function will be passed the current data value as an argument.
*

@@ -125,3 +125,3 @@ * Each key value in the parameter object is first bound to url template if present and then any

*
* Given a template `/path/:verb` and parameter `{verb:'greet', salutation:'Hello'}` results in
* Given a template `/path/:verb` and parameter `{verb: 'greet', salutation: 'Hello'}` results in
* URL `/path/greet?salutation=Hello`.

@@ -135,3 +135,3 @@ *

* Note that the parameter will be ignored, when calling a "GET" action method (i.e. an action
* method that does not accept a request body)
* method that does not accept a request body).
*

@@ -145,5 +145,7 @@ * @param {Object.<Object>=} actions Hash with declaration of custom actions that will be available

*
* {action1: {method:?, params:?, isArray:?, headers:?, ...},
* action2: {method:?, params:?, isArray:?, headers:?, ...},
* ...}
* {
* action1: {method:?, params:?, isArray:?, headers:?, ...},
* action2: {method:?, params:?, isArray:?, headers:?, ...},
* ...
* }
*

@@ -160,3 +162,3 @@ * Where:

* current data value as an argument.
* - **`url`** – {string} – action specific `url` override. The url templating is supported just
* - **`url`** – {string} – Action specific `url` override. The url templating is supported just
* like for the resource-level urls.

@@ -167,3 +169,3 @@ * - **`isArray`** – {boolean=} – If true then the returned object for this action is an array,

* `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –
* transform function or an array of such functions. The transform function takes the http
* Transform function or an array of such functions. The transform function takes the http
* request body and headers and returns its transformed (typically serialized) version.

@@ -175,3 +177,3 @@ * By default, transformRequest will contain one function that checks if the request data is

* `{function(data, headersGetter, status)|Array.<function(data, headersGetter, status)>}` –
* transform function or an array of such functions. The transform function takes the http
* Transform function or an array of such functions. The transform function takes the HTTP
* response body, headers and status and returns its transformed (typically deserialized)

@@ -182,31 +184,35 @@ * version.

* set `transformResponse` to an empty array: `transformResponse: []`
* - **`cache`** – `{boolean|Cache}` – If true, a default $http cache will be used to cache the
* GET request, otherwise if a cache instance built with
* {@link ng.$cacheFactory $cacheFactory} is supplied, this cache will be used for
* caching.
* - **`timeout`** – `{number}` – timeout in milliseconds.<br />
* - **`cache`** – `{boolean|Cache}` – A boolean value or object created with
* {@link ng.$cacheFactory `$cacheFactory`} to enable or disable caching of the HTTP response.
* See {@link $http#caching $http Caching} for more information.
* - **`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.
* **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 />
* - **`withCredentials`** - `{boolean}` - whether to set the `withCredentials` flag on the
* - **`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. Calling `$cancelRequest()` for a non-cancellable or an already completed/cancelled
* request will have no effect.
* - **`withCredentials`** – `{boolean}` – Whether to set the `withCredentials` flag on the
* XHR object. See
* [requests with credentials](https://developer.mozilla.org/en/http_access_control#section_5)
* [XMLHttpRequest.withCredentials](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials)
* for more information.
* - **`responseType`** - `{string}` - see
* [requestType](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#responseType).
* - **`interceptor`** - `{Object=}` - The interceptor object has two optional methods -
* `response` and `responseError`. Both `response` and `responseError` interceptors get called
* with `http response` object. See {@link ng.$http $http interceptors}. In addition, the
* resource instance or array object is accessible by the `resource` property of the
* `http response` object.
* - **`responseType`** – `{string}` – See
* [XMLHttpRequest.responseType](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType).
* - **`interceptor`** – `{Object=}` – The interceptor object has four optional methods -
* `request`, `requestError`, `response`, and `responseError`. See
* {@link ng.$http#interceptors $http interceptors} for details. Note that
* `request`/`requestError` interceptors are applied before calling `$http`, thus before any
* global `$http` interceptors. Also, rejecting or throwing an error inside the `request`
* interceptor will result in calling the `responseError` interceptor.
* The resource instance or collection is available on the `resource` property of the
* `http response` object passed to `response`/`responseError` interceptors.
* Keep in mind that the associated promise will be resolved with the value returned by the
* response interceptor, if one is specified. The default response interceptor returns
* `response.resource` (i.e. the resource instance or array).
* - **`hasBody`** - `{boolean}` - allows to specify if a request body should be included or not.
* If not specified only POST, PUT and PATCH requests will have a body.
*
* response interceptors. Make sure you return an appropriate value and not the `response`
* object passed as input. For reference, the default `response` interceptor (which gets applied
* if you don't specify a custom one) returns `response.resource`.<br />
* See {@link ngResource.$resource#using-interceptors below} for an example of using
* interceptors in `$resource`.
* - **`hasBody`** – `{boolean}` – If true, then the request will have a body.
* If not specified, then only POST, PUT and PATCH requests will have a body. *
* @param {Object} options Hash with custom settings that should extend the

@@ -224,17 +230,19 @@ * default `$resourceProvider` behavior. The supported options are:

* ```js
* { 'get': {method:'GET'},
* 'save': {method:'POST'},
* 'query': {method:'GET', isArray:true},
* 'remove': {method:'DELETE'},
* 'delete': {method:'DELETE'} };
* {
* 'get': {method: 'GET'},
* 'save': {method: 'POST'},
* 'query': {method: 'GET', isArray: true},
* 'remove': {method: 'DELETE'},
* 'delete': {method: 'DELETE'}
* }
* ```
*
* Calling these methods invoke an {@link ng.$http} with the specified http method,
* destination and parameters. When the data is returned from the server then the object is an
* instance of the resource class. The actions `save`, `remove` and `delete` are available on it
* as methods with the `$` prefix. This allows you to easily perform CRUD operations (create,
* read, update, delete) on server-side data like this:
* Calling these methods invoke {@link ng.$http} with the specified http method, destination and
* parameters. When the data is returned from the server then the object is an instance of the
* resource class. The actions `save`, `remove` and `delete` are available on it as methods with
* the `$` prefix. This allows you to easily perform CRUD operations (create, read, update,
* delete) on server-side data like this:
* ```js
* var User = $resource('/user/:userId', {userId:'@id'});
* var user = User.get({userId:123}, function() {
* var User = $resource('/user/:userId', {userId: '@id'});
* User.get({userId: 123}).$promise.then(function(user) {
* user.abc = true;

@@ -245,3 +253,3 @@ * user.$save();

*
* It is important to realize that invoking a $resource object method immediately returns an
* It is important to realize that invoking a `$resource` object method immediately returns an
* empty reference (object or array depending on `isArray`). Once the data is returned from the

@@ -269,16 +277,16 @@ * server the existing reference is populated with the actual data. This is a useful trick since

* Success callback is called with (value (Object|Array), responseHeaders (Function),
* status (number), statusText (string)) arguments, where the value is the populated resource
* status (number), statusText (string)) arguments, where `value` is the populated resource
* instance or collection object. The error callback is called with (httpResponse) argument.
*
* Class actions return empty instance (with additional properties below).
* Instance actions return promise of the action.
* Class actions return an empty instance (with the additional properties listed below).
* Instance actions return a promise for the operation.
*
* The Resource instances and collections have these additional properties:
*
* - `$promise`: the {@link ng.$q promise} of the original server interaction that created this
* - `$promise`: The {@link ng.$q promise} of the original server interaction that created this
* instance or collection.
*
* On success, the promise is resolved with the same resource instance or collection object,
* updated with data from server. This makes it easy to use in
* {@link ngRoute.$routeProvider resolve section of $routeProvider.when()} to defer view
* updated with data from server. This makes it easy to use in the
* {@link ngRoute.$routeProvider `resolve` section of `$routeProvider.when()`} to defer view
* rendering until the resource(s) are loaded.

@@ -289,7 +297,8 @@ *

* If an interceptor object was provided, the promise will instead be resolved with the value
* returned by the interceptor.
* returned by the response interceptor (on success) or responceError interceptor (on failure).
*
* - `$resolved`: `true` after first server interaction is completed (either with success or
* rejection), `false` before that. Knowing if the Resource has been resolved is useful in
* data-binding.
* data-binding. If there is a response/responseError interceptor and it returns a promise,
* `$resolved` will wait for that too.
*

@@ -311,48 +320,58 @@ * The Resource instances and collections have these additional methods:

*
* ### Credit card resource
* ### Basic usage
*
* ```js
// Define CreditCard class
var CreditCard = $resource('/user/:userId/card/:cardId',
{userId:123, cardId:'@id'}, {
charge: {method:'POST', params:{charge:true}}
});
```js
// Define a CreditCard class
var CreditCard = $resource('/users/:userId/cards/:cardId',
{userId: 123, cardId: '@id'}, {
charge: {method: 'POST', params: {charge: true}}
});
// We can retrieve a collection from the server
var cards = CreditCard.query(function() {
// GET: /user/123/card
// server returns: [ {id:456, number:'1234', name:'Smith'} ];
var cards = CreditCard.query();
// GET: /users/123/cards
// server returns: [{id: 456, number: '1234', name: 'Smith'}]
// Wait for the request to complete
cards.$promise.then(function() {
var card = cards[0];
// each item is an instance of CreditCard
// Each item is an instance of CreditCard
expect(card instanceof CreditCard).toEqual(true);
card.name = "J. Smith";
// non GET methods are mapped onto the instances
// Non-GET methods are mapped onto the instances
card.name = 'J. Smith';
card.$save();
// POST: /user/123/card/456 {id:456, number:'1234', name:'J. Smith'}
// server returns: {id:456, number:'1234', name: 'J. Smith'};
// POST: /users/123/cards/456 {id: 456, number: '1234', name: 'J. Smith'}
// server returns: {id: 456, number: '1234', name: 'J. Smith'}
// our custom method is mapped as well.
card.$charge({amount:9.99});
// POST: /user/123/card/456?amount=9.99&charge=true {id:456, number:'1234', name:'J. Smith'}
// Our custom method is mapped as well (since it uses POST)
card.$charge({amount: 9.99});
// POST: /users/123/cards/456?amount=9.99&charge=true {id: 456, number: '1234', name: 'J. Smith'}
});
// we can create an instance as well
var newCard = new CreditCard({number:'0123'});
newCard.name = "Mike Smith";
newCard.$save();
// POST: /user/123/card {number:'0123', name:'Mike Smith'}
// server returns: {id:789, number:'0123', name: 'Mike Smith'};
expect(newCard.id).toEqual(789);
* ```
// We can create an instance as well
var newCard = new CreditCard({number: '0123'});
newCard.name = 'Mike Smith';
var savePromise = newCard.$save();
// POST: /users/123/cards {number: '0123', name: 'Mike Smith'}
// server returns: {id: 789, number: '0123', name: 'Mike Smith'}
savePromise.then(function() {
// Once the promise is resolved, the created instance
// is populated with the data returned by the server
expect(newCard.id).toEqual(789);
});
```
*
* The object returned from this function execution is a resource "class" which has "static" method
* for each action in the definition.
* The object returned from a call to `$resource` is a resource "class" which has one "static"
* method for each action in the definition.
*
* Calling these methods invoke `$http` on the `url` template with the given `method`, `params` and
* `headers`.
* Calling these methods invokes `$http` on the `url` template with the given HTTP `method`,
* `params` and `headers`.
*
* @example
*
* ### User resource
* ### Accessing the response
*

@@ -362,6 +381,6 @@ * When the data is returned from the server then the object is an instance of the resource type and

* operations (create, read, update, delete) on server-side data.
*
```js
var User = $resource('/user/:userId', {userId:'@id'});
User.get({userId:123}, function(user) {
var User = $resource('/users/:userId', {userId: '@id'});
User.get({userId: 123}).$promise.then(function(user) {
user.abc = true;

@@ -372,13 +391,14 @@ user.$save();

*
* It's worth noting that the success callback for `get`, `query` and other methods gets passed
* in the response that came from the server as well as $http header getter function, so one
* could rewrite the above example and get access to http headers as:
* It's worth noting that the success callback for `get`, `query` and other methods gets called with
* the resource instance (populated with the data that came from the server) as well as an `$http`
* header getter function, the HTTP status code and the response status text. So one could rewrite
* the above example and get access to HTTP headers as follows:
*
```js
var User = $resource('/user/:userId', {userId:'@id'});
User.get({userId:123}, function(user, getResponseHeaders){
var User = $resource('/users/:userId', {userId: '@id'});
User.get({userId: 123}, function(user, getResponseHeaders) {
user.abc = true;
user.$save(function(user, putResponseHeaders) {
//user => saved user object
//putResponseHeaders => $http header getter
// `user` => saved `User` object
// `putResponseHeaders` => `$http` header getter
});

@@ -388,44 +408,40 @@ });

*
* You can also access the raw `$http` promise via the `$promise` property on the object returned
*
```
var User = $resource('/user/:userId', {userId:'@id'});
User.get({userId:123})
.$promise.then(function(user) {
$scope.user = user;
});
```
*
* @example
*
* ### Creating a custom 'PUT' request
* ### Creating custom actions
*
* In this example we create a custom method on our resource to make a PUT request
* ```js
* var app = angular.module('app', ['ngResource', 'ngRoute']);
* In this example we create a custom method on our resource to make a PUT request:
*
* // Some APIs expect a PUT request in the format URL/object/ID
* // Here we are creating an 'update' method
* app.factory('Notes', ['$resource', function($resource) {
* return $resource('/notes/:id', null,
* {
* 'update': { method:'PUT' }
* });
* }]);
```js
var app = angular.module('app', ['ngResource']);
// Some APIs expect a PUT request in the format URL/object/ID
// Here we are creating an 'update' method
app.factory('Notes', ['$resource', function($resource) {
return $resource('/notes/:id', {id: '@id'}, {
update: {method: 'PUT'}
});
}]);
// In our controller we get the ID from the URL using `$location`
app.controller('NotesCtrl', ['$location', 'Notes', function($location, Notes) {
// First, retrieve the corresponding `Note` object from the server
// (Assuming a URL of the form `.../notes?id=XYZ`)
var noteId = $location.search().id;
var note = Notes.get({id: noteId});
note.$promise.then(function() {
note.content = 'Hello, world!';
// Now call `update` to save the changes on the server
Notes.update(note);
// This will PUT /notes/ID with the note object as the request payload
// Since `update` is a non-GET method, it will also be available on the instance
// (prefixed with `$`), so we could replace the `Note.update()` call with:
//note.$update();
});
}]);
```
*
* // In our controller we get the ID from the URL using ngRoute and $routeParams
* // We pass in $routeParams and our Notes factory along with $scope
* app.controller('NotesCtrl', ['$scope', '$routeParams', 'Notes',
function($scope, $routeParams, Notes) {
* // First get a note object from the factory
* var note = Notes.get({ id:$routeParams.id });
* $id = note.id;
*
* // Now call update passing in the ID first then the object you are updating
* Notes.update({ id:$id }, note);
*
* // This will PUT /notes/ID with the note object in the request payload
* }]);
* ```
*
* @example

@@ -440,3 +456,3 @@ *

// ...defining the `Hotel` resource...
var Hotel = $resource('/api/hotel/:id', {id: '@id'}, {
var Hotel = $resource('/api/hotels/:id', {id: '@id'}, {
// Let's make the `query()` method cancellable

@@ -451,6 +467,8 @@ query: {method: 'get', isArray: true, cancellable: true}

// in a different destination any more
this.availableHotels.$cancelRequest();
if (this.availableHotels) {
this.availableHotels.$cancelRequest();
}
// Let's query for hotels in '<destination>'
// (calls: /api/hotel?location=<destination>)
// Let's query for hotels in `destination`
// (calls: /api/hotels?location=<destination>)
this.availableHotels = Hotel.query({location: destination});

@@ -460,5 +478,43 @@ };

*
* @example
*
* ### Using interceptors
*
* You can use interceptors to transform the request or response, perform additional operations, and
* modify the returned instance/collection. The following example, uses `request` and `response`
* interceptors to augment the returned instance with additional info:
*
```js
var Thing = $resource('/api/things/:id', {id: '@id'}, {
save: {
method: 'POST',
interceptor: {
request: function(config) {
// Before the request is sent out, store a timestamp on the request config
config.requestTimestamp = Date.now();
return config;
},
response: function(response) {
// Get the instance from the response object
var instance = response.resource;
// Augment the instance with a custom `saveLatency` property, computed as the time
// between sending the request and receiving the response.
instance.saveLatency = Date.now() - response.config.requestTimestamp;
// Return the instance
return instance;
}
}
}
});
Thing.save({foo: 'bar'}).$promise.then(function(thing) {
console.log('That thing was saved in ' + thing.saveLatency + 'ms.');
});
```
*
*/
angular.module('ngResource', ['ng']).
info({ angularVersion: '1.6.10' }).
info({ angularVersion: '1.7.0-rc.0' }).
provider('$resource', function ResourceProvider() {

@@ -693,8 +749,8 @@ var PROTOCOL_AND_IPV6_REGEX = /^https?:\/\/\[[^\]]*][^/]*/;

Resource[name] = function(a1, a2, a3, a4) {
var params = {}, data, success, error;
var params = {}, data, onSuccess, onError;
switch (arguments.length) {
case 4:
error = a4;
success = a3;
onError = a4;
onSuccess = a3;
// falls through

@@ -705,9 +761,9 @@ case 3:

if (isFunction(a1)) {
success = a1;
error = a2;
onSuccess = a1;
onError = a2;
break;
}
success = a2;
error = a3;
onSuccess = a2;
onError = a3;
// falls through

@@ -717,3 +773,3 @@ } else {

data = a2;
success = a3;
onSuccess = a3;
break;

@@ -723,3 +779,3 @@ }

case 1:
if (isFunction(a1)) success = a1;
if (isFunction(a1)) onSuccess = a1;
else if (hasBody) data = a1;

@@ -738,10 +794,16 @@ else params = a1;

var httpConfig = {};
var requestInterceptor = action.interceptor && action.interceptor.request || undefined;
var requestErrorInterceptor = action.interceptor && action.interceptor.requestError ||
undefined;
var responseInterceptor = action.interceptor && action.interceptor.response ||
defaultResponseInterceptor;
var responseErrorInterceptor = action.interceptor && action.interceptor.responseError ||
undefined;
var hasError = !!error;
var hasResponseErrorInterceptor = !!responseErrorInterceptor;
$q.reject;
var successCallback = onSuccess ? function(val) {
onSuccess(val, response.headers, response.status, response.statusText);
} : undefined;
var errorCallback = onError || undefined;
var timeoutDeferred;
var numericTimeoutPromise;
var response;

@@ -775,5 +837,12 @@ forEach(action, function(value, key) {

var promise = $http(httpConfig).then(function(response) {
var data = response.data;
// Start the promise chain
var promise = $q.
resolve(httpConfig).
then(requestInterceptor).
catch(requestErrorInterceptor).
then($http);
promise = promise.then(function(resp) {
var data = resp.data;
if (data) {

@@ -805,8 +874,10 @@ // Need to convert action.isArray to boolean in case it is undefined

}
response.resource = value;
return response;
}, function(response) {
response.resource = value;
return $q.reject(response);
resp.resource = value;
response = resp;
return responseInterceptor(resp);
}, function(rejectionOrResponse) {
rejectionOrResponse.resource = value;
response = rejectionOrResponse;
return responseErrorInterceptor(rejectionOrResponse);
});

@@ -823,21 +894,4 @@

promise = promise.then(
function(response) {
var value = responseInterceptor(response);
(success || noop)(value, response.headers, response.status, response.statusText);
return value;
},
(hasError || hasResponseErrorInterceptor) ?
function(response) {
if (hasError && !hasResponseErrorInterceptor) {
// Avoid `Possibly Unhandled Rejection` error,
// but still fulfill the returned promise with a rejection
promise.catch(noop);
}
if (hasError) error(response);
return hasResponseErrorInterceptor ?
responseErrorInterceptor(response) :
$q.reject(response);
} :
undefined);
// Run the `success`/`error` callbacks, but do not let them affect the returned promise.
promise.then(successCallback, errorCallback);

@@ -844,0 +898,0 @@ if (!isInstanceCall) {

/*
AngularJS v1.6.10
AngularJS v1.7.0-rc.0
(c) 2010-2018 Google, Inc. http://angularjs.org
License: MIT
*/
(function(U,a){'use strict';function L(m,f){f=f||{};a.forEach(f,function(a,d){delete f[d]});for(var d in m)!m.hasOwnProperty(d)||"$"===d.charAt(0)&&"$"===d.charAt(1)||(f[d]=m[d]);return f}var B=a.$$minErr("$resource"),Q=/^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/;a.module("ngResource",["ng"]).info({angularVersion:"1.6.10"}).provider("$resource",function(){var m=/^https?:\/\/\[[^\]]*][^/]*/,f=this;this.defaults={stripTrailingSlashes:!0,cancellable:!1,actions:{get:{method:"GET"},save:{method:"POST"},query:{method:"GET",
isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"}}};this.$get=["$http","$log","$q","$timeout",function(d,P,F,M){function C(a,d){this.template=a;this.defaults=n({},f.defaults,d);this.urlParams={}}var D=a.noop,r=a.forEach,n=a.extend,R=a.copy,N=a.isArray,w=a.isDefined,x=a.isFunction,S=a.isNumber,y=a.$$encodeUriQuery,T=a.$$encodeUriSegment;C.prototype={setUrlParams:function(a,d,f){var g=this,c=f||g.template,s,h,n="",b=g.urlParams=Object.create(null);r(c.split(/\W/),function(a){if("hasOwnProperty"===
a)throw B("badname");!/^\d+$/.test(a)&&a&&(new RegExp("(^|[^\\\\]):"+a+"(\\W|$)")).test(c)&&(b[a]={isQueryParamValue:(new RegExp("\\?.*=:"+a+"(?:\\W|$)")).test(c)})});c=c.replace(/\\:/g,":");c=c.replace(m,function(b){n=b;return""});d=d||{};r(g.urlParams,function(b,a){s=d.hasOwnProperty(a)?d[a]:g.defaults[a];w(s)&&null!==s?(h=b.isQueryParamValue?y(s,!0):T(s),c=c.replace(new RegExp(":"+a+"(\\W|$)","g"),function(b,a){return h+a})):c=c.replace(new RegExp("(/?):"+a+"(\\W|$)","g"),function(a,b,e){return"/"===
e.charAt(0)?e:b+e})});g.defaults.stripTrailingSlashes&&(c=c.replace(/\/+$/,"")||"/");c=c.replace(/\/\.(?=\w+($|\?))/,".");a.url=n+c.replace(/\/(\\|%5C)\./,"/.");r(d,function(b,c){g.urlParams[c]||(a.params=a.params||{},a.params[c]=b)})}};return function(m,y,z,g){function c(b,c){var d={};c=n({},y,c);r(c,function(c,f){x(c)&&(c=c(b));var e;if(c&&c.charAt&&"@"===c.charAt(0)){e=b;var k=c.substr(1);if(null==k||""===k||"hasOwnProperty"===k||!Q.test("."+k))throw B("badmember",k);for(var k=k.split("."),h=0,
n=k.length;h<n&&a.isDefined(e);h++){var g=k[h];e=null!==e?e[g]:void 0}}else e=c;d[f]=e});return d}function s(b){return b.resource}function h(b){L(b||{},this)}var O=new C(m,g);z=n({},f.defaults.actions,z);h.prototype.toJSON=function(){var b=n({},this);delete b.$promise;delete b.$resolved;delete b.$cancelRequest;return b};r(z,function(b,a){var f=!0===b.hasBody||!1!==b.hasBody&&/^(POST|PUT|PATCH)$/i.test(b.method),g=b.timeout,m=w(b.cancellable)?b.cancellable:O.defaults.cancellable;g&&!S(g)&&(P.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 b.timeout,g=null);h[a]=function(e,k,G,y){function z(a){p.catch(D);null!==t&&t.resolve(a)}var H={},u,v,A;switch(arguments.length){case 4:A=y,v=G;case 3:case 2:if(x(k)){if(x(e)){v=e;A=k;break}v=k;A=G}else{H=e;u=k;v=G;break}case 1:x(e)?v=e:f?u=e:H=e;break;case 0:break;default:throw B("badargs",arguments.length);}var E=this instanceof h,l=E?u:b.isArray?[]:new h(u),q={},C=b.interceptor&&b.interceptor.response||s,w=b.interceptor&&b.interceptor.responseError||void 0,I=!!A,J=!!w,t,K;r(b,function(a,
b){switch(b){default:q[b]=R(a);case "params":case "isArray":case "interceptor":case "cancellable":}});!E&&m&&(t=F.defer(),q.timeout=t.promise,g&&(K=M(t.resolve,g)));f&&(q.data=u);O.setUrlParams(q,n({},c(u,b.params||{}),H),b.url);var p=d(q).then(function(c){var e=c.data;if(e){if(N(e)!==!!b.isArray)throw B("badcfg",a,b.isArray?"array":"object",N(e)?"array":"object",q.method,q.url);if(b.isArray)l.length=0,r(e,function(a){"object"===typeof a?l.push(new h(a)):l.push(a)});else{var d=l.$promise;L(e,l);l.$promise=
d}}c.resource=l;return c},function(a){a.resource=l;return F.reject(a)}),p=p["finally"](function(){l.$resolved=!0;!E&&m&&(l.$cancelRequest=D,M.cancel(K),t=K=q.timeout=null)}),p=p.then(function(a){var b=C(a);(v||D)(b,a.headers,a.status,a.statusText);return b},I||J?function(a){I&&!J&&p.catch(D);I&&A(a);return J?w(a):F.reject(a)}:void 0);return E?p:(l.$promise=p,l.$resolved=!1,m&&(l.$cancelRequest=z),l)};h.prototype["$"+a]=function(b,c,d){x(b)&&(d=c,c=b,b={});b=h[a].call(this,b,this,c,d);return b.$promise||
b}});return h}}]})})(window,window.angular);
(function(T,a){'use strict';function M(m,f){f=f||{};a.forEach(f,function(a,d){delete f[d]});for(var d in m)!m.hasOwnProperty(d)||"$"===d.charAt(0)&&"$"===d.charAt(1)||(f[d]=m[d]);return f}var B=a.$$minErr("$resource"),H=/^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/;a.module("ngResource",["ng"]).info({angularVersion:"1.7.0-rc.0"}).provider("$resource",function(){var m=/^https?:\/\/\[[^\]]*][^/]*/,f=this;this.defaults={stripTrailingSlashes:!0,cancellable:!1,actions:{get:{method:"GET"},save:{method:"POST"},query:{method:"GET",
isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"}}};this.$get=["$http","$log","$q","$timeout",function(d,F,G,N){function C(a,d){this.template=a;this.defaults=n({},f.defaults,d);this.urlParams={}}var O=a.noop,r=a.forEach,n=a.extend,R=a.copy,P=a.isArray,D=a.isDefined,x=a.isFunction,I=a.isNumber,y=a.$$encodeUriQuery,S=a.$$encodeUriSegment;C.prototype={setUrlParams:function(a,d,f){var g=this,c=f||g.template,s,h,n="",b=g.urlParams=Object.create(null);r(c.split(/\W/),function(a){if("hasOwnProperty"===
a)throw B("badname");!/^\d+$/.test(a)&&a&&(new RegExp("(^|[^\\\\]):"+a+"(\\W|$)")).test(c)&&(b[a]={isQueryParamValue:(new RegExp("\\?.*=:"+a+"(?:\\W|$)")).test(c)})});c=c.replace(/\\:/g,":");c=c.replace(m,function(b){n=b;return""});d=d||{};r(g.urlParams,function(b,a){s=d.hasOwnProperty(a)?d[a]:g.defaults[a];D(s)&&null!==s?(h=b.isQueryParamValue?y(s,!0):S(s),c=c.replace(new RegExp(":"+a+"(\\W|$)","g"),function(b,a){return h+a})):c=c.replace(new RegExp("(/?):"+a+"(\\W|$)","g"),function(b,a,e){return"/"===
e.charAt(0)?e:a+e})});g.defaults.stripTrailingSlashes&&(c=c.replace(/\/+$/,"")||"/");c=c.replace(/\/\.(?=\w+($|\?))/,".");a.url=n+c.replace(/\/(\\|%5C)\./,"/.");r(d,function(b,c){g.urlParams[c]||(a.params=a.params||{},a.params[c]=b)})}};return function(m,y,z,g){function c(b,c){var d={};c=n({},y,c);r(c,function(c,f){x(c)&&(c=c(b));var e;if(c&&c.charAt&&"@"===c.charAt(0)){e=b;var k=c.substr(1);if(null==k||""===k||"hasOwnProperty"===k||!H.test("."+k))throw B("badmember",k);for(var k=k.split("."),h=0,
n=k.length;h<n&&a.isDefined(e);h++){var g=k[h];e=null!==e?e[g]:void 0}}else e=c;d[f]=e});return d}function s(b){return b.resource}function h(b){M(b||{},this)}var Q=new C(m,g);z=n({},f.defaults.actions,z);h.prototype.toJSON=function(){var b=n({},this);delete b.$promise;delete b.$resolved;delete b.$cancelRequest;return b};r(z,function(b,a){var f=!0===b.hasBody||!1!==b.hasBody&&/^(POST|PUT|PATCH)$/i.test(b.method),g=b.timeout,m=D(b.cancellable)?b.cancellable:Q.defaults.cancellable;g&&!I(g)&&(F.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 b.timeout,g=null);h[a]=function(e,k,J,y){function z(a){p.catch(O);null!==u&&u.resolve(a)}var K={},v,t,w;switch(arguments.length){case 4:w=y,t=J;case 3:case 2:if(x(k)){if(x(e)){t=e;w=k;break}t=k;w=J}else{K=e;v=k;t=J;break}case 1:x(e)?t=e:f?v=e:K=e;break;case 0:break;default:throw B("badargs",arguments.length);}var E=this instanceof h,l=E?v:b.isArray?[]:new h(v),q={},C=b.interceptor&&b.interceptor.request||void 0,D=b.interceptor&&b.interceptor.requestError||void 0,F=b.interceptor&&b.interceptor.response||
s,H=b.interceptor&&b.interceptor.responseError||G.reject,I=t?function(a){t(a,A.headers,A.status,A.statusText)}:void 0;w=w||void 0;var u,L,A;r(b,function(a,b){switch(b){default:q[b]=R(a);case "params":case "isArray":case "interceptor":case "cancellable":}});!E&&m&&(u=G.defer(),q.timeout=u.promise,g&&(L=N(u.resolve,g)));f&&(q.data=v);Q.setUrlParams(q,n({},c(v,b.params||{}),K),b.url);var p=G.resolve(q).then(C).catch(D).then(d),p=p.then(function(c){var e=c.data;if(e){if(P(e)!==!!b.isArray)throw B("badcfg",
a,b.isArray?"array":"object",P(e)?"array":"object",q.method,q.url);if(b.isArray)l.length=0,r(e,function(a){"object"===typeof a?l.push(new h(a)):l.push(a)});else{var d=l.$promise;M(e,l);l.$promise=d}}c.resource=l;A=c;return F(c)},function(a){a.resource=l;A=a;return H(a)}),p=p["finally"](function(){l.$resolved=!0;!E&&m&&(l.$cancelRequest=O,N.cancel(L),u=L=q.timeout=null)});p.then(I,w);return E?p:(l.$promise=p,l.$resolved=!1,m&&(l.$cancelRequest=z),l)};h.prototype["$"+a]=function(b,c,d){x(b)&&(d=c,c=
b,b={});b=h[a].call(this,b,this,c,d);return b.$promise||b}});return h}}]})})(window,window.angular);
//# sourceMappingURL=angular-resource.min.js.map
{
"name": "angular-resource",
"version": "1.6.10",
"version": "1.7.0-rc.0",
"license": "MIT",

@@ -8,4 +8,4 @@ "main": "./angular-resource.js",

"dependencies": {
"angular": "1.6.10"
"angular": "1.7.0-rc.0"
}
}
{
"name": "angular-resource",
"version": "1.6.10",
"version": "1.7.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