@moq/net 0.4.8 → 0.22.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/README.md +7 -1
- package/announce.d.ts +1 -1
- package/announce.d.ts.map +1 -1
- package/announce.js +1 -1
- package/announce.js.map +1 -1
- package/announced.d.ts +51 -47
- package/announced.d.ts.map +1 -1
- package/announced.js +183 -31
- package/announced.js.map +1 -1
- package/announced.test-util.d.ts +2 -0
- package/announced.test-util.d.ts.map +1 -0
- package/announced.test-util.js +27 -0
- package/announced.test-util.js.map +1 -0
- package/auth.d.ts +64 -0
- package/auth.d.ts.map +1 -0
- package/auth.js +20 -0
- package/auth.js.map +1 -0
- package/auth_gate.d.ts +2 -0
- package/auth_gate.d.ts.map +1 -0
- package/auth_gate.js +24 -0
- package/auth_gate.js.map +1 -0
- package/auth_session.d.ts +49 -0
- package/auth_session.d.ts.map +1 -0
- package/auth_session.js +1097 -0
- package/auth_session.js.map +1 -0
- package/bandwidth.d.ts +129 -25
- package/bandwidth.d.ts.map +1 -1
- package/bandwidth.js +410 -138
- package/bandwidth.js.map +1 -1
- package/bandwidth_api.d.ts +1 -1
- package/bandwidth_api.d.ts.map +1 -1
- package/bandwidth_api.js +1 -1
- package/bandwidth_api.js.map +1 -1
- package/broadcast.d.ts +62 -36
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +556 -172
- package/broadcast.js.map +1 -1
- package/cache.d.ts +103 -0
- package/cache.d.ts.map +1 -0
- package/cache.js +254 -0
- package/cache.js.map +1 -0
- package/claim.test-util.d.ts +5 -0
- package/claim.test-util.d.ts.map +1 -0
- package/claim.test-util.js +13 -0
- package/claim.test-util.js.map +1 -0
- package/connection/accept.d.ts +20 -12
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +97 -129
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +28 -19
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +119 -23
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +535 -216
- package/connection/connect.js.map +1 -1
- package/connection/dials.d.ts +45 -0
- package/connection/dials.d.ts.map +1 -0
- package/connection/dials.js +109 -0
- package/connection/dials.js.map +1 -0
- package/connection/endpoint.d.ts +60 -0
- package/connection/endpoint.d.ts.map +1 -0
- package/connection/endpoint.js +114 -0
- package/connection/endpoint.js.map +1 -0
- package/connection/forward.d.ts +7 -1
- package/connection/forward.d.ts.map +1 -1
- package/connection/forward.js +265 -80
- package/connection/forward.js.map +1 -1
- package/connection/goaway.d.ts +16 -9
- package/connection/goaway.d.ts.map +1 -1
- package/connection/goaway.js +22 -108
- package/connection/goaway.js.map +1 -1
- package/connection/handshake.d.ts +32 -6
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +97 -20
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +3 -6
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +1 -2
- package/connection/index.js.map +1 -1
- package/connection/liveness.d.ts +14 -0
- package/connection/liveness.d.ts.map +1 -0
- package/connection/liveness.js +30 -0
- package/connection/liveness.js.map +1 -0
- package/connection/pool.d.ts +137 -58
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +281 -117
- package/connection/pool.js.map +1 -1
- package/connection/reload.d.ts +60 -12
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +859 -233
- package/connection/reload.js.map +1 -1
- package/connection/session.d.ts +91 -0
- package/connection/session.d.ts.map +1 -0
- package/connection/session.js +2 -0
- package/connection/session.js.map +1 -0
- package/connection/stats.d.ts +20 -11
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js +64 -8
- package/connection/stats.js.map +1 -1
- package/connection/ticker.d.ts +4 -0
- package/connection/ticker.d.ts.map +1 -0
- package/connection/ticker.js +66 -0
- package/connection/ticker.js.map +1 -0
- package/connection/tokens.d.ts +2 -0
- package/connection/tokens.d.ts.map +1 -0
- package/connection/tokens.js +404 -0
- package/connection/tokens.js.map +1 -0
- package/connection/transport.d.ts.map +1 -1
- package/connection/transport.js +4 -4
- package/connection/transport.js.map +1 -1
- package/connection/withdrawal.d.ts +2 -0
- package/connection/withdrawal.d.ts.map +1 -0
- package/connection/withdrawal.js +23 -0
- package/connection/withdrawal.js.map +1 -0
- package/consume.js +213 -46
- package/consume.js.map +1 -1
- package/cover.d.ts +59 -0
- package/cover.d.ts.map +1 -0
- package/cover.js +375 -0
- package/cover.js.map +1 -0
- package/datagram.d.ts +70 -11
- package/datagram.d.ts.map +1 -1
- package/datagram.js +317 -1
- package/datagram.js.map +1 -1
- package/datagram_stream.d.ts +18 -0
- package/datagram_stream.d.ts.map +1 -0
- package/datagram_stream.js +67 -0
- package/datagram_stream.js.map +1 -0
- package/defined.test-util.d.ts +2 -0
- package/defined.test-util.d.ts.map +1 -0
- package/defined.test-util.js +7 -0
- package/defined.test-util.js.map +1 -0
- package/delivered.d.ts +75 -0
- package/delivered.d.ts.map +1 -0
- package/delivered.js +228 -0
- package/delivered.js.map +1 -0
- package/demand.d.ts +173 -0
- package/demand.d.ts.map +1 -0
- package/demand.js +582 -0
- package/demand.js.map +1 -0
- package/drops.d.ts +93 -0
- package/drops.d.ts.map +1 -0
- package/drops.js +283 -0
- package/drops.js.map +1 -0
- package/error.d.ts +120 -21
- package/error.d.ts.map +1 -1
- package/error.js +230 -37
- package/error.js.map +1 -1
- package/errors.d.ts +2 -2
- package/errors.d.ts.map +1 -1
- package/errors.js +2 -2
- package/errors.js.map +1 -1
- package/fill.d.ts +174 -0
- package/fill.d.ts.map +1 -0
- package/fill.js +760 -0
- package/fill.js.map +1 -0
- package/flate/decoder.d.ts +2 -0
- package/flate/decoder.d.ts.map +1 -0
- package/flate/decoder.js +63 -0
- package/flate/decoder.js.map +1 -0
- package/flate/encoder.d.ts +2 -0
- package/flate/encoder.d.ts.map +1 -0
- package/flate/encoder.js +64 -0
- package/flate/encoder.js.map +1 -0
- package/flate/group.d.ts +34 -0
- package/flate/group.d.ts.map +1 -0
- package/flate/group.js +140 -0
- package/flate/group.js.map +1 -0
- package/frame.d.ts +80 -0
- package/frame.d.ts.map +1 -0
- package/frame.js +296 -0
- package/frame.js.map +1 -0
- package/frame.test-util.d.ts +5 -0
- package/frame.test-util.d.ts.map +1 -0
- package/frame.test-util.js +9 -0
- package/frame.test-util.js.map +1 -0
- package/group.d.ts +108 -45
- package/group.d.ts.map +1 -1
- package/group.js +1616 -307
- package/group.js.map +1 -1
- package/group_api.d.ts +7 -0
- package/group_api.d.ts.map +1 -0
- package/group_api.js +7 -0
- package/group_api.js.map +1 -0
- package/hop.d.ts +62 -76
- package/hop.d.ts.map +1 -1
- package/hop.js +92 -64
- package/hop.js.map +1 -1
- package/identity.d.ts +39 -0
- package/identity.d.ts.map +1 -0
- package/identity.js +47 -0
- package/identity.js.map +1 -0
- package/ietf/active_count.d.ts +2 -0
- package/ietf/active_count.d.ts.map +1 -0
- package/ietf/active_count.js +30 -0
- package/ietf/active_count.js.map +1 -0
- package/ietf/aliases.js +69 -35
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +14 -62
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +1 -31
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +305 -143
- package/ietf/connection.js.map +1 -1
- package/ietf/datagram.d.ts +60 -0
- package/ietf/datagram.d.ts.map +1 -0
- package/ietf/datagram.js +152 -0
- package/ietf/datagram.js.map +1 -0
- package/ietf/error.d.ts +3 -3
- package/ietf/error.js +82 -100
- package/ietf/error.js.map +1 -1
- package/ietf/fetch.d.ts +91 -35
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +172 -93
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +20 -30
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +140 -171
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +11 -9
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -35
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -1
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +2 -14
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +4 -14
- package/ietf/index.js.map +1 -1
- package/ietf/join.d.ts +7 -0
- package/ietf/join.d.ts.map +1 -0
- package/ietf/join.js +234 -0
- package/ietf/join.js.map +1 -0
- package/ietf/message.d.ts +18 -2
- package/ietf/message.d.ts.map +1 -1
- package/ietf/message.js +60 -40
- package/ietf/message.js.map +1 -1
- package/ietf/message.test-util.d.ts +6 -0
- package/ietf/message.test-util.d.ts.map +1 -0
- package/ietf/message.test-util.js +13 -0
- package/ietf/message.test-util.js.map +1 -0
- package/ietf/namespace.d.ts +17 -3
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +78 -26
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +194 -32
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +405 -178
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +22 -42
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +260 -472
- package/ietf/parameters.js.map +1 -1
- package/ietf/priority.d.ts +17 -2
- package/ietf/priority.d.ts.map +1 -1
- package/ietf/priority.js +19 -4
- package/ietf/priority.js.map +1 -1
- package/ietf/properties.d.ts +5 -4
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +78 -48
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +22 -30
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +45 -139
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +46 -69
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +66 -184
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +1800 -600
- package/ietf/publisher.js.map +1 -1
- package/ietf/range.d.ts +2 -0
- package/ietf/range.d.ts.map +1 -0
- package/ietf/range.js +222 -0
- package/ietf/range.js.map +1 -0
- package/ietf/request.d.ts +3 -27
- package/ietf/request.d.ts.map +1 -1
- package/ietf/request.js +41 -78
- package/ietf/request.js.map +1 -1
- package/ietf/request_stream.d.ts +1 -6
- package/ietf/request_stream.d.ts.map +1 -1
- package/ietf/request_stream.js +306 -16
- package/ietf/request_stream.js.map +1 -1
- package/ietf/session.d.ts +41 -0
- package/ietf/session.d.ts.map +1 -0
- package/ietf/session.js +65 -0
- package/ietf/session.js.map +1 -0
- package/ietf/setup.d.ts +4 -29
- package/ietf/setup.d.ts.map +1 -1
- package/ietf/setup.js +6 -117
- package/ietf/setup.js.map +1 -1
- package/ietf/setup_options.d.ts +31 -0
- package/ietf/setup_options.d.ts.map +1 -0
- package/ietf/setup_options.js +138 -0
- package/ietf/setup_options.js.map +1 -0
- package/ietf/solicit.js +4 -14
- package/ietf/solicit.js.map +1 -1
- package/ietf/subscribe.d.ts +48 -41
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +118 -239
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +13 -76
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +30 -201
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +1839 -536
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.js +105 -27
- package/ietf/token.js.map +1 -1
- package/ietf/track.d.ts +25 -22
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +48 -61
- package/ietf/track.js.map +1 -1
- package/ietf/version.d.ts +13 -42
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +22 -48
- package/ietf/version.js.map +1 -1
- package/implementation.d.ts +2 -0
- package/implementation.d.ts.map +1 -0
- package/implementation.js +5 -0
- package/implementation.js.map +1 -0
- package/index.d.ts +25 -10
- package/index.d.ts.map +1 -1
- package/index.js +19 -6
- package/index.js.map +1 -1
- package/internal.d.ts +1512 -64
- package/internal.d.ts.map +1 -1
- package/internal.js +557 -79
- package/internal.js.map +1 -1
- package/ledger.d.ts +23 -0
- package/ledger.d.ts.map +1 -0
- package/ledger.js +247 -0
- package/ledger.js.map +1 -0
- package/listing.d.ts +132 -0
- package/listing.d.ts.map +1 -0
- package/listing.js +486 -0
- package/listing.js.map +1 -0
- package/lite/announce.d.ts +124 -63
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +384 -158
- package/lite/announce.js.map +1 -1
- package/lite/announce_stream.d.ts +2 -0
- package/lite/announce_stream.d.ts.map +1 -0
- package/lite/announce_stream.js +92 -0
- package/lite/announce_stream.js.map +1 -0
- package/lite/answer.d.ts +22 -0
- package/lite/answer.d.ts.map +1 -0
- package/lite/answer.js +301 -0
- package/lite/answer.js.map +1 -0
- package/lite/auth.d.ts +45 -0
- package/lite/auth.d.ts.map +1 -0
- package/lite/auth.js +204 -0
- package/lite/auth.js.map +1 -0
- package/lite/compat.d.ts +31 -0
- package/lite/compat.d.ts.map +1 -0
- package/lite/compat.js +86 -0
- package/lite/compat.js.map +1 -0
- package/lite/connection.d.ts +1 -45
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +360 -77
- package/lite/connection.js.map +1 -1
- package/lite/datagram-end.d.ts +26 -0
- package/lite/datagram-end.d.ts.map +1 -0
- package/lite/datagram-end.js +30 -0
- package/lite/datagram-end.js.map +1 -0
- package/lite/datagram.d.ts +73 -8
- package/lite/datagram.d.ts.map +1 -1
- package/lite/datagram.js +144 -9
- package/lite/datagram.js.map +1 -1
- package/lite/duration.d.ts +6 -0
- package/lite/duration.d.ts.map +1 -0
- package/lite/duration.js +14 -0
- package/lite/duration.js.map +1 -0
- package/lite/error.d.ts +9 -0
- package/lite/error.d.ts.map +1 -0
- package/lite/error.js +24 -0
- package/lite/error.js.map +1 -0
- package/lite/fills.d.ts +162 -0
- package/lite/fills.d.ts.map +1 -0
- package/lite/fills.js +486 -0
- package/lite/fills.js.map +1 -0
- package/lite/fit.d.ts +49 -0
- package/lite/fit.d.ts.map +1 -0
- package/lite/fit.js +305 -0
- package/lite/fit.js.map +1 -0
- package/lite/goaway.d.ts +1 -1
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +5 -13
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +64 -13
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +108 -30
- package/lite/group.js.map +1 -1
- package/lite/identity.d.ts +25 -0
- package/lite/identity.d.ts.map +1 -0
- package/lite/identity.js +79 -0
- package/lite/identity.js.map +1 -0
- package/lite/index.d.ts +2 -1
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +2 -1
- package/lite/index.js.map +1 -1
- package/lite/message.d.ts +9 -1
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +28 -44
- package/lite/message.js.map +1 -1
- package/lite/priority.d.ts +9 -2
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +11 -105
- package/lite/priority.js.map +1 -1
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +9 -0
- package/lite/probe.js.map +1 -1
- package/lite/publisher.d.ts +10 -1
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +2548 -437
- package/lite/publisher.js.map +1 -1
- package/lite/routed.d.ts +59 -0
- package/lite/routed.d.ts.map +1 -0
- package/lite/routed.js +564 -0
- package/lite/routed.js.map +1 -0
- package/lite/session.d.ts +1 -27
- package/lite/session.d.ts.map +1 -1
- package/lite/session.js +0 -99
- package/lite/session.js.map +1 -1
- package/lite/setup.d.ts +29 -2
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +95 -21
- package/lite/setup.js.map +1 -1
- package/lite/stream.d.ts +5 -11
- package/lite/stream.d.ts.map +1 -1
- package/lite/stream.js +5 -1
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +475 -75
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +1373 -142
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +7 -44
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +3290 -515
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +24 -9
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +116 -37
- package/lite/track.js.map +1 -1
- package/lite/tracks.d.ts +55 -0
- package/lite/tracks.d.ts.map +1 -0
- package/lite/tracks.js +114 -0
- package/lite/tracks.js.map +1 -0
- package/lite/version.d.ts +132 -24
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +378 -33
- package/lite/version.js.map +1 -1
- package/meta.d.ts +77 -0
- package/meta.d.ts.map +1 -0
- package/meta.js +130 -0
- package/meta.js.map +1 -0
- package/meta_api.d.ts +7 -0
- package/meta_api.d.ts.map +1 -0
- package/meta_api.js +7 -0
- package/meta_api.js.map +1 -0
- package/mint.d.ts +28 -0
- package/mint.d.ts.map +1 -0
- package/mint.js +66 -0
- package/mint.js.map +1 -0
- package/open.d.ts +63 -0
- package/open.d.ts.map +1 -0
- package/open.js +250 -0
- package/open.js.map +1 -0
- package/origin.d.ts +392 -140
- package/origin.d.ts.map +1 -1
- package/origin.js +2533 -686
- package/origin.js.map +1 -1
- package/package.json +8 -13
- package/path.d.ts +51 -51
- package/path.d.ts.map +1 -1
- package/path.js +210 -57
- package/path.js.map +1 -1
- package/payload.d.ts +33 -0
- package/payload.d.ts.map +1 -0
- package/payload.js +65 -0
- package/payload.js.map +1 -0
- package/prefix.d.ts +152 -0
- package/prefix.d.ts.map +1 -0
- package/prefix.js +349 -0
- package/prefix.js.map +1 -0
- package/priority.d.ts +8 -0
- package/priority.d.ts.map +1 -0
- package/priority.js +185 -0
- package/priority.js.map +1 -0
- package/queue.d.ts +2 -0
- package/queue.d.ts.map +1 -0
- package/queue.js +46 -0
- package/queue.js.map +1 -0
- package/ranges.d.ts +36 -0
- package/ranges.d.ts.map +1 -0
- package/ranges.js +312 -0
- package/ranges.js.map +1 -0
- package/rescale.d.ts +24 -0
- package/rescale.d.ts.map +1 -0
- package/rescale.js +39 -0
- package/rescale.js.map +1 -0
- package/resume.d.ts +55 -0
- package/resume.d.ts.map +1 -0
- package/resume.js +4173 -0
- package/resume.js.map +1 -0
- package/resume.test-util.d.ts +2 -0
- package/resume.test-util.d.ts.map +1 -0
- package/resume.test-util.js +25 -0
- package/resume.test-util.js.map +1 -0
- package/skips.d.ts +48 -0
- package/skips.d.ts.map +1 -0
- package/skips.js +182 -0
- package/skips.js.map +1 -0
- package/stream.d.ts +75 -37
- package/stream.d.ts.map +1 -1
- package/stream.js +236 -92
- package/stream.js.map +1 -1
- package/subscription.test-util.d.ts +2 -0
- package/subscription.test-util.d.ts.map +1 -0
- package/subscription.test-util.js +49 -0
- package/subscription.test-util.js.map +1 -0
- package/tail.d.ts +23 -14
- package/tail.d.ts.map +1 -1
- package/tail.js +224 -97
- package/tail.js.map +1 -1
- package/time.d.ts +41 -102
- package/time.d.ts.map +1 -1
- package/time.js +129 -91
- package/time.js.map +1 -1
- package/timed.d.ts +21 -0
- package/timed.d.ts.map +1 -0
- package/timed.js +2 -0
- package/timed.js.map +1 -0
- package/track.d.ts +577 -245
- package/track.d.ts.map +1 -1
- package/track.js +7306 -771
- package/track.js.map +1 -1
- package/track_api.d.ts +7 -0
- package/track_api.d.ts.map +1 -0
- package/track_api.js +7 -0
- package/track_api.js.map +1 -0
- package/util/abort.d.ts +1 -0
- package/util/abort.d.ts.map +1 -1
- package/util/abort.js +23 -1
- package/util/abort.js.map +1 -1
- package/util/announce.d.ts +4 -0
- package/util/announce.d.ts.map +1 -0
- package/util/announce.js +11 -0
- package/util/announce.js.map +1 -0
- package/util/bigint.d.ts +3 -0
- package/util/bigint.d.ts.map +1 -0
- package/util/bigint.js +8 -0
- package/util/bigint.js.map +1 -0
- package/util/change.d.ts +12 -0
- package/util/change.d.ts.map +1 -0
- package/util/change.js +18 -0
- package/util/change.js.map +1 -0
- package/util/deadline.d.ts +2 -0
- package/util/deadline.d.ts.map +1 -0
- package/util/deadline.js +108 -0
- package/util/deadline.js.map +1 -0
- package/util/decode_error.d.ts +3 -0
- package/util/decode_error.d.ts.map +1 -0
- package/util/decode_error.js +11 -0
- package/util/decode_error.js.map +1 -0
- package/util/demand.d.ts +8 -0
- package/util/demand.d.ts.map +1 -0
- package/util/demand.js +24 -0
- package/util/demand.js.map +1 -0
- package/util/given_up.d.ts +2 -0
- package/util/given_up.d.ts.map +1 -0
- package/util/given_up.js +101 -0
- package/util/given_up.js.map +1 -0
- package/util/hex.d.ts +6 -0
- package/util/hex.d.ts.map +1 -1
- package/util/hex.js +19 -4
- package/util/hex.js.map +1 -1
- package/util/key.d.ts +15 -0
- package/util/key.d.ts.map +1 -0
- package/util/key.js +38 -0
- package/util/key.js.map +1 -0
- package/util/limits.d.ts +2 -0
- package/util/limits.d.ts.map +1 -0
- package/util/limits.js +76 -0
- package/util/limits.js.map +1 -0
- package/util/observed.d.ts +23 -0
- package/util/observed.d.ts.map +1 -0
- package/util/observed.js +122 -0
- package/util/observed.js.map +1 -0
- package/util/sorted.d.ts +2 -0
- package/util/sorted.d.ts.map +1 -0
- package/util/sorted.js +149 -0
- package/util/sorted.js.map +1 -0
- package/util/timeout.d.ts +2 -1
- package/util/timeout.d.ts.map +1 -1
- package/util/timeout.js +13 -9
- package/util/timeout.js.map +1 -1
- package/util/timer.d.ts +2 -0
- package/util/timer.d.ts.map +1 -0
- package/util/timer.js +19 -0
- package/util/timer.js.map +1 -0
- package/util/utf8.d.ts +2 -0
- package/util/utf8.d.ts.map +1 -1
- package/util/utf8.js +7 -1
- package/util/utf8.js.map +1 -1
- package/util/varint.d.ts.map +1 -1
- package/util/varint.js +8 -1
- package/util/varint.js.map +1 -1
- package/util/watch.d.ts +8 -0
- package/util/watch.d.ts.map +1 -0
- package/util/watch.js +38 -0
- package/util/watch.js.map +1 -0
- package/util/yield.d.ts +2 -0
- package/util/yield.d.ts.map +1 -0
- package/util/yield.js +31 -0
- package/util/yield.js.map +1 -0
- package/varint.d.ts +0 -29
- package/varint.d.ts.map +1 -1
- package/varint.js +7 -28
- package/varint.js.map +1 -1
- package/varint_api.d.ts +7 -0
- package/varint_api.d.ts.map +1 -0
- package/varint_api.js +7 -0
- package/varint_api.js.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
- package/window.d.ts +570 -0
- package/window.d.ts.map +1 -0
- package/window.js +1677 -0
- package/window.js.map +1 -0
- package/wire.d.ts +145 -30
- package/wire.d.ts.map +1 -1
- package/wire.js +27 -0
- package/wire.js.map +1 -1
- package/connection/established.d.ts +0 -53
- package/connection/established.d.ts.map +0 -1
- package/connection/established.js +0 -2
- package/connection/established.js.map +0 -1
- package/ietf/adapter.d.ts +0 -75
- package/ietf/adapter.d.ts.map +0 -1
- package/ietf/adapter.js +0 -699
- package/ietf/adapter.js.map +0 -1
- package/lite/datagram_stream.d.ts +0 -8
- package/lite/datagram_stream.d.ts.map +0 -1
- package/lite/datagram_stream.js +0 -43
- package/lite/datagram_stream.js.map +0 -1
- package/lite/fetch.d.ts +0 -28
- package/lite/fetch.d.ts.map +0 -1
- package/lite/fetch.js +0 -78
- package/lite/fetch.js.map +0 -1
- package/util/log.d.ts +0 -5
- package/util/log.d.ts.map +0 -1
- package/util/log.js +0 -16
- package/util/log.js.map +0 -1
- package/zod.d.ts +0 -13
- package/zod.d.ts.map +0 -1
- package/zod.js +0 -18
- package/zod.js.map +0 -1
package/time.js
CHANGED
|
@@ -1,66 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* {@link Timescale} and {@link Timestamp} for presentation timing.
|
|
3
|
+
*
|
|
4
|
+
* Durations and instants live in `@moq/clock`.
|
|
4
5
|
*
|
|
5
6
|
* @module
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export const Nano = Object.assign((value) => value, {
|
|
11
|
-
zero: 0,
|
|
12
|
-
fromMicro: (us) => (us * 1_000),
|
|
13
|
-
fromMilli: (ms) => (ms * 1_000_000),
|
|
14
|
-
fromSecond: (s) => (s * 1_000_000_000),
|
|
15
|
-
toMicro: (ns) => (ns / 1_000),
|
|
16
|
-
toMilli: (ns) => (ns / 1_000_000),
|
|
17
|
-
toSecond: (ns) => (ns / 1_000_000_000),
|
|
18
|
-
now: () => (performance.now() * 1_000_000),
|
|
19
|
-
add: (a, b) => (a + b),
|
|
20
|
-
sub: (a, b) => (a - b),
|
|
21
|
-
mul: (a, b) => (a * b),
|
|
22
|
-
div: (a, b) => (a / b),
|
|
23
|
-
max: (a, b) => Math.max(a, b),
|
|
24
|
-
min: (a, b) => Math.min(a, b),
|
|
25
|
-
});
|
|
26
|
-
/** Constructors, conversions, and arithmetic for {@link Micro} values. */
|
|
27
|
-
// Calling `Micro(x)` brands a raw number as microseconds. See the `Nano` note: this asserts the unit
|
|
28
|
-
// rather than converting, so use `fromNano`/`fromMilli`/`fromSecond` to convert from another unit.
|
|
29
|
-
export const Micro = Object.assign((value) => value, {
|
|
30
|
-
zero: 0,
|
|
31
|
-
fromNano: (ns) => (ns / 1_000),
|
|
32
|
-
fromMilli: (ms) => (ms * 1_000),
|
|
33
|
-
fromSecond: (s) => (s * 1_000_000),
|
|
34
|
-
toNano: (us) => (us * 1_000),
|
|
35
|
-
toMilli: (us) => (us / 1_000),
|
|
36
|
-
toSecond: (us) => (us / 1_000_000),
|
|
37
|
-
now: () => (performance.now() * 1_000),
|
|
38
|
-
add: (a, b) => (a + b),
|
|
39
|
-
sub: (a, b) => (a - b),
|
|
40
|
-
mul: (a, b) => (a * b),
|
|
41
|
-
div: (a, b) => (a / b),
|
|
42
|
-
max: (a, b) => Math.max(a, b),
|
|
43
|
-
min: (a, b) => Math.min(a, b),
|
|
44
|
-
});
|
|
45
|
-
/** Constructors, conversions, and arithmetic for {@link Milli} values. */
|
|
46
|
-
// Calling `Milli(x)` brands a raw number as milliseconds. See the `Nano` note: this asserts the unit
|
|
47
|
-
// rather than converting, so use `fromNano`/`fromMicro`/`fromSecond` to convert from another unit.
|
|
48
|
-
export const Milli = Object.assign((value) => value, {
|
|
49
|
-
zero: 0,
|
|
50
|
-
fromNano: (ns) => (ns / 1_000_000),
|
|
51
|
-
fromMicro: (us) => (us / 1_000),
|
|
52
|
-
fromSecond: (s) => (s * 1_000),
|
|
53
|
-
toNano: (ms) => (ms * 1_000_000),
|
|
54
|
-
toMicro: (ms) => (ms * 1_000),
|
|
55
|
-
toSecond: (ms) => (ms / 1_000),
|
|
56
|
-
now: () => performance.now(),
|
|
57
|
-
add: (a, b) => (a + b),
|
|
58
|
-
sub: (a, b) => (a - b),
|
|
59
|
-
mul: (a, b) => (a * b),
|
|
60
|
-
div: (a, b) => (a / b),
|
|
61
|
-
max: (a, b) => Math.max(a, b),
|
|
62
|
-
min: (a, b) => Math.min(a, b),
|
|
63
|
-
});
|
|
8
|
+
import { Instant, now } from "@moq/clock";
|
|
9
|
+
import { StreamCode, Stream as StreamError } from "./error.js";
|
|
10
|
+
import { toNumber } from "./util/bigint.js";
|
|
64
11
|
/**
|
|
65
12
|
* Named timescales and a checked constructor.
|
|
66
13
|
*
|
|
@@ -89,22 +36,30 @@ function assertTimestampValue(value) {
|
|
|
89
36
|
}
|
|
90
37
|
}
|
|
91
38
|
/**
|
|
92
|
-
* A presentation timestamp: a raw value in a given {@link Timescale}
|
|
39
|
+
* A presentation timestamp: a raw value in a given {@link Timescale}, or a scale-less track's
|
|
40
|
+
* group key.
|
|
93
41
|
*
|
|
94
|
-
* Mirrors the Rust `Timestamp`. Unlike
|
|
42
|
+
* Mirrors the Rust `Timestamp`. Unlike a `@moq/clock` `Duration` it carries its
|
|
95
43
|
* own scale, so a track can pick its units and conversions can't silently mix them up.
|
|
96
44
|
*
|
|
97
|
-
*
|
|
98
|
-
* (
|
|
99
|
-
* track timescale. Integer timestamps are exact through `2^53 - 1` units; this package
|
|
45
|
+
* A scaled value must be finite and in `[0, Number.MAX_SAFE_INTEGER]`. Fractions are allowed
|
|
46
|
+
* ({@link Timestamp.now}, scale conversion). Encoding rounds down to an integer at the
|
|
47
|
+
* track timescale, as the Rust `Timestamp::convert` does. Integer timestamps are exact through `2^53 - 1` units; this package
|
|
100
48
|
* does not use BigInt for timestamps. {@link Timestamp.as} also refuses a converted
|
|
101
49
|
* value that leaves that range, so a legal source timestamp cannot become an unencodable
|
|
102
50
|
* wire timestamp after a scale change.
|
|
51
|
+
*
|
|
52
|
+
* A scale-less track has no time: each frame's timestamp is {@link Timestamp.unscaled}, whose
|
|
53
|
+
* {@link value} is its group's key and whose {@link scale} is `undefined`, as Rust's
|
|
54
|
+
* `Timestamp::unscaled(key)`. A key past `Number.MAX_SAFE_INTEGER` is refused, so such a group's
|
|
55
|
+
* frames cannot be read here. Anything that needs a scale ({@link as}, {@link asMillis},
|
|
56
|
+
* {@link asMicros}) throws a `RangeError` on one, and {@link isBefore} orders it against no
|
|
57
|
+
* scaled timestamp.
|
|
103
58
|
*/
|
|
104
59
|
export class Timestamp {
|
|
105
|
-
/** The raw value
|
|
60
|
+
/** The raw value in `scale` units, or an unscaled timestamp's group key. */
|
|
106
61
|
value;
|
|
107
|
-
/** Units per second the {@link value} is measured in. */
|
|
62
|
+
/** Units per second the {@link value} is measured in, or `undefined` when unscaled. */
|
|
108
63
|
scale;
|
|
109
64
|
/** Build a timestamp of `value` units at `scale`. */
|
|
110
65
|
constructor(value, scale) {
|
|
@@ -112,9 +67,30 @@ export class Timestamp {
|
|
|
112
67
|
this.value = value;
|
|
113
68
|
this.scale = Timescale(scale);
|
|
114
69
|
}
|
|
115
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* A scale-less track's timestamp: `key` is its group's key (or a datagram's key), with no
|
|
72
|
+
* time. Throws a `RangeError` past `Number.MAX_SAFE_INTEGER`, which a `number` cannot hold.
|
|
73
|
+
*/
|
|
74
|
+
static unscaled(key) {
|
|
75
|
+
if (typeof key === "bigint") {
|
|
76
|
+
if (key < 0n || key > BigInt(Number.MAX_SAFE_INTEGER))
|
|
77
|
+
throw new RangeError(`invalid timestamp key: ${key}`);
|
|
78
|
+
key = Number(key);
|
|
79
|
+
}
|
|
80
|
+
if (!Number.isSafeInteger(key) || key < 0)
|
|
81
|
+
throw new RangeError(`invalid timestamp key: ${key}`);
|
|
82
|
+
const timestamp = new Timestamp(key, Timescale.SECOND);
|
|
83
|
+
// Set here rather than through the constructor, so `new Timestamp` only ever builds a scaled one.
|
|
84
|
+
timestamp.scale = undefined;
|
|
85
|
+
return timestamp;
|
|
86
|
+
}
|
|
87
|
+
/** The installed clock's monotonic instant in milliseconds, not wall-clock time. */
|
|
116
88
|
static now() {
|
|
117
|
-
return new Timestamp(
|
|
89
|
+
return new Timestamp(now().since(Instant.ZERO).asMillis(), Timescale.MILLI);
|
|
90
|
+
}
|
|
91
|
+
/** A timestamp of `secs` seconds. */
|
|
92
|
+
static fromSecs(secs) {
|
|
93
|
+
return new Timestamp(secs, Timescale.SECOND);
|
|
118
94
|
}
|
|
119
95
|
/** A timestamp of `ms` milliseconds. */
|
|
120
96
|
static fromMillis(ms) {
|
|
@@ -124,39 +100,101 @@ export class Timestamp {
|
|
|
124
100
|
static fromMicros(us) {
|
|
125
101
|
return new Timestamp(us, Timescale.MICRO);
|
|
126
102
|
}
|
|
127
|
-
/**
|
|
103
|
+
/** A timestamp of `ns` nanoseconds. */
|
|
104
|
+
static fromNanos(ns) {
|
|
105
|
+
return new Timestamp(ns, Timescale.NANO);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* This timestamp's value re-expressed at `scale`; throws a `RangeError` if it is unscaled or
|
|
109
|
+
* the result is not in the safe range.
|
|
110
|
+
*/
|
|
128
111
|
as(scale) {
|
|
129
112
|
const dest = Timescale(scale);
|
|
130
|
-
const
|
|
113
|
+
const from = scaled(this);
|
|
114
|
+
const converted = dest === from ? this.value : (this.value * dest) / from;
|
|
131
115
|
assertTimestampValue(converted);
|
|
132
116
|
return converted;
|
|
133
117
|
}
|
|
134
|
-
/** The value in
|
|
118
|
+
/** The value in seconds; throws a `RangeError` if it is unscaled. */
|
|
119
|
+
asSecs() {
|
|
120
|
+
return this.as(Timescale.SECOND);
|
|
121
|
+
}
|
|
122
|
+
/** The value in milliseconds; throws a `RangeError` if it is unscaled. */
|
|
135
123
|
asMillis() {
|
|
136
124
|
return this.as(Timescale.MILLI);
|
|
137
125
|
}
|
|
138
|
-
/** The value in microseconds. */
|
|
126
|
+
/** The value in microseconds; throws a `RangeError` if it is unscaled. */
|
|
139
127
|
asMicros() {
|
|
140
128
|
return this.as(Timescale.MICRO);
|
|
141
129
|
}
|
|
130
|
+
/** The value in nanoseconds; throws a `RangeError` if it is unscaled or past the safe range. */
|
|
131
|
+
asNanos() {
|
|
132
|
+
return this.as(Timescale.NANO);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Whether this presents before `other`, whatever their scales. Two unscaled timestamps order
|
|
136
|
+
* by key; a scaled and an unscaled one don't order, so neither is before the other.
|
|
137
|
+
*/
|
|
138
|
+
isBefore(other) {
|
|
139
|
+
if (this.scale === undefined || other.scale === undefined) {
|
|
140
|
+
return this.scale === other.scale && this.value < other.value;
|
|
141
|
+
}
|
|
142
|
+
if (this.scale === other.scale)
|
|
143
|
+
return this.value < other.value;
|
|
144
|
+
// Cross-scale products can pass 2^53, so they are compared exactly in BigInt, as Rust does in u128.
|
|
145
|
+
const [ma, ea] = binary(this.value);
|
|
146
|
+
const [mb, eb] = binary(other.value);
|
|
147
|
+
const e = Math.min(ea, eb);
|
|
148
|
+
return (ma * BigInt(scaled(other))) << BigInt(ea - e) < (mb * BigInt(scaled(this))) << BigInt(eb - e);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A received frame's timestamp: the one its wire carried, or on a scale-less track, which
|
|
153
|
+
* carries none, {@link Timestamp.unscaled} at its group's `key` (a datagram's key). A key past
|
|
154
|
+
* `Number.MAX_SAFE_INTEGER` is a valid group this side cannot hold, so it fails only that
|
|
155
|
+
* stream, with `NotSupported`. Mirrors Rust's `Timestamp::received`.
|
|
156
|
+
*
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
export function received(timestamp, key) {
|
|
160
|
+
if (timestamp)
|
|
161
|
+
return timestamp;
|
|
162
|
+
if (key > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
163
|
+
throw new StreamError(StreamCode.NotSupported, { message: `no unscaled timestamp holds key ${key}` });
|
|
164
|
+
}
|
|
165
|
+
return Timestamp.unscaled(key);
|
|
166
|
+
}
|
|
167
|
+
// `timestamp`'s scale, or a `RangeError` when unscaled: a group key has no time to convert.
|
|
168
|
+
function scaled(timestamp) {
|
|
169
|
+
if (timestamp.scale === undefined)
|
|
170
|
+
throw new RangeError("an unscaled timestamp has no time");
|
|
171
|
+
return timestamp.scale;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* `timestamp`'s value at `scale`, rounded down exactly, as Rust's integer `Timestamp::convert`.
|
|
175
|
+
*
|
|
176
|
+
* A double is a dyadic rational, so the conversion runs in BigInt with no rounding before the
|
|
177
|
+
* floor: an aligned value keeps it (4611686021000000 ns is 4611686021 ms, where `as` gives
|
|
178
|
+
* 4611686020.999999), and one instant gives one result whatever scale it came from. Throws a
|
|
179
|
+
* `RangeError` past the safe integer range, or for an unscaled timestamp.
|
|
180
|
+
*
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
export function floorAt(timestamp, scale) {
|
|
184
|
+
const from = scaled(timestamp);
|
|
185
|
+
if (from === scale)
|
|
186
|
+
return Math.floor(timestamp.value);
|
|
187
|
+
const [mantissa, exponent] = binary(timestamp.value);
|
|
188
|
+
return toNumber((mantissa * BigInt(scale)) / (BigInt(from) << BigInt(-exponent)));
|
|
189
|
+
}
|
|
190
|
+
// A finite, non-negative `value` exactly as `mantissa * 2^exponent`. Doubling is exact, so
|
|
191
|
+
// a fraction becomes an integer within its binary digits.
|
|
192
|
+
function binary(value) {
|
|
193
|
+
let exponent = 0;
|
|
194
|
+
while (!Number.isInteger(value)) {
|
|
195
|
+
value *= 2;
|
|
196
|
+
exponent--;
|
|
197
|
+
}
|
|
198
|
+
return [BigInt(value), exponent];
|
|
142
199
|
}
|
|
143
|
-
/** Constructors, conversions, and arithmetic for {@link Second} values. */
|
|
144
|
-
// Calling `Second(x)` brands a raw number as seconds. See the `Nano` note: this asserts the unit
|
|
145
|
-
// rather than converting, so use `fromNano`/`fromMicro`/`fromMilli` to convert from another unit.
|
|
146
|
-
export const Second = Object.assign((value) => value, {
|
|
147
|
-
zero: 0,
|
|
148
|
-
fromNano: (ns) => (ns / 1_000_000_000),
|
|
149
|
-
fromMicro: (us) => (us / 1_000_000),
|
|
150
|
-
fromMilli: (ms) => (ms / 1_000),
|
|
151
|
-
toNano: (s) => (s * 1_000_000_000),
|
|
152
|
-
toMicro: (s) => (s * 1_000_000),
|
|
153
|
-
toMilli: (s) => (s * 1_000),
|
|
154
|
-
now: () => (performance.now() / 1_000),
|
|
155
|
-
add: (a, b) => (a + b),
|
|
156
|
-
sub: (a, b) => (a - b),
|
|
157
|
-
mul: (a, b) => (a * b),
|
|
158
|
-
div: (a, b) => (a / b),
|
|
159
|
-
max: (a, b) => Math.max(a, b),
|
|
160
|
-
min: (a, b) => Math.min(a, b),
|
|
161
|
-
});
|
|
162
200
|
//# sourceMappingURL=time.js.map
|
package/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,yEAAyE;AACzE,+FAA+F;AAC/F,oGAAoG;AACpG,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAa,EAAQ,EAAE,CAAC,KAAa,EAAE;IACzE,IAAI,EAAE,CAAS;IACf,SAAS,EAAE,CAAC,EAAS,EAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,CAAS;IACpD,SAAS,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,KAAK,CAAW;IACxD,MAAM,EAAE,CAAC,CAAS,EAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,aAAa,CAAS;IACxD,OAAO,EAAE,CAAC,CAAS,EAAS,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,CAAU;IACvD,OAAO,EAAE,CAAC,CAAS,EAAS,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAU;IACnD,GAAG,EAAE,GAAW,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAW;IAC/D,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAW;CAC/D,CAAC,CAAC","sourcesContent":["/**\n * Branded time types (nanoseconds, microseconds, milliseconds, seconds) with conversions,\n * plus {@link Timescale} and {@link Timestamp} for presentation timing.\n *\n * @module\n */\n\n/** A duration in nanoseconds, branded so it can't be mixed with other units. */\nexport type Nano = number & { readonly _brand: \"nano\" };\n\n/** Constructors, conversions, and arithmetic for {@link Nano} values. */\n// Calling `Nano(x)` brands a raw number as nanoseconds. The unit is the caller's assertion: no\n// conversion happens, so reach for `fromMicro`/`fromMilli`/`fromSecond` when the source has a unit.\nexport const Nano = Object.assign((value: number): Nano => value as Nano, {\n\tzero: 0 as Nano,\n\tfromMicro: (us: Micro): Nano => (us * 1_000) as Nano,\n\tfromMilli: (ms: Milli): Nano => (ms * 1_000_000) as Nano,\n\tfromSecond: (s: Second): Nano => (s * 1_000_000_000) as Nano,\n\ttoMicro: (ns: Nano): Micro => (ns / 1_000) as Micro,\n\ttoMilli: (ns: Nano): Milli => (ns / 1_000_000) as Milli,\n\ttoSecond: (ns: Nano): Second => (ns / 1_000_000_000) as Second,\n\tnow: (): Nano => (performance.now() * 1_000_000) as Nano,\n\tadd: (a: Nano, b: Nano): Nano => (a + b) as Nano,\n\tsub: (a: Nano, b: Nano): Nano => (a - b) as Nano,\n\tmul: (a: Nano, b: number): Nano => (a * b) as Nano,\n\tdiv: (a: Nano, b: number): Nano => (a / b) as Nano,\n\tmax: (a: Nano, b: Nano): Nano => Math.max(a, b) as Nano,\n\tmin: (a: Nano, b: Nano): Nano => Math.min(a, b) as Nano,\n});\n\n/** A duration in microseconds, branded so it can't be mixed with other units. */\nexport type Micro = number & { readonly _brand: \"micro\" };\n\n/** Constructors, conversions, and arithmetic for {@link Micro} values. */\n// Calling `Micro(x)` brands a raw number as microseconds. See the `Nano` note: this asserts the unit\n// rather than converting, so use `fromNano`/`fromMilli`/`fromSecond` to convert from another unit.\nexport const Micro = Object.assign((value: number): Micro => value as Micro, {\n\tzero: 0 as Micro,\n\tfromNano: (ns: Nano): Micro => (ns / 1_000) as Micro,\n\tfromMilli: (ms: Milli): Micro => (ms * 1_000) as Micro,\n\tfromSecond: (s: Second): Micro => (s * 1_000_000) as Micro,\n\ttoNano: (us: Micro): Nano => (us * 1_000) as Nano,\n\ttoMilli: (us: Micro): Milli => (us / 1_000) as Milli,\n\ttoSecond: (us: Micro): Second => (us / 1_000_000) as Second,\n\tnow: (): Micro => (performance.now() * 1_000) as Micro,\n\tadd: (a: Micro, b: Micro): Micro => (a + b) as Micro,\n\tsub: (a: Micro, b: Micro): Micro => (a - b) as Micro,\n\tmul: (a: Micro, b: number): Micro => (a * b) as Micro,\n\tdiv: (a: Micro, b: number): Micro => (a / b) as Micro,\n\tmax: (a: Micro, b: Micro): Micro => Math.max(a, b) as Micro,\n\tmin: (a: Micro, b: Micro): Micro => Math.min(a, b) as Micro,\n});\n\n/** A duration in milliseconds, branded so it can't be mixed with other units. */\nexport type Milli = number & { readonly _brand: \"milli\" };\n\n/** Constructors, conversions, and arithmetic for {@link Milli} values. */\n// Calling `Milli(x)` brands a raw number as milliseconds. See the `Nano` note: this asserts the unit\n// rather than converting, so use `fromNano`/`fromMicro`/`fromSecond` to convert from another unit.\nexport const Milli = Object.assign((value: number): Milli => value as Milli, {\n\tzero: 0 as Milli,\n\tfromNano: (ns: Nano): Milli => (ns / 1_000_000) as Milli,\n\tfromMicro: (us: Micro): Milli => (us / 1_000) as Milli,\n\tfromSecond: (s: Second): Milli => (s * 1_000) as Milli,\n\ttoNano: (ms: Milli): Nano => (ms * 1_000_000) as Nano,\n\ttoMicro: (ms: Milli): Micro => (ms * 1_000) as Micro,\n\ttoSecond: (ms: Milli): Second => (ms / 1_000) as Second,\n\tnow: (): Milli => performance.now() as Milli,\n\tadd: (a: Milli, b: Milli): Milli => (a + b) as Milli,\n\tsub: (a: Milli, b: Milli): Milli => (a - b) as Milli,\n\tmul: (a: Milli, b: number): Milli => (a * b) as Milli,\n\tdiv: (a: Milli, b: number): Milli => (a / b) as Milli,\n\tmax: (a: Milli, b: Milli): Milli => Math.max(a, b) as Milli,\n\tmin: (a: Milli, b: Milli): Milli => Math.min(a, b) as Milli,\n});\n\n/** Units per second for a {@link Timestamp}'s value, e.g. `1000` for milliseconds. */\nexport type Timescale = number & { readonly _brand: \"timescale\" };\n\n/**\n * Named timescales and a checked constructor.\n *\n * Units per second must be a safe integer ≥ 1. JavaScript numbers are exact only\n * through `Number.MAX_SAFE_INTEGER` (`2^53 - 1`); the wire varint range goes\n * to `2^62 - 1`, which Rust accepts and this constructor refuses.\n */\nexport const Timescale = Object.assign(\n\t(unitsPerSecond: number): Timescale => {\n\t\tif (!Number.isSafeInteger(unitsPerSecond) || unitsPerSecond <= 0) {\n\t\t\tthrow new RangeError(`invalid timescale: ${unitsPerSecond}`);\n\t\t}\n\t\treturn unitsPerSecond as Timescale;\n\t},\n\t{\n\t\t/** One unit per second. */\n\t\tSECOND: 1 as Timescale,\n\t\t/** 1,000 units per second. */\n\t\tMILLI: 1_000 as Timescale,\n\t\t/** 1,000,000 units per second. */\n\t\tMICRO: 1_000_000 as Timescale,\n\t\t/** 1,000,000,000 units per second. */\n\t\tNANO: 1_000_000_000 as Timescale,\n\t},\n);\n\nfunction assertTimestampValue(value: number): void {\n\tif (!Number.isFinite(value) || value < 0 || value > Number.MAX_SAFE_INTEGER) {\n\t\tthrow new RangeError(`invalid timestamp: ${value}`);\n\t}\n}\n\n/**\n * A presentation timestamp: a raw value in a given {@link Timescale}.\n *\n * Mirrors the Rust `Timestamp`. Unlike the bare `Milli`/`Micro` aliases it carries its\n * own scale, so a track can pick its units and conversions can't silently mix them up.\n *\n * The value must be finite and in `[0, Number.MAX_SAFE_INTEGER]`. Fractions are allowed\n * (`performance.now()`, scale conversion). Encoding rounds to the nearest integer at the\n * track timescale. Integer timestamps are exact through `2^53 - 1` units; this package\n * does not use BigInt for timestamps. {@link Timestamp.as} also refuses a converted\n * value that leaves that range, so a legal source timestamp cannot become an unencodable\n * wire timestamp after a scale change.\n */\nexport class Timestamp {\n\t/** The raw value, in `scale` units. */\n\treadonly value: number;\n\t/** Units per second the {@link value} is measured in. */\n\treadonly scale: Timescale;\n\n\t/** Build a timestamp of `value` units at `scale`. */\n\tconstructor(value: number, scale: Timescale) {\n\t\tassertTimestampValue(value);\n\t\tthis.value = value;\n\t\tthis.scale = Timescale(scale);\n\t}\n\n\t/** Monotonic now (`performance.now()`, milliseconds since page load), not wall-clock time. */\n\tstatic now(): Timestamp {\n\t\treturn new Timestamp(performance.now(), Timescale.MILLI);\n\t}\n\n\t/** A timestamp of `ms` milliseconds. */\n\tstatic fromMillis(ms: number): Timestamp {\n\t\treturn new Timestamp(ms, Timescale.MILLI);\n\t}\n\n\t/** A timestamp of `us` microseconds. */\n\tstatic fromMicros(us: number): Timestamp {\n\t\treturn new Timestamp(us, Timescale.MICRO);\n\t}\n\n\t/** This timestamp's value re-expressed at `scale`; throws if the result is not in the safe range. */\n\tas(scale: Timescale): number {\n\t\tconst dest = Timescale(scale);\n\t\tconst converted = dest === this.scale ? this.value : (this.value * dest) / this.scale;\n\t\tassertTimestampValue(converted);\n\t\treturn converted;\n\t}\n\n\t/** The value in milliseconds. */\n\tasMillis(): number {\n\t\treturn this.as(Timescale.MILLI);\n\t}\n\n\t/** The value in microseconds. */\n\tasMicros(): number {\n\t\treturn this.as(Timescale.MICRO);\n\t}\n}\n\n/** A duration in seconds, branded so it can't be mixed with other units. */\nexport type Second = number & { readonly _brand: \"second\" };\n\n/** Constructors, conversions, and arithmetic for {@link Second} values. */\n// Calling `Second(x)` brands a raw number as seconds. See the `Nano` note: this asserts the unit\n// rather than converting, so use `fromNano`/`fromMicro`/`fromMilli` to convert from another unit.\nexport const Second = Object.assign((value: number): Second => value as Second, {\n\tzero: 0 as Second,\n\tfromNano: (ns: Nano): Second => (ns / 1_000_000_000) as Second,\n\tfromMicro: (us: Micro): Second => (us / 1_000_000) as Second,\n\tfromMilli: (ms: Milli): Second => (ms / 1_000) as Second,\n\ttoNano: (s: Second): Nano => (s * 1_000_000_000) as Nano,\n\ttoMicro: (s: Second): Micro => (s * 1_000_000) as Micro,\n\ttoMilli: (s: Second): Milli => (s * 1_000) as Milli,\n\tnow: (): Second => (performance.now() / 1_000) as Second,\n\tadd: (a: Second, b: Second): Second => (a + b) as Second,\n\tsub: (a: Second, b: Second): Second => (a - b) as Second,\n\tmul: (a: Second, b: number): Second => (a * b) as Second,\n\tdiv: (a: Second, b: number): Second => (a / b) as Second,\n\tmax: (a: Second, b: Second): Second => Math.max(a, b) as Second,\n\tmin: (a: Second, b: Second): Second => Math.min(a, b) as Second,\n});\n"]}
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAK5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CACrC,CAAC,cAAsB,EAAa,EAAE;IACrC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,cAAc,IAAI,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,UAAU,CAAC,sBAAsB,cAAc,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,cAA2B,CAAC;AACpC,CAAC,EACD;IACC,2BAA2B;IAC3B,MAAM,EAAE,CAAc;IACtB,8BAA8B;IAC9B,KAAK,EAAE,KAAkB;IACzB,kCAAkC;IAClC,KAAK,EAAE,SAAsB;IAC7B,sCAAsC;IACtC,IAAI,EAAE,aAA0B;CAChC,CACD,CAAC;AAEF,SAAS,oBAAoB,CAAC,KAAa;IAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC7E,MAAM,IAAI,UAAU,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,SAAS;IACrB,4EAA4E;IACnE,KAAK,CAAS;IACvB,uFAAuF;IAC9E,KAAK,CAAwB;IAEtC,qDAAqD;IACrD,YAAY,KAAa,EAAE,KAAgB;QAC1C,o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AAmC,CAAC,CAAC;IAC7F,OAAO,SAAS,CAAC,KAAK,CAAC;AACxB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CAAC,SAAoB,EAAE,KAAgB;IAC7D,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/B,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACvD,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACrD,OAAO,QAAQ,CAAC,CAAC,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACnF,CAAC;AAED,2FAA2F;AAC3F,0DAA0D;AAC1D,SAAS,MAAM,CAAC,KAAa;IAC5B,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,KAAK,IAAI,CAAC,CAAC;QACX,QAAQ,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC","sourcesContent":["/**\n * {@link Timescale} and {@link Timestamp} for presentation timing.\n *\n * Durations and instants live in `@moq/clock`.\n *\n * @module\n */\nimport { Instant, now } from \"@moq/clock\";\nimport { StreamCode, Stream as StreamError } from \"./error.ts\";\nimport { toNumber } from \"./util/bigint.ts\";\n\n/** Units per second for a {@link Timestamp}'s value, e.g. `1000` for milliseconds. */\nexport type Timescale = number & { readonly _brand: \"timescale\" };\n\n/**\n * Named timescales and a checked constructor.\n *\n * Units per second must be a safe integer ≥ 1. JavaScript numbers are exact only\n * through `Number.MAX_SAFE_INTEGER` (`2^53 - 1`); the wire varint range goes\n * to `2^62 - 1`, which Rust accepts and this constructor refuses.\n */\nexport const Timescale = Object.assign(\n\t(unitsPerSecond: number): Timescale => {\n\t\tif (!Number.isSafeInteger(unitsPerSecond) || unitsPerSecond <= 0) {\n\t\t\tthrow new RangeError(`invalid timescale: ${unitsPerSecond}`);\n\t\t}\n\t\treturn unitsPerSecond as Timescale;\n\t},\n\t{\n\t\t/** One unit per second. */\n\t\tSECOND: 1 as Timescale,\n\t\t/** 1,000 units per second. */\n\t\tMILLI: 1_000 as Timescale,\n\t\t/** 1,000,000 units per second. */\n\t\tMICRO: 1_000_000 as Timescale,\n\t\t/** 1,000,000,000 units per second. */\n\t\tNANO: 1_000_000_000 as Timescale,\n\t},\n);\n\nfunction assertTimestampValue(value: number): void {\n\tif (!Number.isFinite(value) || value < 0 || value > Number.MAX_SAFE_INTEGER) {\n\t\tthrow new RangeError(`invalid timestamp: ${value}`);\n\t}\n}\n\n/**\n * A presentation timestamp: a raw value in a given {@link Timescale}, or a scale-less track's\n * group key.\n *\n * Mirrors the Rust `Timestamp`. Unlike a `@moq/clock` `Duration` it carries its\n * own scale, so a track can pick its units and conversions can't silently mix them up.\n *\n * A scaled value must be finite and in `[0, Number.MAX_SAFE_INTEGER]`. Fractions are allowed\n * ({@link Timestamp.now}, scale conversion). Encoding rounds down to an integer at the\n * track timescale, as the Rust `Timestamp::convert` does. Integer timestamps are exact through `2^53 - 1` units; this package\n * does not use BigInt for timestamps. {@link Timestamp.as} also refuses a converted\n * value that leaves that range, so a legal source timestamp cannot become an unencodable\n * wire timestamp after a scale change.\n *\n * A scale-less track has no time: each frame's timestamp is {@link Timestamp.unscaled}, whose\n * {@link value} is its group's key and whose {@link scale} is `undefined`, as Rust's\n * `Timestamp::unscaled(key)`. A key past `Number.MAX_SAFE_INTEGER` is refused, so such a group's\n * frames cannot be read here. Anything that needs a scale ({@link as}, {@link asMillis},\n * {@link asMicros}) throws a `RangeError` on one, and {@link isBefore} orders it against no\n * scaled timestamp.\n */\nexport class Timestamp {\n\t/** The raw value in `scale` units, or an unscaled timestamp's group key. */\n\treadonly value: number;\n\t/** Units per second the {@link value} is measured in, or `undefined` when unscaled. */\n\treadonly scale: Timescale | undefined;\n\n\t/** Build a timestamp of `value` units at `scale`. */\n\tconstructor(value: number, scale: Timescale) {\n\t\tassertTimestampValue(value);\n\t\tthis.value = value;\n\t\tthis.scale = Timescale(scale);\n\t}\n\n\t/**\n\t * A scale-less track's timestamp: `key` is its group's key (or a datagram's key), with no\n\t * time. Throws a `RangeError` past `Number.MAX_SAFE_INTEGER`, which a `number` cannot hold.\n\t */\n\tstatic unscaled(key: bigint | number): Timestamp {\n\t\tif (typeof key === \"bigint\") {\n\t\t\tif (key < 0n || key > BigInt(Number.MAX_SAFE_INTEGER))\n\t\t\t\tthrow new RangeError(`invalid timestamp key: ${key}`);\n\t\t\tkey = Number(key);\n\t\t}\n\t\tif (!Number.isSafeInteger(key) || key < 0) throw new RangeError(`invalid timestamp key: ${key}`);\n\t\tconst timestamp = new Timestamp(key, Timescale.SECOND);\n\t\t// Set here rather than through the constructor, so `new Timestamp` only ever builds a scaled one.\n\t\t(timestamp as { scale: Timescale | undefined }).scale = undefined;\n\t\treturn timestamp;\n\t}\n\n\t/** The installed clock's monotonic instant in milliseconds, not wall-clock time. */\n\tstatic now(): Timestamp {\n\t\treturn new Timestamp(now().since(Instant.ZERO).asMillis(), Timescale.MILLI);\n\t}\n\n\t/** A timestamp of `secs` seconds. */\n\tstatic fromSecs(secs: number): Timestamp {\n\t\treturn new Timestamp(secs, Timescale.SECOND);\n\t}\n\n\t/** A timestamp of `ms` milliseconds. */\n\tstatic fromMillis(ms: number): Timestamp {\n\t\treturn new Timestamp(ms, Timescale.MILLI);\n\t}\n\n\t/** A timestamp of `us` microseconds. */\n\tstatic fromMicros(us: number): Timestamp {\n\t\treturn new Timestamp(us, Timescale.MICRO);\n\t}\n\n\t/** A timestamp of `ns` nanoseconds. */\n\tstatic fromNanos(ns: number): Timestamp {\n\t\treturn new Timestamp(ns, Timescale.NANO);\n\t}\n\n\t/**\n\t * This timestamp's value re-expressed at `scale`; throws a `RangeError` if it is unscaled or\n\t * the result is not in the safe range.\n\t */\n\tas(scale: Timescale): number {\n\t\tconst dest = Timescale(scale);\n\t\tconst from = scaled(this);\n\t\tconst converted = dest === from ? this.value : (this.value * dest) / from;\n\t\tassertTimestampValue(converted);\n\t\treturn converted;\n\t}\n\n\t/** The value in seconds; throws a `RangeError` if it is unscaled. */\n\tasSecs(): number {\n\t\treturn this.as(Timescale.SECOND);\n\t}\n\n\t/** The value in milliseconds; throws a `RangeError` if it is unscaled. */\n\tasMillis(): number {\n\t\treturn this.as(Timescale.MILLI);\n\t}\n\n\t/** The value in microseconds; throws a `RangeError` if it is unscaled. */\n\tasMicros(): number {\n\t\treturn this.as(Timescale.MICRO);\n\t}\n\n\t/** The value in nanoseconds; throws a `RangeError` if it is unscaled or past the safe range. */\n\tasNanos(): number {\n\t\treturn this.as(Timescale.NANO);\n\t}\n\n\t/**\n\t * Whether this presents before `other`, whatever their scales. Two unscaled timestamps order\n\t * by key; a scaled and an unscaled one don't order, so neither is before the other.\n\t */\n\tisBefore(other: Timestamp): boolean {\n\t\tif (this.scale === undefined || other.scale === undefined) {\n\t\t\treturn this.scale === other.scale && this.value < other.value;\n\t\t}\n\t\tif (this.scale === other.scale) return this.value < other.value;\n\t\t// Cross-scale products can pass 2^53, so they are compared exactly in BigInt, as Rust does in u128.\n\t\tconst [ma, ea] = binary(this.value);\n\t\tconst [mb, eb] = binary(other.value);\n\t\tconst e = Math.min(ea, eb);\n\t\treturn (ma * BigInt(scaled(other))) << BigInt(ea - e) < (mb * BigInt(scaled(this))) << BigInt(eb - e);\n\t}\n}\n\n/**\n * A received frame's timestamp: the one its wire carried, or on a scale-less track, which\n * carries none, {@link Timestamp.unscaled} at its group's `key` (a datagram's key). A key past\n * `Number.MAX_SAFE_INTEGER` is a valid group this side cannot hold, so it fails only that\n * stream, with `NotSupported`. Mirrors Rust's `Timestamp::received`.\n *\n * @internal\n */\nexport function received(timestamp: Timestamp | undefined, key: bigint): Timestamp {\n\tif (timestamp) return timestamp;\n\tif (key > BigInt(Number.MAX_SAFE_INTEGER)) {\n\t\tthrow new StreamError(StreamCode.NotSupported, { message: `no unscaled timestamp holds key ${key}` });\n\t}\n\treturn Timestamp.unscaled(key);\n}\n\n// `timestamp`'s scale, or a `RangeError` when unscaled: a group key has no time to convert.\nfunction scaled(timestamp: Timestamp): Timescale {\n\tif (timestamp.scale === undefined) throw new RangeError(\"an unscaled timestamp has no time\");\n\treturn timestamp.scale;\n}\n\n/**\n * `timestamp`'s value at `scale`, rounded down exactly, as Rust's integer `Timestamp::convert`.\n *\n * A double is a dyadic rational, so the conversion runs in BigInt with no rounding before the\n * floor: an aligned value keeps it (4611686021000000 ns is 4611686021 ms, where `as` gives\n * 4611686020.999999), and one instant gives one result whatever scale it came from. Throws a\n * `RangeError` past the safe integer range, or for an unscaled timestamp.\n *\n * @internal\n */\nexport function floorAt(timestamp: Timestamp, scale: Timescale): number {\n\tconst from = scaled(timestamp);\n\tif (from === scale) return Math.floor(timestamp.value);\n\tconst [mantissa, exponent] = binary(timestamp.value);\n\treturn toNumber((mantissa * BigInt(scale)) / (BigInt(from) << BigInt(-exponent)));\n}\n\n// A finite, non-negative `value` exactly as `mantissa * 2^exponent`. Doubling is exact, so\n// a fraction becomes an integer within its binary digits.\nfunction binary(value: number): [bigint, number] {\n\tlet exponent = 0;\n\twhile (!Number.isInteger(value)) {\n\t\tvalue *= 2;\n\t\texponent--;\n\t}\n\treturn [BigInt(value), exponent];\n}\n"]}
|
package/timed.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A value paired with its frame's timestamp.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { Timestamp } from "./time.ts";
|
|
7
|
+
/**
|
|
8
|
+
* A value read from a track, and its frame's timestamp.
|
|
9
|
+
*
|
|
10
|
+
* Writes take the same pair as two arguments, `(value, at)`. On a timed track `at` is when the
|
|
11
|
+
* value was captured. A scale-less track has no time, so there it is {@link Timestamp.unscaled}
|
|
12
|
+
* at a group key: a write that opens a group starts it at that key, which must pass every group
|
|
13
|
+
* the track holds.
|
|
14
|
+
*/
|
|
15
|
+
export interface Timed<T> {
|
|
16
|
+
/** The value. */
|
|
17
|
+
value: T;
|
|
18
|
+
/** The frame's timestamp: its capture time, or its group key on a scale-less track. */
|
|
19
|
+
at: Timestamp;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=timed.d.ts.map
|
package/timed.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timed.d.ts","sourceRoot":"","sources":["../src/timed.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC;IACvB,iBAAiB;IACjB,KAAK,EAAE,CAAC,CAAC;IACT,uFAAuF;IACvF,EAAE,EAAE,SAAS,CAAC;CACd"}
|
package/timed.js
ADDED
package/timed.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timed.js","sourceRoot":"","sources":["../src/timed.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A value paired with its frame's timestamp.\n *\n * @module\n */\nimport type { Timestamp } from \"./time.ts\";\n\n/**\n * A value read from a track, and its frame's timestamp.\n *\n * Writes take the same pair as two arguments, `(value, at)`. On a timed track `at` is when the\n * value was captured. A scale-less track has no time, so there it is {@link Timestamp.unscaled}\n * at a group key: a write that opens a group starts it at that key, which must pass every group\n * the track holds.\n */\nexport interface Timed<T> {\n\t/** The value. */\n\tvalue: T;\n\t/** The frame's timestamp: its capture time, or its group key on a scale-less track. */\n\tat: Timestamp;\n}\n"]}
|