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 e363378 commit 332cdf1Copy full SHA for 332cdf1
lib/parsers/string.js
@@ -1,15 +1,18 @@
1
var Iconv = require('iconv-lite');
2
3
-var NODE_ENCODING = {
4
- 'ascii': true,
5
- 'utf8': true,
6
- 'utf16le': true,
7
- 'ucs2': true,
8
- 'base64': true,
9
- 'latin1': true,
10
- 'binary': true,
11
- 'hex': true
12
-};
+var NODE_ENCODING = [
+ 'ascii',
+ 'utf8',
+ 'utf16le',
+ 'ucs2',
+ 'base64',
+ 'latin1',
+ 'binary',
+ 'hex'
+].reduce(function (map, item) {
13
+ map[item] = Buffer.isEncoding(item);
14
+ return map;
15
+}, {});
16
17
exports.decode = function(buffer, encoding, options) {
18
if (NODE_ENCODING[encoding]) {
0 commit comments