Blog

String.prototype.expandTabs()

I personally love both JavaScript and Python. For this reason, from time to time I like to port functions that are available in Python, over to JavaScript. The following is a port of the expandTabs function. String.prototype.expandTabs = function(tabSize) { tabSize = Math.min(Math.max(parseInt(+tabSize || 8), 1), 32); return this.replace(/^.*\t.*$/gm, function(line) Read more…

By Chris West, ago