Skip to content

Instantly share code, notes, and snippets.

@st98
Created March 3, 2014 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save st98/9319175 to your computer and use it in GitHub Desktop.
Save st98/9319175 to your computer and use it in GitHub Desktop.
54 => " \t\t \t\t \n", -54 => "\t\t\t \t\t \n"
var toWhitespace = function (n) {
var result = '';
var table = {
0: ' ',
1: '\t'
};
result += (n < 0) ? table[1] : table[0];
result += Math.abs(n).toString(2).replace(/[01]/g, function (m) {
return table[m];
});
result += '\n';
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment