@sjcrh/proteinpaint-shared 2.115.0 → 2.116.1-1
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/README.md +7 -4
- package/package.json +3 -2
- package/src/termdb.usecase.js +16 -0
- package/src/time.js +22 -24
package/README.md
CHANGED
|
@@ -28,12 +28,15 @@ This package will be bundled as part of the client dependencies.
|
|
|
28
28
|
For server builds, run `npm run build` to generate `src/*.js` from `src/*.ts` files.
|
|
29
29
|
This is also automatically done as part of the `prepack` package script.
|
|
30
30
|
|
|
31
|
-
NOTE: For now, only code in `.js` files.
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
NOTE: For now, only code in `.js` files.
|
|
32
|
+
|
|
33
|
+
### If using `.ts` files:
|
|
34
|
+
1. commit the generated `.js` files
|
|
35
|
+
2. add the js file to package.json prettier command
|
|
36
|
+
keep doing this until a dev script or another approach can take care of the `.js` file requirement.
|
|
34
37
|
|
|
35
38
|
## Test
|
|
36
39
|
|
|
37
40
|
```sh
|
|
38
41
|
npm test
|
|
39
|
-
```
|
|
42
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sjcrh/proteinpaint-shared",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.116.1-1",
|
|
4
4
|
"description": "ProteinPaint code that is shared between server and client-side workspaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
"./*": "./src/*"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "esbuild src/*.ts --platform=node --outdir=src/ --format=esm && prettier --no-semi --use-tabs --write src/urljson.js src/joinUrl.js src/doc.js",
|
|
12
|
+
"build": "esbuild src/*.ts --platform=node --outdir=src/ --format=esm && prettier --no-semi --use-tabs --write src/urljson.js src/joinUrl.js src/time.js src/doc.js",
|
|
13
13
|
"prepack": "npm run build",
|
|
14
14
|
"pretest": "mkdir -p test && node emitImports > test/internals-test.ts",
|
|
15
|
+
"spec:coverage": "node test/relevant.js",
|
|
15
16
|
"test": "tsx test/internals-test.ts",
|
|
16
17
|
"test-x": "ls src/test/*.spec* | xargs -I % bash -c '{ tsx %; sleep 0.001; }'"
|
|
17
18
|
},
|
package/src/termdb.usecase.js
CHANGED
|
@@ -103,6 +103,22 @@ export function isUsableTerm(term, _usecase, termdbConfig, ds) {
|
|
|
103
103
|
if (!term.isleaf) uses.add('branch')
|
|
104
104
|
}
|
|
105
105
|
return uses
|
|
106
|
+
case 'runChart':
|
|
107
|
+
if (usecase.detail == 'date') {
|
|
108
|
+
if (term.type == 'date') {
|
|
109
|
+
uses.add('plot')
|
|
110
|
+
}
|
|
111
|
+
if (child_types.includes('date')) uses.add('branch')
|
|
112
|
+
} else if (usecase.detail == 'numeric') {
|
|
113
|
+
if (isNumericTerm(term) && term.type != 'date') {
|
|
114
|
+
uses.add('plot')
|
|
115
|
+
}
|
|
116
|
+
if (hasNumericChild(child_types)) uses.add('branch')
|
|
117
|
+
} else {
|
|
118
|
+
if (graphableTypes.has(term.type)) uses.add('plot')
|
|
119
|
+
if (!term.isleaf) uses.add('branch')
|
|
120
|
+
}
|
|
121
|
+
return uses
|
|
106
122
|
case 'numericDictTermCluster':
|
|
107
123
|
if (!usecase.detail?.exclude?.includes(term.id)) {
|
|
108
124
|
if (isNumericTerm(term)) {
|
package/src/time.js
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
function formatElapsedTime(ms) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
if (typeof ms !== 'number') {
|
|
3
|
+
return 'Invalid time: not a number'
|
|
4
|
+
}
|
|
5
|
+
if (isNaN(ms)) {
|
|
6
|
+
return 'Invalid time: NaN'
|
|
7
|
+
}
|
|
8
|
+
if (!isFinite(ms)) {
|
|
9
|
+
return ms > 0 ? 'Infinite time' : '-Infinite time'
|
|
10
|
+
}
|
|
11
|
+
const absMs = Math.abs(ms)
|
|
12
|
+
const sign = ms < 0 ? '-' : ''
|
|
13
|
+
if (absMs < 1e3) {
|
|
14
|
+
return `${sign}${absMs}ms`
|
|
15
|
+
} else if (absMs < 6e4) {
|
|
16
|
+
const seconds = (absMs / 1e3).toFixed(2)
|
|
17
|
+
return `${sign}${seconds}s`
|
|
18
|
+
} else {
|
|
19
|
+
const minutes = Math.floor(absMs / 6e4)
|
|
20
|
+
const seconds = ((absMs % 6e4) / 1e3).toFixed(2)
|
|
21
|
+
return `${sign}${minutes}m ${seconds}s`
|
|
22
|
+
}
|
|
23
23
|
}
|
|
24
|
-
export {
|
|
25
|
-
formatElapsedTime
|
|
26
|
-
};
|
|
24
|
+
export { formatElapsedTime }
|