@procedures/quantity 0.62.0 → 0.63.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/src/manifest.ts CHANGED
@@ -10,6 +10,105 @@ export const manifest: ExportsManifest = {
10
10
  "quantity"
11
11
  ],
12
12
  "$defs": {
13
+ "Atom": {
14
+ "type": "object",
15
+ "properties": {
16
+ "symbol": {
17
+ "type": "string"
18
+ },
19
+ "name": {
20
+ "type": "string"
21
+ },
22
+ "display": {
23
+ "type": "string",
24
+ "description": "This text is how it prints, where that is not its symbol: °F, µs."
25
+ },
26
+ "vector": {
27
+ "type": "object",
28
+ "properties": {
29
+ "time": {
30
+ "type": "number"
31
+ },
32
+ "length": {
33
+ "type": "number"
34
+ },
35
+ "mass": {
36
+ "type": "number"
37
+ },
38
+ "temperature": {
39
+ "type": "number"
40
+ },
41
+ "data": {
42
+ "type": "number"
43
+ },
44
+ "money": {
45
+ "type": "number"
46
+ },
47
+ "current": {
48
+ "type": "number"
49
+ }
50
+ }
51
+ },
52
+ "factor": {
53
+ "$ref": "#/$defs/Rational"
54
+ },
55
+ "offset": {
56
+ "$ref": "#/$defs/Rational",
57
+ "description": "An affine unit (a temperature) has an offset: base = (value + offset) × factor."
58
+ },
59
+ "log": {
60
+ "const": true,
61
+ "description": "A logarithmic level converts only to itself, and it averages by energy."
62
+ },
63
+ "counts": {
64
+ "type": "string",
65
+ "description": "This name is what it counts, when it is a count of something: a GT is 10⁹ transfers, a bpm counts beats."
66
+ },
67
+ "percent": {
68
+ "const": true,
69
+ "description": "A percentage makes a unit with no dimension a ratio."
70
+ },
71
+ "param": {
72
+ "const": "hz",
73
+ "description": "Its size changes with the system that it measures: a jiffy is 1/HZ seconds."
74
+ },
75
+ "decimals": {
76
+ "type": "number",
77
+ "description": "An amount keeps this many decimal places: money keeps the cent."
78
+ },
79
+ "aliases": {
80
+ "type": "array",
81
+ "items": {
82
+ "type": "string"
83
+ }
84
+ }
85
+ },
86
+ "required": [
87
+ "symbol",
88
+ "name",
89
+ "vector",
90
+ "factor"
91
+ ]
92
+ },
93
+ "Component": {
94
+ "type": "object",
95
+ "properties": {
96
+ "atom": {
97
+ "$ref": "#/$defs/Atom"
98
+ },
99
+ "annotation": {
100
+ "type": "string",
101
+ "description": "The annotation `{rep}` counts reps, and `%{1RM}` is a percentage of a one-rep max."
102
+ },
103
+ "exponent": {
104
+ "type": "number",
105
+ "description": "The exponent has a sign: what follows the slash divides."
106
+ }
107
+ },
108
+ "required": [
109
+ "exponent"
110
+ ]
111
+ },
13
112
  "Extent": {
14
113
  "anyOf": [
15
114
  {
@@ -57,6 +156,25 @@ export const manifest: ExportsManifest = {
57
156
  "unit"
58
157
  ]
59
158
  },
159
+ "Rational": {
160
+ "type": "object",
161
+ "properties": {
162
+ "n": {
163
+ "type": "string",
164
+ "pattern": "^-?(0|[1-9][0-9]*)$",
165
+ "x-procedures-codec": "bigint"
166
+ },
167
+ "d": {
168
+ "type": "string",
169
+ "pattern": "^-?(0|[1-9][0-9]*)$",
170
+ "x-procedures-codec": "bigint"
171
+ }
172
+ },
173
+ "required": [
174
+ "n",
175
+ "d"
176
+ ]
177
+ },
60
178
  "Scale": {
61
179
  "type": "object",
62
180
  "properties": {
@@ -132,6 +250,503 @@ export const manifest: ExportsManifest = {
132
250
  "unit"
133
251
  ]
134
252
  },
253
+ "Unit": {
254
+ "type": "object",
255
+ "properties": {
256
+ "symbol": {
257
+ "type": "string",
258
+ "description": "The symbol is its canonical spelling: the symbols of the atoms, `·` between factors, and one `/`."
259
+ },
260
+ "components": {
261
+ "type": "array",
262
+ "items": {
263
+ "$ref": "#/$defs/Component"
264
+ }
265
+ },
266
+ "vector": {
267
+ "type": "object",
268
+ "properties": {
269
+ "time": {
270
+ "type": "number"
271
+ },
272
+ "length": {
273
+ "type": "number"
274
+ },
275
+ "mass": {
276
+ "type": "number"
277
+ },
278
+ "temperature": {
279
+ "type": "number"
280
+ },
281
+ "data": {
282
+ "type": "number"
283
+ },
284
+ "money": {
285
+ "type": "number"
286
+ },
287
+ "current": {
288
+ "type": "number"
289
+ }
290
+ }
291
+ },
292
+ "factor": {
293
+ "$ref": "#/$defs/Rational"
294
+ },
295
+ "offset": {
296
+ "$ref": "#/$defs/Rational",
297
+ "description": "Only a lone affine unit (°F, °C) has an offset. A compound of it is a difference."
298
+ },
299
+ "kind": {
300
+ "enum": [
301
+ "time",
302
+ "length",
303
+ "mass",
304
+ "temperature",
305
+ "data",
306
+ "money",
307
+ "current",
308
+ "count",
309
+ "ratio",
310
+ "level",
311
+ "frequency",
312
+ "transfer-rate",
313
+ "data-rate",
314
+ "speed",
315
+ "area",
316
+ "volume",
317
+ "energy",
318
+ "power",
319
+ "voltage",
320
+ "charge",
321
+ "resistance",
322
+ "specific-power",
323
+ "specific-volume-rate",
324
+ "money-rate",
325
+ "energy-price",
326
+ "derived"
327
+ ]
328
+ },
329
+ "counts": {
330
+ "type": "object",
331
+ "properties": {},
332
+ "additionalProperties": {
333
+ "type": "number"
334
+ },
335
+ "description": "The counts are what it counts, with exponents: bpm counts beats, and `{set}/wk` counts sets per week."
336
+ },
337
+ "log": {
338
+ "type": "boolean"
339
+ },
340
+ "param": {
341
+ "const": "hz",
342
+ "description": "The parameter is what its size changes with: a jiffy needs the HZ of the kernel."
343
+ }
344
+ },
345
+ "required": [
346
+ "symbol",
347
+ "components",
348
+ "vector",
349
+ "factor",
350
+ "kind",
351
+ "counts",
352
+ "log"
353
+ ]
354
+ },
355
+ "UnitSystem": {
356
+ "type": "object",
357
+ "properties": {
358
+ "atoms": {
359
+ "type": "array",
360
+ "items": {
361
+ "$ref": "#/$defs/Atom"
362
+ }
363
+ },
364
+ "atomBySymbol": {
365
+ "type": "array",
366
+ "items": {
367
+ "type": "array",
368
+ "prefixItems": [
369
+ {
370
+ "type": "string"
371
+ },
372
+ {
373
+ "$ref": "#/$defs/Atom"
374
+ }
375
+ ],
376
+ "minItems": 2,
377
+ "maxItems": 2
378
+ },
379
+ "x-procedures-codec": "map"
380
+ },
381
+ "lookupAtom": {
382
+ "type": "object",
383
+ "description": "This function gives the atom that a spelling names: its symbol or one of its aliases.",
384
+ "required": [
385
+ "$proc"
386
+ ],
387
+ "properties": {
388
+ "$proc": {
389
+ "type": "array",
390
+ "items": {
391
+ "type": "string"
392
+ },
393
+ "minItems": 1
394
+ },
395
+ "input": {},
396
+ "$when": {
397
+ "const": "$never"
398
+ }
399
+ },
400
+ "x-procedures-program": {
401
+ "params": [
402
+ "spelling"
403
+ ],
404
+ "inputs": [
405
+ {
406
+ "type": "string"
407
+ }
408
+ ],
409
+ "output": {
410
+ "$ref": "#/$defs/Atom"
411
+ },
412
+ "undefinedForNull": true
413
+ }
414
+ },
415
+ "parseUnit": {
416
+ "type": "object",
417
+ "description": "This function resolves a unit from its spelling. The spelling has symbols or their aliases, factors joined by `·` or `*`, and one `/` at most. All that follows the slash divides: \"kcal/h·kg\" is per hour per kilogram. A factor can have a power (`m^2`) and say what it counts (`{rep}`).",
418
+ "required": [
419
+ "$proc"
420
+ ],
421
+ "properties": {
422
+ "$proc": {
423
+ "type": "array",
424
+ "items": {
425
+ "type": "string"
426
+ },
427
+ "minItems": 1
428
+ },
429
+ "input": {},
430
+ "$when": {
431
+ "const": "$never"
432
+ }
433
+ },
434
+ "x-procedures-program": {
435
+ "params": [
436
+ "spelling"
437
+ ],
438
+ "inputs": [
439
+ {
440
+ "type": "string"
441
+ }
442
+ ],
443
+ "output": {
444
+ "$ref": "#/$defs/Unit"
445
+ }
446
+ }
447
+ },
448
+ "tryParseUnit": {
449
+ "type": "object",
450
+ "description": "This function gives the unit of a spelling, or undefined when the spelling names no unit.",
451
+ "required": [
452
+ "$proc"
453
+ ],
454
+ "properties": {
455
+ "$proc": {
456
+ "type": "array",
457
+ "items": {
458
+ "type": "string"
459
+ },
460
+ "minItems": 1
461
+ },
462
+ "input": {},
463
+ "$when": {
464
+ "const": "$never"
465
+ }
466
+ },
467
+ "x-procedures-program": {
468
+ "params": [
469
+ "spelling"
470
+ ],
471
+ "inputs": [
472
+ {
473
+ "type": "string"
474
+ }
475
+ ],
476
+ "output": {
477
+ "$ref": "#/$defs/Unit"
478
+ },
479
+ "undefinedForNull": true
480
+ }
481
+ },
482
+ "isCanonicalUnit": {
483
+ "type": "object",
484
+ "description": "This function tells if stored data can have this spelling. Only the canonical spelling is correct.",
485
+ "required": [
486
+ "$proc"
487
+ ],
488
+ "properties": {
489
+ "$proc": {
490
+ "type": "array",
491
+ "items": {
492
+ "type": "string"
493
+ },
494
+ "minItems": 1
495
+ },
496
+ "input": {},
497
+ "$when": {
498
+ "const": "$never"
499
+ }
500
+ },
501
+ "x-procedures-program": {
502
+ "params": [
503
+ "spelling"
504
+ ],
505
+ "inputs": [
506
+ {
507
+ "type": "string"
508
+ }
509
+ ],
510
+ "output": {
511
+ "type": "boolean"
512
+ }
513
+ }
514
+ },
515
+ "canonicalUnit": {
516
+ "type": "object",
517
+ "description": "This function gives the canonical spelling of a unit, for data from another system: \"hr\" is \"h\".",
518
+ "required": [
519
+ "$proc"
520
+ ],
521
+ "properties": {
522
+ "$proc": {
523
+ "type": "array",
524
+ "items": {
525
+ "type": "string"
526
+ },
527
+ "minItems": 1
528
+ },
529
+ "input": {},
530
+ "$when": {
531
+ "const": "$never"
532
+ }
533
+ },
534
+ "x-procedures-program": {
535
+ "params": [
536
+ "spelling"
537
+ ],
538
+ "inputs": [
539
+ {
540
+ "type": "string"
541
+ }
542
+ ],
543
+ "output": {
544
+ "type": "string"
545
+ }
546
+ }
547
+ },
548
+ "kindOf": {
549
+ "type": "object",
550
+ "description": "One call of a pure procedure, as data, for the function (spelling: string) => Kind | \"derived\". It reads each parameter as {\"$ref\": \"<name>\"}: spelling.",
551
+ "required": [
552
+ "$proc"
553
+ ],
554
+ "properties": {
555
+ "$proc": {
556
+ "type": "array",
557
+ "items": {
558
+ "type": "string"
559
+ },
560
+ "minItems": 1
561
+ },
562
+ "input": {},
563
+ "$when": {
564
+ "const": "$never"
565
+ }
566
+ },
567
+ "x-procedures-program": {
568
+ "params": [
569
+ "spelling"
570
+ ],
571
+ "inputs": [
572
+ {
573
+ "type": "string"
574
+ }
575
+ ],
576
+ "output": {
577
+ "enum": [
578
+ "time",
579
+ "length",
580
+ "mass",
581
+ "temperature",
582
+ "data",
583
+ "money",
584
+ "current",
585
+ "count",
586
+ "ratio",
587
+ "level",
588
+ "frequency",
589
+ "transfer-rate",
590
+ "data-rate",
591
+ "speed",
592
+ "area",
593
+ "volume",
594
+ "energy",
595
+ "power",
596
+ "voltage",
597
+ "charge",
598
+ "resistance",
599
+ "specific-power",
600
+ "specific-volume-rate",
601
+ "money-rate",
602
+ "energy-price",
603
+ "derived"
604
+ ]
605
+ }
606
+ }
607
+ },
608
+ "whyNotConvertible": {
609
+ "type": "object",
610
+ "description": "This function gives the reason that `from` cannot become `to`, or undefined when it can.",
611
+ "required": [
612
+ "$proc"
613
+ ],
614
+ "properties": {
615
+ "$proc": {
616
+ "type": "array",
617
+ "items": {
618
+ "type": "string"
619
+ },
620
+ "minItems": 1
621
+ },
622
+ "input": {},
623
+ "$when": {
624
+ "const": "$never"
625
+ }
626
+ },
627
+ "x-procedures-program": {
628
+ "params": [
629
+ "from",
630
+ "to"
631
+ ],
632
+ "inputs": [
633
+ {
634
+ "type": "string"
635
+ },
636
+ {
637
+ "type": "string"
638
+ }
639
+ ],
640
+ "output": {
641
+ "type": "string"
642
+ },
643
+ "undefinedForNull": true
644
+ }
645
+ },
646
+ "convertible": {
647
+ "type": "object",
648
+ "description": "One call of a pure procedure, as data, for the function (from: string, to: string) => boolean. It reads each parameter as {\"$ref\": \"<name>\"}: from, to.",
649
+ "required": [
650
+ "$proc"
651
+ ],
652
+ "properties": {
653
+ "$proc": {
654
+ "type": "array",
655
+ "items": {
656
+ "type": "string"
657
+ },
658
+ "minItems": 1
659
+ },
660
+ "input": {},
661
+ "$when": {
662
+ "const": "$never"
663
+ }
664
+ },
665
+ "x-procedures-program": {
666
+ "params": [
667
+ "from",
668
+ "to"
669
+ ],
670
+ "inputs": [
671
+ {
672
+ "type": "string"
673
+ },
674
+ {
675
+ "type": "string"
676
+ }
677
+ ],
678
+ "output": {
679
+ "type": "boolean"
680
+ }
681
+ }
682
+ },
683
+ "convertExact": {
684
+ "type": "object",
685
+ "description": "This function converts a value in one unit, exactly, into another unit.",
686
+ "required": [
687
+ "$proc"
688
+ ],
689
+ "properties": {
690
+ "$proc": {
691
+ "type": "array",
692
+ "items": {
693
+ "type": "string"
694
+ },
695
+ "minItems": 1
696
+ },
697
+ "input": {},
698
+ "$when": {
699
+ "const": "$never"
700
+ }
701
+ },
702
+ "x-procedures-program": {
703
+ "params": [
704
+ "value",
705
+ "from",
706
+ "to",
707
+ "on"
708
+ ],
709
+ "inputs": [
710
+ {
711
+ "$ref": "#/$defs/Rational"
712
+ },
713
+ {
714
+ "type": "string"
715
+ },
716
+ {
717
+ "type": "string"
718
+ },
719
+ {
720
+ "anyOf": [
721
+ {
722
+ "$ref": "#/$defs/MeasuredOn"
723
+ },
724
+ {
725
+ "type": "null"
726
+ }
727
+ ]
728
+ }
729
+ ],
730
+ "output": {
731
+ "$ref": "#/$defs/Rational"
732
+ }
733
+ }
734
+ }
735
+ },
736
+ "required": [
737
+ "atoms",
738
+ "atomBySymbol",
739
+ "lookupAtom",
740
+ "parseUnit",
741
+ "tryParseUnit",
742
+ "isCanonicalUnit",
743
+ "canonicalUnit",
744
+ "kindOf",
745
+ "whyNotConvertible",
746
+ "convertible",
747
+ "convertExact"
748
+ ]
749
+ },
135
750
  "Unknown": {
136
751
  "type": "object",
137
752
  "properties": {
@@ -286,6 +901,50 @@ export const manifest: ExportsManifest = {
286
901
  "writes": []
287
902
  }
288
903
  },
904
+ {
905
+ "name": "convertExact",
906
+ "path": [
907
+ "quantity",
908
+ "convertExact"
909
+ ],
910
+ "description": "This function converts a value in one unit, exactly, into another unit.",
911
+ "params": [
912
+ "value",
913
+ "from",
914
+ "to",
915
+ "on"
916
+ ],
917
+ "input": {
918
+ "type": "object",
919
+ "properties": {
920
+ "value": {
921
+ "$ref": "#/$defs/Rational"
922
+ },
923
+ "from": {
924
+ "type": "string"
925
+ },
926
+ "to": {
927
+ "type": "string"
928
+ },
929
+ "on": {
930
+ "$ref": "#/$defs/MeasuredOn"
931
+ }
932
+ },
933
+ "required": [
934
+ "value",
935
+ "from",
936
+ "to"
937
+ ],
938
+ "additionalProperties": false
939
+ },
940
+ "output": {
941
+ "$ref": "#/$defs/Rational"
942
+ },
943
+ "effects": {
944
+ "reads": [],
945
+ "writes": []
946
+ }
947
+ },
289
948
  {
290
949
  "name": "convertible",
291
950
  "path": [
@@ -674,6 +1333,43 @@ export const manifest: ExportsManifest = {
674
1333
  "writes": []
675
1334
  }
676
1335
  },
1336
+ {
1337
+ "name": "lookupAtom",
1338
+ "path": [
1339
+ "quantity",
1340
+ "lookupAtom"
1341
+ ],
1342
+ "description": "This function gives the atom that a spelling names: its symbol or one of its aliases.",
1343
+ "params": [
1344
+ "spelling"
1345
+ ],
1346
+ "input": {
1347
+ "type": "object",
1348
+ "properties": {
1349
+ "spelling": {
1350
+ "type": "string"
1351
+ }
1352
+ },
1353
+ "required": [
1354
+ "spelling"
1355
+ ],
1356
+ "additionalProperties": false
1357
+ },
1358
+ "output": {
1359
+ "anyOf": [
1360
+ {
1361
+ "$ref": "#/$defs/Atom"
1362
+ },
1363
+ {
1364
+ "type": "null"
1365
+ }
1366
+ ]
1367
+ },
1368
+ "effects": {
1369
+ "reads": [],
1370
+ "writes": []
1371
+ }
1372
+ },
677
1373
  {
678
1374
  "name": "max",
679
1375
  "path": [
@@ -785,6 +1481,36 @@ export const manifest: ExportsManifest = {
785
1481
  "writes": []
786
1482
  }
787
1483
  },
1484
+ {
1485
+ "name": "parseUnit",
1486
+ "path": [
1487
+ "quantity",
1488
+ "parseUnit"
1489
+ ],
1490
+ "description": "This function resolves a unit from its spelling. The spelling has symbols or their aliases, factors joined by `·` or `*`, and one `/` at most. All that follows the slash divides: \"kcal/h·kg\" is per hour per kilogram. A factor can have a power (`m^2`) and say what it counts (`{rep}`).",
1491
+ "params": [
1492
+ "spelling"
1493
+ ],
1494
+ "input": {
1495
+ "type": "object",
1496
+ "properties": {
1497
+ "spelling": {
1498
+ "type": "string"
1499
+ }
1500
+ },
1501
+ "required": [
1502
+ "spelling"
1503
+ ],
1504
+ "additionalProperties": false
1505
+ },
1506
+ "output": {
1507
+ "$ref": "#/$defs/Unit"
1508
+ },
1509
+ "effects": {
1510
+ "reads": [],
1511
+ "writes": []
1512
+ }
1513
+ },
788
1514
  {
789
1515
  "name": "quantity",
790
1516
  "path": [
@@ -1074,6 +1800,43 @@ export const manifest: ExportsManifest = {
1074
1800
  "writes": []
1075
1801
  }
1076
1802
  },
1803
+ {
1804
+ "name": "tryParseUnit",
1805
+ "path": [
1806
+ "quantity",
1807
+ "tryParseUnit"
1808
+ ],
1809
+ "description": "This function gives the unit of a spelling, or undefined when the spelling names no unit.",
1810
+ "params": [
1811
+ "spelling"
1812
+ ],
1813
+ "input": {
1814
+ "type": "object",
1815
+ "properties": {
1816
+ "spelling": {
1817
+ "type": "string"
1818
+ }
1819
+ },
1820
+ "required": [
1821
+ "spelling"
1822
+ ],
1823
+ "additionalProperties": false
1824
+ },
1825
+ "output": {
1826
+ "anyOf": [
1827
+ {
1828
+ "$ref": "#/$defs/Unit"
1829
+ },
1830
+ {
1831
+ "type": "null"
1832
+ }
1833
+ ]
1834
+ },
1835
+ "effects": {
1836
+ "reads": [],
1837
+ "writes": []
1838
+ }
1839
+ },
1077
1840
  {
1078
1841
  "name": "unbounded",
1079
1842
  "path": [
@@ -1186,30 +1949,10 @@ export const manifest: ExportsManifest = {
1186
1949
  }
1187
1950
  ],
1188
1951
  "exempt": [
1189
- {
1190
- "name": "convertExact",
1191
- "reason": "input-not-json",
1192
- "detail": "value.n: bigint"
1193
- },
1194
- {
1195
- "name": "lookupAtom",
1196
- "reason": "output-not-json",
1197
- "detail": "factor.n: bigint"
1198
- },
1199
- {
1200
- "name": "parseUnit",
1201
- "reason": "output-not-json",
1202
- "detail": "components.atom.factor.n: bigint"
1203
- },
1204
- {
1205
- "name": "tryParseUnit",
1206
- "reason": "output-not-json",
1207
- "detail": "components.atom.factor.n: bigint"
1208
- },
1209
1952
  {
1210
1953
  "name": "unitSystem",
1211
- "reason": "input-not-json",
1212
- "detail": "atoms.factor.n: bigint"
1954
+ "reason": "output-not-json",
1955
+ "detail": "lookupAtom: a function"
1213
1956
  }
1214
1957
  ],
1215
1958
  "others": {