@agoric/time 0.3.3-dev-7153535.0 → 0.3.3-dev-813e29e.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/index.js +2 -0
- package/package.json +3 -3
- package/src/timeMath.js +18 -28
- package/src/types.js +2 -0
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/time",
|
|
3
|
-
"version": "0.3.3-dev-
|
|
3
|
+
"version": "0.3.3-dev-813e29e.0+813e29e",
|
|
4
4
|
"description": "Timestamps, time math, timer service API definition",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@agoric/assert": "0.6.1-dev-
|
|
33
|
+
"@agoric/assert": "0.6.1-dev-813e29e.0+813e29e",
|
|
34
34
|
"@endo/nat": "^4.1.30",
|
|
35
35
|
"@endo/patterns": "^0.2.5"
|
|
36
36
|
},
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"typeCoverage": {
|
|
56
56
|
"atLeast": 86.95
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "813e29e088f8fda82916bc9fc2b36502805158ec"
|
|
59
59
|
}
|
package/src/timeMath.js
CHANGED
|
@@ -3,23 +3,13 @@ import { mustMatch } from '@endo/patterns';
|
|
|
3
3
|
import { RelativeTimeRecordShape, TimestampRecordShape } from './typeGuards.js';
|
|
4
4
|
|
|
5
5
|
const { Fail, quote: q } = assert;
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {import('@endo/marshal').RankComparison} RankComparison
|
|
8
|
-
*
|
|
9
|
-
* @typedef {import('./types').TimerBrand} TimerBrand
|
|
10
|
-
* @typedef {import('./types').Timestamp} Timestamp
|
|
11
|
-
* @typedef {import('./types').RelativeTime} RelativeTime
|
|
12
|
-
* @typedef {import('./types').RelativeTimeValue} RelativeTimeValue
|
|
13
|
-
* @typedef {import('./types').TimestampValue} TimestampValue
|
|
14
|
-
* @typedef {import('./types').TimeMathType} TimeMathType
|
|
15
|
-
*/
|
|
16
6
|
|
|
17
7
|
/**
|
|
18
8
|
* `agreedTimerBrand` is internal to this module.
|
|
19
9
|
*
|
|
20
|
-
* @param {TimerBrand | undefined} leftBrand
|
|
21
|
-
* @param {TimerBrand | undefined} rightBrand
|
|
22
|
-
* @returns {TimerBrand | undefined}
|
|
10
|
+
* @param {import('./types').TimerBrand | undefined} leftBrand
|
|
11
|
+
* @param {import('./types').TimerBrand | undefined} rightBrand
|
|
12
|
+
* @returns {import('./types').TimerBrand | undefined}
|
|
23
13
|
*/
|
|
24
14
|
const agreedTimerBrand = (leftBrand, rightBrand) => {
|
|
25
15
|
if (leftBrand === undefined) {
|
|
@@ -44,9 +34,9 @@ const agreedTimerBrand = (leftBrand, rightBrand) => {
|
|
|
44
34
|
* this logic. It does the error checking between the operands, and returns
|
|
45
35
|
* the brand, if any, that should label the resulting time value.
|
|
46
36
|
*
|
|
47
|
-
* @param {Timestamp | RelativeTime} left
|
|
48
|
-
* @param {Timestamp | RelativeTime} right
|
|
49
|
-
* @returns {TimerBrand | undefined}
|
|
37
|
+
* @param {import('./types').Timestamp | import('./types').RelativeTime} left
|
|
38
|
+
* @param {import('./types').Timestamp | import('./types').RelativeTime} right
|
|
39
|
+
* @returns {import('./types').TimerBrand | undefined}
|
|
50
40
|
*/
|
|
51
41
|
const sharedTimerBrand = (left, right) => {
|
|
52
42
|
const leftBrand = typeof left === 'bigint' ? undefined : left.timerBrand;
|
|
@@ -59,10 +49,10 @@ const sharedTimerBrand = (left, right) => {
|
|
|
59
49
|
* operators in the case where the returned time should be a `Timestamp`
|
|
60
50
|
* rather than a `RelativeTime`.
|
|
61
51
|
*
|
|
62
|
-
* @param {Timestamp | RelativeTime} left
|
|
63
|
-
* @param {Timestamp | RelativeTime} right
|
|
64
|
-
* @param {TimestampValue} absValue
|
|
65
|
-
* @returns {Timestamp}
|
|
52
|
+
* @param {import('./types').Timestamp | import('./types').RelativeTime} left
|
|
53
|
+
* @param {import('./types').Timestamp | import('./types').RelativeTime} right
|
|
54
|
+
* @param {import('./types').TimestampValue} absValue
|
|
55
|
+
* @returns {import('./types').Timestamp}
|
|
66
56
|
*/
|
|
67
57
|
const absLike = (left, right, absValue) => {
|
|
68
58
|
Nat(absValue);
|
|
@@ -82,10 +72,10 @@ const absLike = (left, right, absValue) => {
|
|
|
82
72
|
* operators in the case where the returned time should be a `RelativeTime`
|
|
83
73
|
* rather than a `Timestamp`.
|
|
84
74
|
*
|
|
85
|
-
* @param {Timestamp | RelativeTime} left
|
|
86
|
-
* @param {Timestamp | RelativeTime} right
|
|
87
|
-
* @param {RelativeTimeValue} relValue
|
|
88
|
-
* @returns {RelativeTime}
|
|
75
|
+
* @param {import('./types').Timestamp | import('./types').RelativeTime} left
|
|
76
|
+
* @param {import('./types').Timestamp | import('./types').RelativeTime} right
|
|
77
|
+
* @param {import('./types').RelativeTimeValue} relValue
|
|
78
|
+
* @returns {import('./types').RelativeTime}
|
|
89
79
|
*/
|
|
90
80
|
const relLike = (left, right, relValue) => {
|
|
91
81
|
Nat(relValue);
|
|
@@ -197,11 +187,11 @@ const modRelRel = (rel, step) =>
|
|
|
197
187
|
* `compareValues` is internal to this module, and used to implement
|
|
198
188
|
* the time comparison operators.
|
|
199
189
|
*
|
|
200
|
-
* @param {Timestamp | RelativeTime} left
|
|
201
|
-
* @param {Timestamp | RelativeTime} right
|
|
190
|
+
* @param {import('./types').Timestamp | import('./types').RelativeTime} left
|
|
191
|
+
* @param {import('./types').Timestamp | import('./types').RelativeTime} right
|
|
202
192
|
* @param {bigint} v1
|
|
203
193
|
* @param {bigint} v2
|
|
204
|
-
* @returns {RankComparison}
|
|
194
|
+
* @returns {import('@endo/marshal').RankComparison}
|
|
205
195
|
*/
|
|
206
196
|
const compareValues = (left, right, v1, v2) => {
|
|
207
197
|
sharedTimerBrand(left, right);
|
|
@@ -247,7 +237,7 @@ const compareValues = (left, right, v1, v2) => {
|
|
|
247
237
|
* operand, and return a labeled time object with the brand of the labeled
|
|
248
238
|
* operand.
|
|
249
239
|
*
|
|
250
|
-
* @type {TimeMathType}
|
|
240
|
+
* @type {import('./types').TimeMathType}
|
|
251
241
|
*/
|
|
252
242
|
export const TimeMath = harden({
|
|
253
243
|
absValue,
|
package/src/types.js
ADDED