Skip to content

Commit

Permalink
feat: delete unreachable breanches (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
zekth authored Jun 18, 2022
1 parent 9e7e538 commit 8a8b4e9
Showing 1 changed file with 17 additions and 22 deletions.
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

0 comments on commit 8a8b4e9

Please sign in to comment.