optimized ipAddress parser

This commit is contained in:
Rob Garrison 2012-07-12 02:25:32 -05:00
parent 718ef4e79b
commit 3951345f69

View File

@ -1023,18 +1023,11 @@
return (/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/).test(s);
},
format: function(s, table) {
var i, item, a = s.split("."),
var i, a = s.split("."),
r = "",
l = a.length;
for (i = 0; i < l; i++) {
item = a[i];
if (item.length === 1) {
r += "00" + item;
} else if (item.length === 2) {
r += "0" + item;
} else {
r += item;
}
r += ("00" + a[i]).slice(-3);
}
return ts.formatFloat(r, table);
},