File tree Expand file tree Collapse file tree
packages/common/src/local-first Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -336,8 +336,21 @@ export const timestampBytesToTimestamp = (
336336 return { millis : Number ( millis ) , counter, nodeId } as Timestamp ;
337337} ;
338338
339+ /**
340+ * An {@link Order} for {@link TimestampBytes}.
341+ *
342+ * This `Order` uses lexicographic byte order to compare serialized
343+ * {@link TimestampBytes} produced by {@link timestampToTimestampBytes}. See
344+ * {@link orderUint8Array} for the underlying implementation.
345+ */
339346export const orderTimestampBytes : Order < TimestampBytes > = orderUint8Array ;
340347
348+ /**
349+ * Convert a {@link Timestamp} to an ISO 8601 {@link DateIso} string.
350+ *
351+ * The conversion uses the timestamp's `millis` (a {@link Millis} value) and
352+ * `Date.prototype.toISOString()` to produce a `DateIso`.
353+ */
341354export const timestampToDateIso = ( timestamp : Timestamp ) : DateIso =>
342- // `as DateIso` is safe because the timestamp is always valid
355+ // `as DateIso` is safe because Timestamp guarantees a valid `millis`
343356 new Date ( timestamp . millis ) . toISOString ( ) as DateIso ;
You can’t perform that action at this time.
0 commit comments