Created
June 2, 2016 19:02
-
-
Save kawanet/e3a19451b24142a70d0e4eaef5a6eb00 to your computer and use it in GitHub Desktop.
Revisions
-
kawanet revised this gist
Jun 2, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,3 +23,5 @@ function pad(char) { return array.join(""); } } if ("undefined" !== typeof module) module.exports = pad; -
kawanet revised this gist
Jun 2, 2016 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,7 @@ * @param char {String} * @returns {Function} * @license MIT * @see https://gist.github.com/kawanet/e3a19451b24142a70d0e4eaef5a6eb00 */ function pad(char) { -
kawanet created this gist
Jun 2, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ /** * sprintf("%08d", x) == pad("0")(8)(x) * * @param char {String} * @returns {Function} * @license MIT */ function pad(char) { return function(len) { var prefix = padder(len); return function(str) { return (str == null) ? prefix : (prefix + str).substr(-len); }; }; function padder(len) { var array = []; for (var i = 0; i < len; i++) { array[i] = char; } return array.join(""); } }