Skip to content

Commit db42ad8

Browse files
authored
lib: remove result variable from asData (#167)
This commit removes the 'result' variable form the utility function asData. The motivation is to improve readability. Signed-off-by: Daniel Bevenius <[email protected]>
1 parent cf36a15 commit db42ad8

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

lib/utils/fun.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,16 @@ const isJsonContentType = (contentType) =>
5353
contentType && contentType.match(/(json)/i);
5454

5555
const asData = (data, contentType) => {
56-
let result = data;
57-
5856
// pattern matching alike
59-
result = isString(result) &&
60-
!isBase64(result) &&
57+
const maybeJson = isString(data) &&
58+
!isBase64(data) &&
6159
isJsonContentType(contentType)
62-
? JSON.parse(result)
63-
: result;
64-
65-
result = isBinary(result)
66-
? asBase64(result)
67-
: result;
60+
? JSON.parse(data)
61+
: data;
6862

69-
return result;
63+
return isBinary(maybeJson)
64+
? asBase64(maybeJson)
65+
: maybeJson;
7066
};
7167

7268
module.exports = {

0 commit comments

Comments
 (0)