ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject [08/17] incubator-ponymail git commit: add number padding function
Date Fri, 02 Sep 2016 07:44:10 GMT
add number padding function


Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/7b308dea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/7b308dea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/7b308dea

Branch: refs/heads/coffee-and-cake
Commit: 7b308dea22b9068d2e551680fe4c87621aa31260
Parents: 9169483
Author: Daniel Gruno <humbedooh@apache.org>
Authored: Thu Sep 1 17:16:38 2016 +0200
Committer: Daniel Gruno <humbedooh@apache.org>
Committed: Thu Sep 1 17:16:38 2016 +0200

----------------------------------------------------------------------
 site/js/coffee/misc.coffee | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/7b308dea/site/js/coffee/misc.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/misc.coffee b/site/js/coffee/misc.coffee
index e4a9e69..6d187dd 100644
--- a/site/js/coffee/misc.coffee
+++ b/site/js/coffee/misc.coffee
@@ -27,6 +27,14 @@ Number.prototype.pretty = (fix) ->
         return String(this.toFixed(fix)).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
     return String(this.toFixed(0)).replace(/(\d)(?=(\d{3})+$)/g, '$1,');
 
+# Number padding
+# usage: 123.pad(6) -> 000123
+Number.prototype.pad = (n) ->
+    str = String(this)
+    if str.length < n
+        str = "0".repeat(n-str.length) + str
+    return str
+
 
 # isArray: function to detect if an object is an array
 isArray = ( value ) ->


Mime
View raw message