@sjcrh/proteinpaint-shared 2.162.0 → 2.163.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/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-shared",
3
- "version": "2.162.0",
3
+ "version": "2.163.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",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
9
+ "./*.ts": "./src/*.ts_SHOULD_BE_js",
9
10
  "./*": "./src/*"
10
11
  },
11
12
  "scripts": {
package/src/index.js CHANGED
@@ -15,6 +15,7 @@ export * from './termdb.bins.js'
15
15
  export * from './termdb.initbinconfig.js'
16
16
  export * from './termdb.usecase.js'
17
17
  export * from './terms.js'
18
+ export * from './time.js'
18
19
  export * from './tree.js'
19
20
  // do `npm run esm` to generate .js file from .ts file
20
21
  export * from './urljson.js'
@@ -154,6 +154,11 @@ export function isUsableTerm(term, _usecase, termdbConfig, ds) {
154
154
  }
155
155
  return uses
156
156
 
157
+ case 'numericTermCollections':
158
+ if (usecase.detail?.termIds?.includes(term.id)) uses.add('plot')
159
+ if (usecase.detail?.branchIds?.includes(term.id)) uses.add('branch')
160
+ return uses
161
+
157
162
  case 'profileForms':
158
163
  if (!term.isleaf) {
159
164
  const ancestors = term.id.split('__').length //depends on using the __ naming convension!
package/src/time.js CHANGED
@@ -1,9 +1,8 @@
1
- function formatElapsedTime(ms) {
2
- if (typeof ms !== "number") {
3
- return "Invalid time: not a number"
4
- }
5
- if (isNaN(ms)) {
6
- return "Invalid time: NaN"
1
+ 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"
7
6
  }
8
7
  if (!isFinite(ms)) {
9
8
  return ms > 0 ? "Infinite time" : "-Infinite time"
@@ -12,13 +11,12 @@ function formatElapsedTime(ms) {
12
11
  const sign = ms < 0 ? "-" : ""
13
12
  if (absMs < 1e3) {
14
13
  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
14
  }
15
+ if (absMs < 6e4) {
16
+ return `${sign}${(absMs / 1e3).toFixed(precision)}s`
17
+ }
18
+ const minutes = Math.floor(absMs / 6e4)
19
+ const seconds = ((absMs % 6e4) / 1e3).toFixed(precision)
20
+ return `${sign}${minutes}m ${seconds}s`
23
21
  }
24
22
  export { formatElapsedTime }