@sjcrh/proteinpaint-shared 2.147.1 → 2.149.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/joinUrl.js +7 -7
- package/src/termdb.bins.js +2 -0
- package/src/termdb.initbinconfig.js +1 -1
- package/src/time.js +5 -5
- package/src/urljson.js +21 -12
package/package.json
CHANGED
package/src/joinUrl.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
function joinUrl(p1, ...p2) {
|
|
2
|
-
if (typeof p1 !=
|
|
3
|
-
if (!p1) throw
|
|
4
|
-
if (p1.indexOf(
|
|
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"
|
|
5
5
|
let url = p1
|
|
6
6
|
for (const p of p2) {
|
|
7
|
-
if (typeof p !=
|
|
8
|
-
if (!p) throw
|
|
9
|
-
if (url.slice(-1) !=
|
|
10
|
-
url += p.startsWith(
|
|
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
|
|
11
11
|
}
|
|
12
12
|
return url
|
|
13
13
|
}
|
package/src/termdb.bins.js
CHANGED
|
@@ -267,6 +267,8 @@ export function get_bin_label(bin, binconfig, valueConversion) {
|
|
|
267
267
|
/*
|
|
268
268
|
Generate a numeric bin label given a bin configuration and an optional term valueConversion object
|
|
269
269
|
*/
|
|
270
|
+
if ('label' in bin) return bin.label
|
|
271
|
+
|
|
270
272
|
const bc = binconfig
|
|
271
273
|
if (!bc.binLabelFormatter) bc.binLabelFormatter = getNumDecimalsFormatter(bc)
|
|
272
274
|
if (!bin.startunbounded && !bin.stopunbounded && !('startinclusive' in bin) && !('stopinclusive' in bin)) {
|
|
@@ -6,7 +6,7 @@ Initialize a bin configuration for a numeric dataset
|
|
|
6
6
|
{format: 'string'}: output bin config as JSON string
|
|
7
7
|
*/
|
|
8
8
|
export default function initBinConfig(data, opts = {}) {
|
|
9
|
-
if (data.find(d => !Number.isFinite(d))) throw 'non-numeric values found'
|
|
9
|
+
if (data.find(d => !Number.isFinite(d))) throw new Error('non-numeric values found')
|
|
10
10
|
|
|
11
11
|
let binConfig
|
|
12
12
|
const s = new Set(data)
|
package/src/time.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
function formatElapsedTime(ms) {
|
|
2
|
-
if (typeof ms !==
|
|
3
|
-
return
|
|
2
|
+
if (typeof ms !== "number") {
|
|
3
|
+
return "Invalid time: not a number"
|
|
4
4
|
}
|
|
5
5
|
if (isNaN(ms)) {
|
|
6
|
-
return
|
|
6
|
+
return "Invalid time: NaN"
|
|
7
7
|
}
|
|
8
8
|
if (!isFinite(ms)) {
|
|
9
|
-
return ms > 0 ?
|
|
9
|
+
return ms > 0 ? "Infinite time" : "-Infinite time"
|
|
10
10
|
}
|
|
11
11
|
const absMs = Math.abs(ms)
|
|
12
|
-
const sign = ms < 0 ?
|
|
12
|
+
const sign = ms < 0 ? "-" : ""
|
|
13
13
|
if (absMs < 1e3) {
|
|
14
14
|
return `${sign}${absMs}ms`
|
|
15
15
|
} else if (absMs < 6e4) {
|
package/src/urljson.js
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
|
-
import { isNumeric } from
|
|
2
|
-
const reserved = [
|
|
3
|
-
const delimiters = ['"',
|
|
1
|
+
import { isNumeric } from "./helpers.js"
|
|
2
|
+
const reserved = ["false", "true", "null", "undefined"]
|
|
3
|
+
const delimiters = ['"', "{", "["]
|
|
4
4
|
function encode(rawObject) {
|
|
5
5
|
const params = []
|
|
6
6
|
for (const [key, value] of Object.entries(rawObject)) {
|
|
7
|
-
if (
|
|
7
|
+
if (
|
|
8
|
+
typeof value == "string" &&
|
|
9
|
+
!isNumeric(value) &&
|
|
10
|
+
!reserved.includes(value) &&
|
|
11
|
+
!delimiters.includes(value[0])
|
|
12
|
+
) {
|
|
8
13
|
params.push(`${key}=${encodeURIComponent(value)}`)
|
|
9
14
|
} else if (value !== void 0) {
|
|
10
15
|
params.push(`${key}=${encodeURIComponent(JSON.stringify(value))}`)
|
|
11
16
|
}
|
|
12
17
|
}
|
|
13
|
-
return params.join(
|
|
18
|
+
return params.join("&")
|
|
14
19
|
}
|
|
15
20
|
function decode(query) {
|
|
16
21
|
const encoding = query.encoding
|
|
17
22
|
for (const [key, value] of Object.entries(query)) {
|
|
18
23
|
if (
|
|
19
|
-
encoding ==
|
|
20
|
-
value ==
|
|
21
|
-
value ==
|
|
22
|
-
value ==
|
|
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'
|
|
23
28
|
isNumeric(value) || // NEED TO check
|
|
24
|
-
(typeof value ==
|
|
25
|
-
|
|
26
|
-
|
|
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("]"))
|
|
27
36
|
)
|
|
28
37
|
query[key] = JSON.parse(value)
|
|
29
38
|
}
|