Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify switch statement #550

Merged
merged 1 commit into from
Nov 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Simplify switch statement
Both the 'undefined' and 'function' cases can be handled in the same way.
  • Loading branch information
nwoltman committed Nov 22, 2018
commit e27e29110bd0aebcc14d08609e9ba593830ced87
8 changes: 3 additions & 5 deletions lib/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ function asJson (obj, msg, num, time) {
value = serializers[key] ? serializers[key](value) : value

switch (typeof value) {
case 'undefined': continue
case 'undefined':
case 'function':
jsumners marked this conversation as resolved.
Show resolved Hide resolved
continue
case 'number':
/* eslint no-fallthrough: "off" */
if (Number.isFinite(value) === false) {
Expand All @@ -122,10 +124,6 @@ function asJson (obj, msg, num, time) {
case 'string':
value = (stringifiers[key] || asString)(value)
break
case 'function':
// ignore functions
value = undefined
break
default:
value = (stringifiers[key] || stringify)(value)
}
Expand Down