diff --git a/src/number.js b/src/number.js index 0da58b1..8fea757 100644 --- a/src/number.js +++ b/src/number.js @@ -1,27 +1,51 @@ -Object.extend(Number.prototype, { - toColorPart: function() { +Object.extend(Number.prototype, (function() { + function toColorPart() { return this.toPaddedString(2, 16); - }, + } - succ: function() { + function succ() { return this + 1; - }, + } - times: function(iterator, context) { + function times(iterator, context) { $R(0, this, true).each(iterator, context); return this; - }, + } - toPaddedString: function(length, radix) { + function toPaddedString(length, radix) { var string = this.toString(radix || 10); return '0'.times(length - string.length) + string; - }, + } - toJSON: function() { + function toJSON() { return isFinite(this) ? this.toString() : 'null'; } -}); - -$w('abs round ceil floor').each(function(method){ - Number.prototype[method] = Math[method].methodize(); -}); \ No newline at end of file + + function abs() { + return Math.abs(this); + } + + function round() { + return Math.round(this); + } + + function ceil() { + return Math.ceil(this); + } + + function floor() { + return Math.floor(this); + } + + return { + toColorPart: toColorPart, + succ: succ, + times: times, + toPaddedString: toPaddedString, + toJSON: toJSON, + abs: abs, + round: round, + ceil: ceil, + floor: floor + }; +})());