Skip to content

Commit

Permalink
add time sugar to Number
Browse files Browse the repository at this point in the history
  • Loading branch information
erisdev committed Mar 23, 2012
1 parent c575b3e commit ae99fb2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/utilities.coffee
Expand Up @@ -19,6 +19,12 @@ Number::toPaddedString = (length, base = 10) ->
string = "0#{string}" while string.length < length string = "0#{string}" while string.length < length
string string


Number::nanoseconds = -> this / 1000000
Number::milliseconds = -> this
Number::seconds = -> this * 1000
Number::minutes = -> this * 60000
Number::hours = -> this * 3600000

RegExp.escape = (string) -> RegExp.escape = (string) ->
string.replace /[\/\.\*\+\?\|\(\)\[\]\{\}\\]/g, '\\$&' string.replace /[\/\.\*\+\?\|\(\)\[\]\{\}\\]/g, '\\$&'


Expand Down Expand Up @@ -62,5 +68,5 @@ hideProperties = (obj, properties...) ->
Object.defineProperty obj, prop, enumerable: false Object.defineProperty obj, prop, enumerable: false


hideProperties Object.prototype, 'tap', 'isEmpty', 'getKeys', 'getOwnKeys' hideProperties Object.prototype, 'tap', 'isEmpty', 'getKeys', 'getOwnKeys'
hideProperties Number.prototype, 'toPaddedString' hideProperties Number.prototype, 'toPaddedString', 'nanoseconds', 'milliseconds', 'seconds', 'minutes', 'hours'
hideProperties String.prototype, 'template', 'escapeEntities', 'unescapeEntities' hideProperties String.prototype, 'template', 'escapeEntities', 'unescapeEntities'

0 comments on commit ae99fb2

Please sign in to comment.