Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit bf61c14

Browse files
committed
refactor($resource): use local references of Angular helpers
1 parent 6eb4ffc commit bf61c14

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/ngResource/resource.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,10 @@ angular.module('ngResource', ['ng']).
522522
forEach = angular.forEach,
523523
extend = angular.extend,
524524
copy = angular.copy,
525+
isArray = angular.isArray,
526+
isDefined = angular.isDefined,
525527
isFunction = angular.isFunction,
528+
isNumber = angular.isNumber,
526529
encodeUriQuery = angular.$$encodeUriQuery,
527530
encodeUriSegment = angular.$$encodeUriSegment;
528531

@@ -561,7 +564,7 @@ angular.module('ngResource', ['ng']).
561564
params = params || {};
562565
forEach(self.urlParams, function(paramInfo, urlParam) {
563566
val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam];
564-
if (angular.isDefined(val) && val !== null) {
567+
if (isDefined(val) && val !== null) {
565568
if (paramInfo.isQueryParamValue) {
566569
encodedVal = encodeUriQuery(val, true);
567570
} else {
@@ -639,11 +642,11 @@ angular.module('ngResource', ['ng']).
639642
forEach(actions, function(action, name) {
640643
var hasBody = /^(POST|PUT|PATCH)$/i.test(action.method);
641644
var numericTimeout = action.timeout;
642-
var cancellable = angular.isDefined(action.cancellable) ? action.cancellable :
643-
(options && angular.isDefined(options.cancellable)) ? options.cancellable :
645+
var cancellable = isDefined(action.cancellable) ? action.cancellable :
646+
(options && isDefined(options.cancellable)) ? options.cancellable :
644647
provider.defaults.cancellable;
645648

646-
if (numericTimeout && !angular.isNumber(numericTimeout)) {
649+
if (numericTimeout && !isNumber(numericTimeout)) {
647650
$log.debug('ngResource:\n' +
648651
' Only numeric values are allowed as `timeout`.\n' +
649652
' Promises are not supported in $resource, because the same value would ' +
@@ -736,11 +739,11 @@ angular.module('ngResource', ['ng']).
736739

737740
if (data) {
738741
// Need to convert action.isArray to boolean in case it is undefined
739-
if (angular.isArray(data) !== (!!action.isArray)) {
742+
if (isArray(data) !== (!!action.isArray)) {
740743
throw $resourceMinErr('badcfg',
741744
'Error in resource configuration for action `{0}`. Expected response to ' +
742745
'contain an {1} but got an {2} (Request: {3} {4})', name, action.isArray ? 'array' : 'object',
743-
angular.isArray(data) ? 'array' : 'object', httpConfig.method, httpConfig.url);
746+
isArray(data) ? 'array' : 'object', httpConfig.method, httpConfig.url);
744747
}
745748
if (action.isArray) {
746749
value.length = 0;
@@ -768,7 +771,7 @@ angular.module('ngResource', ['ng']).
768771
promise = promise['finally'](function() {
769772
value.$resolved = true;
770773
if (!isInstanceCall && cancellable) {
771-
value.$cancelRequest = angular.noop;
774+
value.$cancelRequest = noop;
772775
$timeout.cancel(numericTimeoutPromise);
773776
timeoutDeferred = numericTimeoutPromise = httpConfig.timeout = null;
774777
}

0 commit comments

Comments
 (0)