ic-mops 0.8.5 → 0.8.7
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/package.json +3 -1
- package/.mops/base@0.7.4/LICENSE +0 -208
- package/.mops/base@0.7.4/README.md +0 -64
- package/.mops/base@0.7.4/mops.toml +0 -5
- package/.mops/base@0.7.4/src/Array.mo +0 -686
- package/.mops/base@0.7.4/src/AssocList.mo +0 -203
- package/.mops/base@0.7.4/src/Blob.mo +0 -55
- package/.mops/base@0.7.4/src/Bool.mo +0 -44
- package/.mops/base@0.7.4/src/Buffer.mo +0 -1937
- package/.mops/base@0.7.4/src/CertifiedData.mo +0 -29
- package/.mops/base@0.7.4/src/Char.mo +0 -67
- package/.mops/base@0.7.4/src/Debug.mo +0 -15
- package/.mops/base@0.7.4/src/Deque.mo +0 -75
- package/.mops/base@0.7.4/src/Error.mo +0 -41
- package/.mops/base@0.7.4/src/ExperimentalCycles.mo +0 -51
- package/.mops/base@0.7.4/src/ExperimentalInternetComputer.mo +0 -36
- package/.mops/base@0.7.4/src/ExperimentalStableMemory.mo +0 -121
- package/.mops/base@0.7.4/src/Float.mo +0 -150
- package/.mops/base@0.7.4/src/Func.mo +0 -38
- package/.mops/base@0.7.4/src/Hash.mo +0 -83
- package/.mops/base@0.7.4/src/HashMap.mo +0 -229
- package/.mops/base@0.7.4/src/Heap.mo +0 -113
- package/.mops/base@0.7.4/src/Int.mo +0 -150
- package/.mops/base@0.7.4/src/Int16.mo +0 -159
- package/.mops/base@0.7.4/src/Int32.mo +0 -160
- package/.mops/base@0.7.4/src/Int64.mo +0 -161
- package/.mops/base@0.7.4/src/Int8.mo +0 -160
- package/.mops/base@0.7.4/src/Iter.mo +0 -220
- package/.mops/base@0.7.4/src/IterType.mo +0 -7
- package/.mops/base@0.7.4/src/List.mo +0 -433
- package/.mops/base@0.7.4/src/Nat.mo +0 -75
- package/.mops/base@0.7.4/src/Nat16.mo +0 -146
- package/.mops/base@0.7.4/src/Nat32.mo +0 -146
- package/.mops/base@0.7.4/src/Nat64.mo +0 -146
- package/.mops/base@0.7.4/src/Nat8.mo +0 -146
- package/.mops/base@0.7.4/src/None.mo +0 -19
- package/.mops/base@0.7.4/src/Option.mo +0 -160
- package/.mops/base@0.7.4/src/Order.mo +0 -46
- package/.mops/base@0.7.4/src/Prelude.mo +0 -33
- package/.mops/base@0.7.4/src/Principal.mo +0 -58
- package/.mops/base@0.7.4/src/RBTree.mo +0 -218
- package/.mops/base@0.7.4/src/Random.mo +0 -188
- package/.mops/base@0.7.4/src/Result.mo +0 -210
- package/.mops/base@0.7.4/src/Stack.mo +0 -40
- package/.mops/base@0.7.4/src/Text.mo +0 -615
- package/.mops/base@0.7.4/src/Time.mo +0 -37
- package/.mops/base@0.7.4/src/Trie.mo +0 -1200
- package/.mops/base@0.7.4/src/TrieMap.mo +0 -180
- package/.mops/base@0.7.4/src/TrieSet.mo +0 -97
- package/.mops/base@0.8.3/LICENSE +0 -208
- package/.mops/base@0.8.3/README.md +0 -64
- package/.mops/base@0.8.3/mops.toml +0 -6
- package/.mops/base@0.8.3/src/Array.mo +0 -717
- package/.mops/base@0.8.3/src/AssocList.mo +0 -404
- package/.mops/base@0.8.3/src/Blob.mo +0 -212
- package/.mops/base@0.8.3/src/Bool.mo +0 -44
- package/.mops/base@0.8.3/src/Buffer.mo +0 -2660
- package/.mops/base@0.8.3/src/CertifiedData.mo +0 -53
- package/.mops/base@0.8.3/src/Char.mo +0 -65
- package/.mops/base@0.8.3/src/Debug.mo +0 -56
- package/.mops/base@0.8.3/src/Deque.mo +0 -243
- package/.mops/base@0.8.3/src/Error.mo +0 -68
- package/.mops/base@0.8.3/src/ExperimentalCycles.mo +0 -151
- package/.mops/base@0.8.3/src/ExperimentalInternetComputer.mo +0 -60
- package/.mops/base@0.8.3/src/ExperimentalStableMemory.mo +0 -348
- package/.mops/base@0.8.3/src/Float.mo +0 -843
- package/.mops/base@0.8.3/src/Func.mo +0 -46
- package/.mops/base@0.8.3/src/Hash.mo +0 -82
- package/.mops/base@0.8.3/src/HashMap.mo +0 -457
- package/.mops/base@0.8.3/src/Heap.mo +0 -233
- package/.mops/base@0.8.3/src/Int.mo +0 -365
- package/.mops/base@0.8.3/src/Int16.mo +0 -521
- package/.mops/base@0.8.3/src/Int32.mo +0 -522
- package/.mops/base@0.8.3/src/Int64.mo +0 -522
- package/.mops/base@0.8.3/src/Int8.mo +0 -522
- package/.mops/base@0.8.3/src/Iter.mo +0 -227
- package/.mops/base@0.8.3/src/IterType.mo +0 -7
- package/.mops/base@0.8.3/src/List.mo +0 -930
- package/.mops/base@0.8.3/src/Nat.mo +0 -305
- package/.mops/base@0.8.3/src/Nat16.mo +0 -144
- package/.mops/base@0.8.3/src/Nat32.mo +0 -144
- package/.mops/base@0.8.3/src/Nat64.mo +0 -144
- package/.mops/base@0.8.3/src/Nat8.mo +0 -144
- package/.mops/base@0.8.3/src/None.mo +0 -19
- package/.mops/base@0.8.3/src/Option.mo +0 -154
- package/.mops/base@0.8.3/src/Order.mo +0 -46
- package/.mops/base@0.8.3/src/Prelude.mo +0 -33
- package/.mops/base@0.8.3/src/Principal.mo +0 -249
- package/.mops/base@0.8.3/src/RBTree.mo +0 -681
- package/.mops/base@0.8.3/src/Random.mo +0 -270
- package/.mops/base@0.8.3/src/Result.mo +0 -209
- package/.mops/base@0.8.3/src/Stack.mo +0 -93
- package/.mops/base@0.8.3/src/Text.mo +0 -761
- package/.mops/base@0.8.3/src/Time.mo +0 -36
- package/.mops/base@0.8.3/src/Timer.mo +0 -62
- package/.mops/base@0.8.3/src/Trie.mo +0 -1603
- package/.mops/base@0.8.3/src/TrieMap.mo +0 -392
- package/.mops/base@0.8.3/src/TrieSet.mo +0 -148
- package/network.txt +0 -1
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/// System time
|
|
2
|
-
|
|
3
|
-
import Prim "mo:⛔";
|
|
4
|
-
module {
|
|
5
|
-
|
|
6
|
-
/// System time is represent as nanoseconds since 1970-01-01.
|
|
7
|
-
public type Time = Int;
|
|
8
|
-
|
|
9
|
-
/// Current system time given as nanoseconds since 1970-01-01. The system guarantees that:
|
|
10
|
-
///
|
|
11
|
-
/// * the time, as observed by the canister smart contract, is monotonically increasing, even across canister upgrades.
|
|
12
|
-
/// * within an invocation of one entry point, the time is constant.
|
|
13
|
-
///
|
|
14
|
-
/// The system times of different canisters are unrelated, and calls from one canister to another may appear to travel "backwards in time"
|
|
15
|
-
///
|
|
16
|
-
/// Note: While an implementation will likely try to keep the system time close to the real time, this is not formally guaranteed.
|
|
17
|
-
public let now : () -> Time = func() : Int = Prim.nat64ToNat(Prim.time());
|
|
18
|
-
///
|
|
19
|
-
/// The following example illustrates using the system time:
|
|
20
|
-
///
|
|
21
|
-
/// ```motoko
|
|
22
|
-
/// import Int = "mo:base/Int";
|
|
23
|
-
/// import Time = "mo:base/Time";
|
|
24
|
-
///
|
|
25
|
-
/// actor {
|
|
26
|
-
/// var lastTime = Time.now();
|
|
27
|
-
/// public func greet(name : Text) : async Text {
|
|
28
|
-
/// let now = Time.now();
|
|
29
|
-
/// let elapsedSeconds = (now - lastTime) / 1000_000_000;
|
|
30
|
-
/// lastTime := now;
|
|
31
|
-
/// return "Hello, " # name # "!" #
|
|
32
|
-
/// " I was last called " # Int.toText(elapsedSeconds) # " seconds ago";
|
|
33
|
-
/// };
|
|
34
|
-
/// };
|
|
35
|
-
/// ```
|
|
36
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/// Timers for one-off or periodic tasks.
|
|
2
|
-
///
|
|
3
|
-
/// Note: If `moc` is invoked with `-no-timer`, the importing will fail.
|
|
4
|
-
/// Note: The resolution of the timers is in the order of the block rate,
|
|
5
|
-
/// so durations should be chosen well above that. For frequent
|
|
6
|
-
/// canister wake-ups the heatbeat mechanism should be considered.
|
|
7
|
-
|
|
8
|
-
import { setTimer = setTimerNano; cancelTimer = cancel } = "mo:⛔";
|
|
9
|
-
import { fromIntWrap } = "Nat64";
|
|
10
|
-
|
|
11
|
-
module {
|
|
12
|
-
|
|
13
|
-
public type Duration = { #seconds : Nat; #nanoseconds : Nat };
|
|
14
|
-
public type TimerId = Nat;
|
|
15
|
-
|
|
16
|
-
func toNanos(d : Duration) : Nat64 =
|
|
17
|
-
fromIntWrap (switch d {
|
|
18
|
-
case (#seconds s) s * 1000_000_000;
|
|
19
|
-
case (#nanoseconds ns) ns });
|
|
20
|
-
|
|
21
|
-
/// Installs a one-off timer that upon expiration after given duration `d`
|
|
22
|
-
/// executes the future `job()`.
|
|
23
|
-
///
|
|
24
|
-
/// ```motoko no-repl
|
|
25
|
-
/// let now = Time.now();
|
|
26
|
-
/// let thirtyMinutes = 1_000_000_000 * 60 * 30;
|
|
27
|
-
/// func alarmUser() : async () {
|
|
28
|
-
/// // ...
|
|
29
|
-
/// };
|
|
30
|
-
/// appt.reminder = setTimer(#nanoseconds (Int.abs(appt.when - now - thirtyMinutes)), alarmUser);
|
|
31
|
-
/// ```
|
|
32
|
-
public func setTimer(d : Duration, job : () -> async ()) : TimerId {
|
|
33
|
-
setTimerNano(toNanos d, false, job)
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/// Installs a recurring timer that upon expiration after given duration `d`
|
|
37
|
-
/// executes the future `job()` and reinserts itself for another expiration.
|
|
38
|
-
///
|
|
39
|
-
/// Note: A duration of 0 will only expire once.
|
|
40
|
-
///
|
|
41
|
-
/// ```motoko no-repl
|
|
42
|
-
/// func checkAndWaterPlants() : async () {
|
|
43
|
-
/// // ...
|
|
44
|
-
/// };
|
|
45
|
-
/// let daily = recurringTimer(#seconds (24 * 60 * 60), checkAndWaterPlants);
|
|
46
|
-
/// ```
|
|
47
|
-
public func recurringTimer(d : Duration, job : () -> async ()) : TimerId {
|
|
48
|
-
setTimerNano(toNanos d, true, job)
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/// Cancels a still active timer with `(id : TimerId)`. For expired timers
|
|
52
|
-
/// and not recognised `id`s nothing happens.
|
|
53
|
-
///
|
|
54
|
-
/// ```motoko no-repl
|
|
55
|
-
/// func deleteAppt(appt : Appointment) {
|
|
56
|
-
/// cancelTimer (appt.reminder);
|
|
57
|
-
/// // ...
|
|
58
|
-
/// };
|
|
59
|
-
/// ```
|
|
60
|
-
public let cancelTimer : TimerId -> () = cancel;
|
|
61
|
-
|
|
62
|
-
}
|