Skip to content

Commit fd37bb4

Browse files
committed
Cleaning up duplicate functions
1 parent 7f3d746 commit fd37bb4

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

lib/mcapi/utils/utils.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const fs = require('fs');
88
*/
99

1010
module.exports.isSet = function (value) {
11-
return typeof value !== "undefined" && value !== null && value.length !== 0;
11+
return isSet(value);
1212
};
1313

1414
isSet = function (value) {
@@ -23,16 +23,7 @@ isSet = function (value) {
2323
* @returns {string} encoded string
2424
*/
2525
module.exports.bytesToString = function (bytes, dataEncoding) {
26-
if (typeof bytes === "undefined" || bytes === null) {
27-
throw new Error("Input not valid");
28-
}
29-
switch (dataEncoding.toLowerCase()) {
30-
case 'hex':
31-
return forge.util.bytesToHex(bytes);
32-
case 'base64':
33-
default:
34-
return forge.util.encode64(bytes);
35-
}
26+
return bytesToString(bytes, dataEncoding);
3627
};
3728

3829
function bytesToString(bytes, dataEncoding) {
@@ -46,7 +37,7 @@ function bytesToString(bytes, dataEncoding) {
4637
default:
4738
return forge.util.encode64(bytes);
4839
}
49-
};
40+
}
5041

5142
/**
5243
* Converts a (hex or base64) string into a 'binary' encoded string of bytes.

0 commit comments

Comments
 (0)