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

Commit e9bf93d

Browse files
committed
refactor(*): rename internal function int to toInt
Renamed the internal function `int` to `toInt` as `int` is a reserved word Closes #7768
1 parent 2e721a7 commit e9bf93d

File tree

11 files changed

+28
-28
lines changed

11 files changed

+28
-28
lines changed

Diff for: src/.jshintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"nextUid": false,
3535
"setHashKey": false,
3636
"extend": false,
37-
"int": false,
37+
"toInt": false,
3838
"inherit": false,
3939
"noop": false,
4040
"identity": false,

Diff for: src/Angular.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
nextUid: true,
2929
setHashKey: true,
3030
extend: true,
31-
int: true,
31+
toInt: true,
3232
inherit: true,
3333
noop: true,
3434
identity: true,
@@ -357,7 +357,7 @@ function extend(dst) {
357357
return dst;
358358
}
359359

360-
function int(str) {
360+
function toInt(str) {
361361
return parseInt(str, 10);
362362
}
363363

Diff for: src/ng/directive/validators.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var maxlengthDirective = function() {
6060

6161
var maxlength = -1;
6262
attr.$observe('maxlength', function(value) {
63-
var intVal = int(value);
63+
var intVal = toInt(value);
6464
maxlength = isNaN(intVal) ? -1 : intVal;
6565
ctrl.$validate();
6666
});
@@ -80,7 +80,7 @@ var minlengthDirective = function() {
8080

8181
var minlength = 0;
8282
attr.$observe('minlength', function(value) {
83-
minlength = int(value) || 0;
83+
minlength = toInt(value) || 0;
8484
ctrl.$validate();
8585
});
8686
ctrl.$validators.minlength = function(modelValue, viewValue) {

Diff for: src/ng/filter/filters.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,13 @@ function dateFilter($locale) {
429429
timeSetter = match[8] ? date.setUTCHours : date.setHours;
430430

431431
if (match[9]) {
432-
tzHour = int(match[9] + match[10]);
433-
tzMin = int(match[9] + match[11]);
432+
tzHour = toInt(match[9] + match[10]);
433+
tzMin = toInt(match[9] + match[11]);
434434
}
435-
dateSetter.call(date, int(match[1]), int(match[2]) - 1, int(match[3]));
436-
var h = int(match[4] || 0) - tzHour;
437-
var m = int(match[5] || 0) - tzMin;
438-
var s = int(match[6] || 0);
435+
dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3]));
436+
var h = toInt(match[4] || 0) - tzHour;
437+
var m = toInt(match[5] || 0) - tzMin;
438+
var s = toInt(match[6] || 0);
439439
var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
440440
timeSetter.call(date, h, m, s, ms);
441441
return date;
@@ -452,7 +452,7 @@ function dateFilter($locale) {
452452
format = format || 'mediumDate';
453453
format = $locale.DATETIME_FORMATS[format] || format;
454454
if (isString(date)) {
455-
date = NUMBER_STRING.test(date) ? int(date) : jsonStringToDate(date);
455+
date = NUMBER_STRING.test(date) ? toInt(date) : jsonStringToDate(date);
456456
}
457457

458458
if (isNumber(date)) {

Diff for: src/ng/filter/limitTo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function limitToFilter() {
9292
if (Math.abs(Number(limit)) === Infinity) {
9393
limit = Number(limit);
9494
} else {
95-
limit = int(limit);
95+
limit = toInt(limit);
9696
}
9797
if (isNaN(limit)) return input;
9898

Diff for: src/ng/location.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function parseAbsoluteUrl(absoluteUrl, locationObj) {
2727

2828
locationObj.$$protocol = parsedUrl.protocol;
2929
locationObj.$$host = parsedUrl.hostname;
30-
locationObj.$$port = int(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null;
30+
locationObj.$$port = toInt(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null;
3131
}
3232

3333

Diff for: src/ng/sniffer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function $SnifferProvider() {
1818
this.$get = ['$window', '$document', function($window, $document) {
1919
var eventSupport = {},
2020
android =
21-
int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),
21+
toInt((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),
2222
boxee = /Boxee/i.test(($window.navigator || {}).userAgent),
2323
document = $document[0] || {},
2424
vendorPrefix,

Diff for: src/ngMock/angular-mocks.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -574,20 +574,20 @@ function jsonStringToDate(string) {
574574
tzHour = 0,
575575
tzMin = 0;
576576
if (match[9]) {
577-
tzHour = int(match[9] + match[10]);
578-
tzMin = int(match[9] + match[11]);
577+
tzHour = toInt(match[9] + match[10]);
578+
tzMin = toInt(match[9] + match[11]);
579579
}
580-
date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3]));
581-
date.setUTCHours(int(match[4] || 0) - tzHour,
582-
int(match[5] || 0) - tzMin,
583-
int(match[6] || 0),
584-
int(match[7] || 0));
580+
date.setUTCFullYear(toInt(match[1]), toInt(match[2]) - 1, toInt(match[3]));
581+
date.setUTCHours(toInt(match[4] || 0) - tzHour,
582+
toInt(match[5] || 0) - tzMin,
583+
toInt(match[6] || 0),
584+
toInt(match[7] || 0));
585585
return date;
586586
}
587587
return string;
588588
}
589589

590-
function int(str) {
590+
function toInt(str) {
591591
return parseInt(str, 10);
592592
}
593593

Diff for: test/.jshintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"nextUid": false,
3232
"setHashKey": false,
3333
"extend": false,
34-
"int": false,
34+
"toInt": false,
3535
"inherit": false,
3636
"noop": false,
3737
"identity": false,

Diff for: test/ng/directive/inputSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ describe('input', function() {
21692169
var value = 0;
21702170
var inputElm = helper.compileInput('<input type="number" ng-model="value" ng-minlength="min" attr-capture />');
21712171
helper.attrs.$observe('minlength', function(v) {
2172-
value = int(helper.attrs.minlength);
2172+
value = toInt(helper.attrs.minlength);
21732173
});
21742174

21752175
$rootScope.$apply(function() {
@@ -2215,7 +2215,7 @@ describe('input', function() {
22152215
var value = 0;
22162216
var inputElm = helper.compileInput('<input type="number" ng-model="value" ng-maxlength="max" attr-capture />');
22172217
helper.attrs.$observe('maxlength', function(v) {
2218-
value = int(helper.attrs.maxlength);
2218+
value = toInt(helper.attrs.maxlength);
22192219
});
22202220

22212221
$rootScope.$apply(function() {

Diff for: test/ng/directive/validatorsSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ describe('validators', function() {
224224
var value = 0;
225225
var inputElm = helper.compileInput('<input type="text" ng-model="value" ng-minlength="min" attr-capture />');
226226
helper.attrs.$observe('minlength', function(v) {
227-
value = int(helper.attrs.minlength);
227+
value = toInt(helper.attrs.minlength);
228228
});
229229

230230
$rootScope.$apply('min = 5');
@@ -318,7 +318,7 @@ describe('validators', function() {
318318
var value = 0;
319319
var inputElm = helper.compileInput('<input type="text" ng-model="value" ng-maxlength="max" attr-capture />');
320320
helper.attrs.$observe('maxlength', function(v) {
321-
value = int(helper.attrs.maxlength);
321+
value = toInt(helper.attrs.maxlength);
322322
});
323323

324324
$rootScope.$apply('max = 10');

0 commit comments

Comments
 (0)