Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 28a63b2

Browse files
committed
remove default encoding
1 parent a1886b2 commit 28a63b2

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

lib/decode-key.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ var encodings = require('./encodings');
22
var walk = require('./walk');
33

44
module.exports = function decodeKey(key, optionObjects){
5-
var encoding = walk(optionObjects, 'keyEncoding') || 'utf8';
5+
var encoding = walk(optionObjects, 'keyEncoding');
66
if (typeof encoding == 'string') encoding = encodings[encoding];
7+
if (!encoding) return key;
78
return encoding.decode(key);
89
};

lib/decode-value.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ var encodings = require('./encodings');
22
var walk = require('./walk');
33

44
module.exports = function decodeValue(value, optionObjects){
5-
var encoding = walk(optionObjects, 'valueEncoding') || 'utf8';
5+
var encoding = walk(optionObjects, 'valueEncoding');
66
if (typeof encoding == 'string') encoding = encodings[encoding];
7+
if (!encoding) return value;
78
return encoding.decode(value);
89
};
910

lib/encode-key.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ var encodings = require('./encodings');
22
var walk = require('./walk');
33

44
module.exports = function encodeKey(key, optionObjects){
5-
var encoding = walk(optionObjects, 'keyEncoding') || 'utf8';
5+
var encoding = walk(optionObjects, 'keyEncoding');
66
if (typeof encoding == 'string') encoding = encodings[encoding];
7+
if (!encoding) return key;
78
return encoding.encode(key);
89
};

lib/encode-value.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ var encodings = require('./encodings');
22
var walk = require('./walk');
33

44
module.exports = function encodeValue(value, optionObjects){
5-
var encoding = walk(optionObjects, 'valueEncoding') || 'utf8';
5+
var encoding = walk(optionObjects, 'valueEncoding');
66
if (typeof encoding == 'string') encoding = encodings[encoding];
7+
if (!encoding) return value;
78
return encoding.encode(value);
89
};
910

lib/key-as-buffer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ var encodings = require('./encodings');
22
var walk = require('./walk');
33

44
module.exports = function keyAsBuffer(optionObjects){
5-
var encoding = walk(optionObjects, 'keyEncoding') || 'utf8';
5+
var encoding = walk(optionObjects, 'keyEncoding');
66
if (typeof encoding == 'string') encoding = encodings[encoding];
7+
if (!encoding) return false;
78
return encoding.buffer;
89
};

lib/value-as-buffer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ var encodings = require('./encodings');
22
var walk = require('./walk');
33

44
module.exports = function valueAsBuffer(optionObjects){
5-
var encoding = walk(optionObjects, 'valueEncoding') || 'utf8';
5+
var encoding = walk(optionObjects, 'valueEncoding');
66
if (typeof encoding == 'string') encoding = encodings[encoding];
7+
if (!encoding) return false;
78
return encoding.buffer;
89
};

0 commit comments

Comments
 (0)