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