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

refactor: delete unreachable branches #466

Merged
merged 1 commit into from
Jun 18, 2022
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
39 changes: 17 additions & 22 deletions serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,44 +67,44 @@ module.exports = class Serializer {
return bool === null ? 'null' : this.asBoolean(bool)
}

asDatetime (date, skipQuotes) {
const quotes = skipQuotes === true ? '' : '"'
asDatetime (date) {
const quotes = '"'
if (date instanceof Date) {
return quotes + date.toISOString() + quotes
}
return this.asString(date, skipQuotes)
return this.asString(date)
}

asDatetimeNullable (date, skipQuotes) {
return date === null ? 'null' : this.asDatetime(date, skipQuotes)
asDatetimeNullable (date) {
return date === null ? 'null' : this.asDatetime(date)
}

asDate (date, skipQuotes) {
const quotes = skipQuotes === true ? '' : '"'
asDate (date) {
const quotes = '"'
if (date instanceof Date) {
return quotes + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(0, 10) + quotes
}
return this.asString(date, skipQuotes)
return this.asString(date)
}

asDateNullable (date, skipQuotes) {
return date === null ? 'null' : this.asDate(date, skipQuotes)
asDateNullable (date) {
return date === null ? 'null' : this.asDate(date)
}

asTime (date, skipQuotes) {
const quotes = skipQuotes === true ? '' : '"'
asTime (date) {
const quotes = '"'
if (date instanceof Date) {
return quotes + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(11, 19) + quotes
}
return this.asString(date, skipQuotes)
return this.asString(date)
}

asTimeNullable (date, skipQuotes) {
return date === null ? 'null' : this.asTime(date, skipQuotes)
asTimeNullable (date) {
return date === null ? 'null' : this.asTime(date)
}

asString (str, skipQuotes) {
const quotes = skipQuotes === true ? '' : '"'
asString (str) {
const quotes = '"'
if (str instanceof Date) {
return quotes + str.toISOString() + quotes
} else if (str === null) {
Expand All @@ -114,11 +114,6 @@ module.exports = class Serializer {
} else if (typeof str !== 'string') {
str = str.toString()
}
// If we skipQuotes it means that we are using it as test
// no need to test the string length for the render
if (skipQuotes) {
return str
}

if (str.length < 42) {
return this.asStringSmall(str)
Expand Down