Skip to content

Commit d296f3c

Browse files
creilly8xzhou82
authored andcommitted
Letting prettier win
1 parent 2f35ee2 commit d296f3c

File tree

3 files changed

+23
-34
lines changed

3 files changed

+23
-34
lines changed

shared/utils/src/joinUrl.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
function joinUrl(p1, ...p2) {
2-
if (typeof p1 != "string") throw `first argument must be string type`
3-
if (!p1) throw "blank string not allowed"
4-
if (p1.indexOf("?") != -1) throw "search string not allowed"
2+
if (typeof p1 != 'string') throw `first argument must be string type`
3+
if (!p1) throw 'blank string not allowed'
4+
if (p1.indexOf('?') != -1) throw 'search string not allowed'
55
let url = p1
66
for (const p of p2) {
7-
if (typeof p != "string") throw `all arguments must be string type`
8-
if (!p) throw "blank string not allowed"
9-
if (url.slice(-1) != "/") url += "/"
10-
url += p.startsWith("/") ? p.substring(1) : p
7+
if (typeof p != 'string') throw `all arguments must be string type`
8+
if (!p) throw 'blank string not allowed'
9+
if (url.slice(-1) != '/') url += '/'
10+
url += p.startsWith('/') ? p.substring(1) : p
1111
}
1212
return url
1313
}

shared/utils/src/time.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
function formatElapsedTime(ms, precision = 2) {
2-
if (typeof ms !== "number" || isNaN(ms)) {
3-
return typeof ms !== "number"
4-
? "Invalid time: not a number"
5-
: "Invalid time: NaN"
2+
if (typeof ms !== 'number' || isNaN(ms)) {
3+
return typeof ms !== 'number' ? 'Invalid time: not a number' : 'Invalid time: NaN'
64
}
75
if (!isFinite(ms)) {
8-
return ms > 0 ? "Infinite time" : "-Infinite time"
6+
return ms > 0 ? 'Infinite time' : '-Infinite time'
97
}
108
const absMs = Math.abs(ms)
11-
const sign = ms < 0 ? "-" : ""
9+
const sign = ms < 0 ? '-' : ''
1210
if (absMs < 1e3) {
1311
return `${sign}${absMs}ms`
1412
}

shared/utils/src/urljson.js

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,29 @@
1-
import { isNumeric } from "./helpers.js"
2-
const reserved = ["false", "true", "null", "undefined"]
3-
const delimiters = ['"', "{", "["]
1+
import { isNumeric } from './helpers.js'
2+
const reserved = ['false', 'true', 'null', 'undefined']
3+
const delimiters = ['"', '{', '[']
44
function encode(rawObject) {
55
const params = []
66
for (const [key, value] of Object.entries(rawObject)) {
7-
if (
8-
typeof value == "string" &&
9-
!isNumeric(value) &&
10-
!reserved.includes(value) &&
11-
!delimiters.includes(value[0])
12-
) {
7+
if (typeof value == 'string' && !isNumeric(value) && !reserved.includes(value) && !delimiters.includes(value[0])) {
138
params.push(`${key}=${encodeURIComponent(value)}`)
149
} else if (value !== void 0) {
1510
params.push(`${key}=${encodeURIComponent(JSON.stringify(value))}`)
1611
}
1712
}
18-
return params.join("&")
13+
return params.join('&')
1914
}
2015
function decode(query) {
2116
const encoding = query.encoding
2217
for (const [key, value] of Object.entries(query)) {
2318
if (
24-
encoding == "json" ||
25-
value == "null" || // not new, always been
26-
value == "true" || // NEED TO FIND-REPLACE CODE THAT USES value == 'true'
27-
value == "false" || // NEED TO FIND-REPLACE CODE THAT USES value == 'false'
19+
encoding == 'json' ||
20+
value == 'null' || // not new, always been
21+
value == 'true' || // NEED TO FIND-REPLACE CODE THAT USES value == 'true'
22+
value == 'false' || // NEED TO FIND-REPLACE CODE THAT USES value == 'false'
2823
isNumeric(value) || // NEED TO check
29-
(typeof value == "string" &&
30-
value.startsWith('"') &&
31-
value.endsWith('"')) ||
32-
(typeof value == "string" &&
33-
value.startsWith("{") &&
34-
value.endsWith("}")) ||
35-
(value.startsWith("[") && value.endsWith("]"))
24+
(typeof value == 'string' && value.startsWith('"') && value.endsWith('"')) ||
25+
(typeof value == 'string' && value.startsWith('{') && value.endsWith('}')) ||
26+
(value.startsWith('[') && value.endsWith(']'))
3627
)
3728
query[key] = JSON.parse(value)
3829
}

0 commit comments

Comments
 (0)