You should take a look at the trim package and how often hat is downloaded.
``` exports = module.exports = trim;
function trim(str){ return str.replace(/^\s|\s$/g, ''); }
exports.left = function(str){ return str.replace(/^\s/, ''); };
exports.right = function(str){ return str.replace(/\s$/, ''); };
```
Here's a paste: https://pastebin.com/kBHprdyj