We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9de15dc commit 209f45bCopy full SHA for 209f45b
index.js
@@ -21,8 +21,17 @@
21
22
var Buffer = require('buffer').Buffer;
23
24
+var isBufferEncoding = Buffer.isEncoding
25
+ || function(encoding) {
26
+ switch (encoding && encoding.toLowerCase()) {
27
+ 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;
28
+ default: return false;
29
+ }
30
31
+
32
33
function assertEncoding(encoding) {
- if (encoding && !Buffer.isEncoding(encoding)) {
34
+ if (encoding && !isBufferEncoding(encoding)) {
35
throw new Error('Unknown encoding: ' + encoding);
36
}
37
0 commit comments