From: Feross Aboukhadijeh Date: Wed, 5 Apr 2017 18:28:28 +0000 (-0700) Subject: remove string.trim() shim X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=c265a5491532e9f94d08849d6fa70df69c4cdaef;p=buffer.git remove string.trim() shim --- diff --git a/index.js b/index.js index 7010056..47d9450 100644 --- a/index.js +++ b/index.js @@ -1564,7 +1564,7 @@ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g function base64clean (str) { // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = stringtrim(str).replace(INVALID_BASE64_RE, '') + str = str.trim().replace(INVALID_BASE64_RE, '') // Node converts strings with length < 2 to '' if (str.length < 2) return '' // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not @@ -1574,11 +1574,6 @@ function base64clean (str) { return str } -function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') -} - function toHex (n) { if (n < 16) return '0' + n.toString(16) return n.toString(16)