[Pkg-javascript-commits] [node-string-decoder] 02/03: fix 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 f53f49cb2b90bd316ca511eb84941bd46ee1cf21
Author: Rod Vagg <rod at vagg.org>
Date:   Tue Jan 28 13:21:11 2014 +1100

    fix missing Buffer.isEncoding on Node 0.8
---
 index.js | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/index.js b/index.js
index 80edb05..2e44a03 100644
--- a/index.js
+++ b/index.js
@@ -21,8 +21,17 @@
 
 var Buffer = require('buffer').Buffer;
 
+var isBufferEncoding = Buffer.isEncoding
+  || function(encoding) {
+       switch (encoding && encoding.toLowerCase()) {
+         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;
+         default: return false;
+       }
+     }
+
+
 function assertEncoding(encoding) {
-  if (encoding && !Buffer.isEncoding(encoding)) {
+  if (encoding && !isBufferEncoding(encoding)) {
     throw new Error('Unknown encoding: ' + encoding);
   }
 }

-- 
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