[Pkg-javascript-commits] [node-string-decoder] 01/03: missing Buffer.isEncoding() on Node 0.8

Bastien Roucariès rouca at moszumanska.debian.org
Mon May 15 15:05:17 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to annotated tag v0.10.25
in repository node-string-decoder.

commit 0155b4e3fb2b2582a8106d014ff3e0f757710532
Author: Rod Vagg <rod at vagg.org>
Date:   Tue Jan 28 13:21:00 2014 +1100

    missing Buffer.isEncoding() on Node 0.8
---
 build/files.js | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/build/files.js b/build/files.js
index 24d4d60..7396a4f 100644
--- a/build/files.js
+++ b/build/files.js
@@ -9,9 +9,26 @@
 module.exports['string_decoder.js'] = [
 
     // pull in Bufer as a require
+    // add Buffer.isEncoding where missing
     [
         /^(\/\/ USE OR OTHER DEALINGS IN THE SOFTWARE\.)/m
-      , '$1\n\nvar Buffer = require(\'buffer\').Buffer;'
+      ,   '$1\n\nvar Buffer = require(\'buffer\').Buffer;'
+        + '\n'
+        + '\nvar isBufferEncoding = Buffer.isEncoding'
+        + '\n  || function(encoding) {'
+        + '\n       switch (encoding && encoding.toLowerCase()) {'
+        + '\n         case \'hex\': case \'utf8\': case \'utf-8\': case \'ascii\': case \'binary\': case \'base64\': case \'ucs2\': case \'ucs-2\': case \'utf16le\': case \'utf-16le\': case \'raw\': return true;'
+        + '\n         default: return false;'
+        + '\n       }'
+        + '\n     }'
+        + '\n'
+
+    ]
+
+    // use custom Buffer.isEncoding reference
+  , [
+        /Buffer\.isEncoding\(/g
+      , 'isBufferEncoding\('
     ]
 
 ]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-string-decoder.git



More information about the Pkg-javascript-commits mailing list