Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add time sugar to Number

  • Loading branch information...
commit ae99fb2bacebf876f5635c11639d820b4336803f 1 parent c575b3e
@erisdev authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 scripts/utilities.coffee
View
8 scripts/utilities.coffee
@@ -19,6 +19,12 @@ Number::toPaddedString = (length, base = 10) ->
string = "0#{string}" while string.length < length
string
+Number::nanoseconds = -> this / 1000000
+Number::milliseconds = -> this
+Number::seconds = -> this * 1000
+Number::minutes = -> this * 60000
+Number::hours = -> this * 3600000
+
RegExp.escape = (string) ->
string.replace /[\/\.\*\+\?\|\(\)\[\]\{\}\\]/g, '\\$&'
@@ -62,5 +68,5 @@ hideProperties = (obj, properties...) ->
Object.defineProperty obj, prop, enumerable: false
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'
Please sign in to comment.
Something went wrong with that request. Please try again.