From 8a8b4e9a178d507c72bbdc97f428dcc8f7a63756 Mon Sep 17 00:00:00 2001 From: Vincent Le Goff Date: Sat, 18 Jun 2022 22:01:37 +0200 Subject: [PATCH] feat: delete unreachable breanches (#466) --- serializer.js | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/serializer.js b/serializer.js index 81563bd5..5a7df6a9 100644 --- a/serializer.js +++ b/serializer.js @@ -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) { @@ -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)