@shd101wyy/yo 0.1.25 → 0.1.27

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.
Files changed (194) hide show
  1. package/.github/skills/yo-async-effects/SKILL.md +4 -4
  2. package/.github/skills/yo-async-effects/async-effects-recipes.md +40 -40
  3. package/.github/skills/yo-core-patterns/SKILL.md +1 -1
  4. package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +30 -26
  5. package/.github/skills/yo-project-workflow/SKILL.md +6 -3
  6. package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +34 -11
  7. package/.github/skills/yo-syntax/SKILL.md +7 -6
  8. package/.github/skills/yo-syntax/syntax-cheatsheet.md +78 -60
  9. package/.github/skills/yo-wasm-integration/wasm-integration-cheatsheet.md +3 -3
  10. package/README.md +10 -8
  11. package/out/cjs/index.cjs +583 -567
  12. package/out/cjs/yo-cli.cjs +664 -632
  13. package/out/cjs/yo-lsp.cjs +510 -485
  14. package/out/esm/index.mjs +538 -522
  15. package/out/types/src/codegen/codegen-c.d.ts +2 -2
  16. package/out/types/src/codegen/functions/collection.d.ts +2 -2
  17. package/out/types/src/codegen/functions/context.d.ts +3 -2
  18. package/out/types/src/codegen/types/collection.d.ts +2 -2
  19. package/out/types/src/codegen/utils/index.d.ts +3 -1
  20. package/out/types/src/doc/builder.d.ts +2 -2
  21. package/out/types/src/evaluator/calls/closure-type.d.ts +2 -2
  22. package/out/types/src/evaluator/calls/record-type.d.ts +11 -0
  23. package/out/types/src/evaluator/context.d.ts +8 -9
  24. package/out/types/src/evaluator/index.d.ts +3 -3
  25. package/out/types/src/evaluator/types/record.d.ts +14 -0
  26. package/out/types/src/evaluator/types/validation.d.ts +2 -2
  27. package/out/types/src/evaluator/values/anonymous-module.d.ts +5 -5
  28. package/out/types/src/evaluator/values/impl.d.ts +1 -1
  29. package/out/types/src/expr.d.ts +1 -4
  30. package/out/types/src/formatter.d.ts +11 -0
  31. package/out/types/src/function-value.d.ts +1 -1
  32. package/out/types/src/lsp/document-manager.d.ts +1 -1
  33. package/out/types/src/lsp/formatting.d.ts +2 -0
  34. package/out/types/src/module-manager.d.ts +3 -3
  35. package/out/types/src/tests/formatter.test.d.ts +1 -0
  36. package/out/types/src/types/creators.d.ts +3 -4
  37. package/out/types/src/types/definitions.d.ts +8 -19
  38. package/out/types/src/types/guards.d.ts +3 -3
  39. package/out/types/src/types/tags.d.ts +0 -1
  40. package/out/types/src/types/utils.d.ts +1 -1
  41. package/out/types/src/value-tag.d.ts +0 -1
  42. package/out/types/src/value.d.ts +6 -13
  43. package/out/types/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +1 -1
  45. package/std/alg/hash.yo +13 -21
  46. package/std/allocator.yo +25 -40
  47. package/std/async.yo +3 -7
  48. package/std/build.yo +105 -151
  49. package/std/cli/arg_parser.yo +184 -169
  50. package/std/collections/array_list.yo +350 -314
  51. package/std/collections/btree_map.yo +142 -131
  52. package/std/collections/deque.yo +132 -128
  53. package/std/collections/hash_map.yo +542 -566
  54. package/std/collections/hash_set.yo +623 -687
  55. package/std/collections/linked_list.yo +275 -293
  56. package/std/collections/ordered_map.yo +113 -85
  57. package/std/collections/priority_queue.yo +73 -73
  58. package/std/crypto/md5.yo +191 -95
  59. package/std/crypto/random.yo +56 -64
  60. package/std/crypto/sha256.yo +151 -107
  61. package/std/encoding/base64.yo +87 -81
  62. package/std/encoding/hex.yo +43 -50
  63. package/std/encoding/html.yo +56 -81
  64. package/std/encoding/html_char_utils.yo +7 -13
  65. package/std/encoding/html_entities.yo +2248 -2253
  66. package/std/encoding/json.yo +316 -224
  67. package/std/encoding/punycode.yo +86 -116
  68. package/std/encoding/toml.yo +67 -66
  69. package/std/encoding/utf16.yo +37 -44
  70. package/std/env.yo +62 -91
  71. package/std/error.yo +12 -20
  72. package/std/fmt/display.yo +5 -9
  73. package/std/fmt/index.yo +8 -14
  74. package/std/fmt/to_string.yo +330 -315
  75. package/std/fmt/writer.yo +58 -87
  76. package/std/fs/dir.yo +83 -102
  77. package/std/fs/file.yo +147 -180
  78. package/std/fs/metadata.yo +45 -78
  79. package/std/fs/temp.yo +55 -65
  80. package/std/fs/types.yo +27 -40
  81. package/std/fs/walker.yo +53 -68
  82. package/std/gc.yo +5 -8
  83. package/std/glob.yo +30 -43
  84. package/std/http/client.yo +107 -120
  85. package/std/http/http.yo +106 -96
  86. package/std/http/index.yo +4 -6
  87. package/std/imm/list.yo +88 -93
  88. package/std/imm/map.yo +528 -464
  89. package/std/imm/set.yo +52 -57
  90. package/std/imm/sorted_map.yo +340 -286
  91. package/std/imm/sorted_set.yo +57 -63
  92. package/std/imm/string.yo +404 -345
  93. package/std/imm/vec.yo +173 -181
  94. package/std/io/reader.yo +3 -6
  95. package/std/io/writer.yo +4 -8
  96. package/std/libc/assert.yo +5 -9
  97. package/std/libc/ctype.yo +32 -22
  98. package/std/libc/dirent.yo +26 -25
  99. package/std/libc/errno.yo +164 -90
  100. package/std/libc/fcntl.yo +52 -45
  101. package/std/libc/float.yo +66 -44
  102. package/std/libc/limits.yo +42 -33
  103. package/std/libc/math.yo +53 -82
  104. package/std/libc/signal.yo +72 -47
  105. package/std/libc/stdatomic.yo +217 -188
  106. package/std/libc/stdint.yo +5 -29
  107. package/std/libc/stdio.yo +5 -29
  108. package/std/libc/stdlib.yo +32 -39
  109. package/std/libc/string.yo +5 -23
  110. package/std/libc/sys/stat.yo +58 -56
  111. package/std/libc/time.yo +5 -19
  112. package/std/libc/unistd.yo +5 -20
  113. package/std/libc/wctype.yo +6 -9
  114. package/std/libc/windows.yo +26 -30
  115. package/std/log.yo +41 -55
  116. package/std/net/addr.yo +102 -97
  117. package/std/net/dns.yo +27 -28
  118. package/std/net/errors.yo +50 -49
  119. package/std/net/tcp.yo +113 -124
  120. package/std/net/udp.yo +55 -66
  121. package/std/os/env.yo +35 -33
  122. package/std/os/signal.yo +15 -25
  123. package/std/path.yo +276 -311
  124. package/std/prelude.yo +6316 -4333
  125. package/std/process/command.yo +87 -103
  126. package/std/process/index.yo +12 -31
  127. package/std/regex/compiler.yo +196 -95
  128. package/std/regex/flags.yo +58 -39
  129. package/std/regex/index.yo +157 -173
  130. package/std/regex/match.yo +20 -31
  131. package/std/regex/node.yo +134 -152
  132. package/std/regex/parser.yo +283 -259
  133. package/std/regex/unicode.yo +172 -202
  134. package/std/regex/vm.yo +155 -171
  135. package/std/string/index.yo +5 -7
  136. package/std/string/rune.yo +45 -55
  137. package/std/string/string.yo +937 -964
  138. package/std/string/string_builder.yo +94 -104
  139. package/std/string/unicode.yo +46 -64
  140. package/std/sync/channel.yo +72 -73
  141. package/std/sync/cond.yo +31 -36
  142. package/std/sync/mutex.yo +30 -32
  143. package/std/sync/once.yo +13 -16
  144. package/std/sync/rwlock.yo +26 -31
  145. package/std/sync/waitgroup.yo +20 -25
  146. package/std/sys/advise.yo +16 -24
  147. package/std/sys/bufio/buf_reader.yo +77 -93
  148. package/std/sys/bufio/buf_writer.yo +52 -65
  149. package/std/sys/clock.yo +4 -9
  150. package/std/sys/constants.yo +77 -61
  151. package/std/sys/copy.yo +4 -10
  152. package/std/sys/dir.yo +26 -43
  153. package/std/sys/dns.yo +41 -61
  154. package/std/sys/errors.yo +95 -103
  155. package/std/sys/events.yo +45 -57
  156. package/std/sys/externs.yo +319 -267
  157. package/std/sys/fallocate.yo +7 -11
  158. package/std/sys/fcntl.yo +14 -22
  159. package/std/sys/file.yo +26 -40
  160. package/std/sys/future.yo +5 -8
  161. package/std/sys/iov.yo +12 -25
  162. package/std/sys/lock.yo +12 -13
  163. package/std/sys/mmap.yo +38 -43
  164. package/std/sys/path.yo +3 -8
  165. package/std/sys/perm.yo +7 -21
  166. package/std/sys/pipe.yo +5 -12
  167. package/std/sys/process.yo +23 -29
  168. package/std/sys/seek.yo +10 -12
  169. package/std/sys/signal.yo +7 -13
  170. package/std/sys/signals.yo +52 -35
  171. package/std/sys/socket.yo +63 -58
  172. package/std/sys/socketpair.yo +3 -6
  173. package/std/sys/sockinfo.yo +11 -20
  174. package/std/sys/statfs.yo +11 -34
  175. package/std/sys/statx.yo +25 -52
  176. package/std/sys/sysinfo.yo +15 -20
  177. package/std/sys/tcp.yo +62 -92
  178. package/std/sys/temp.yo +5 -9
  179. package/std/sys/time.yo +5 -15
  180. package/std/sys/timer.yo +6 -11
  181. package/std/sys/tty.yo +10 -18
  182. package/std/sys/udp.yo +22 -39
  183. package/std/sys/umask.yo +3 -6
  184. package/std/sys/unix.yo +33 -52
  185. package/std/testing/bench.yo +49 -52
  186. package/std/thread.yo +10 -15
  187. package/std/time/datetime.yo +105 -89
  188. package/std/time/duration.yo +43 -56
  189. package/std/time/instant.yo +13 -18
  190. package/std/time/sleep.yo +5 -9
  191. package/std/url/index.yo +184 -209
  192. package/std/worker.yo +6 -10
  193. package/out/types/src/evaluator/calls/module-type.d.ts +0 -11
  194. package/out/types/src/evaluator/types/module.d.ts +0 -19
@@ -9,101 +9,88 @@
9
9
  //! println(d.as_secs()); // 0
10
10
  //! println(d.as_millis()); // 500
11
11
  //! ```
12
-
13
- { String } :: import "../string";
14
- { ToString } :: import "../fmt";
15
- { snprintf } :: import "../libc/stdio";
16
-
12
+ { String } :: import("../string");
13
+ { ToString } :: import("../fmt");
14
+ { snprintf } :: import("../libc/stdio");
17
15
  /// Span of time stored as seconds and nanoseconds.
18
16
  Duration :: struct(
19
- secs : i64,
17
+ secs : i64,
20
18
  nanos : i64
21
19
  );
22
-
23
- impl(Duration,
20
+ impl(
21
+ Duration,
24
22
  // Create a Duration from whole seconds.
25
- from_secs : (fn(secs: i64) -> Self)(
26
- Self(secs: secs, nanos: i64(0))
23
+ from_secs : (fn(secs : i64) -> Self)(
24
+ Self(secs : secs, nanos : i64(0))
27
25
  ),
28
-
29
26
  // Create a Duration from milliseconds.
30
- from_millis : (fn(millis: i64) -> Self)(
31
- Self(secs: (millis / i64(1000)), nanos: ((millis % i64(1000)) * i64(1000000)))
27
+ from_millis : (fn(millis : i64) -> Self)(
28
+ Self(secs : (millis / i64(1000)), nanos : ((millis % i64(1000)) * i64(1000000)))
32
29
  ),
33
-
34
30
  // Create a Duration from microseconds.
35
- from_micros : (fn(micros: i64) -> Self)(
36
- Self(secs: (micros / i64(1000000)), nanos: ((micros % i64(1000000)) * i64(1000)))
31
+ from_micros : (fn(micros : i64) -> Self)(
32
+ Self(secs : (micros / i64(1000000)), nanos : ((micros % i64(1000000)) * i64(1000)))
37
33
  ),
38
-
39
34
  // Create a Duration of zero length.
40
35
  zero : (fn() -> Self)(
41
- Self(secs: i64(0), nanos: i64(0))
36
+ Self(secs : i64(0), nanos : i64(0))
42
37
  ),
43
-
44
38
  // Create a Duration from raw nanoseconds.
45
- from_nanos : (fn(nanos: i64) -> Self)(
46
- Self(secs: (nanos / i64(1000000000)), nanos: (nanos % i64(1000000000)))
39
+ from_nanos : (fn(nanos : i64) -> Self)(
40
+ Self(secs : (nanos / i64(1000000000)), nanos : (nanos % i64(1000000000)))
47
41
  ),
48
-
49
42
  // Total whole seconds in the duration.
50
- as_secs : (fn(self: *(Self)) -> i64)(
43
+ as_secs : (fn(self : *(Self)) -> i64)(
51
44
  self.secs
52
45
  ),
53
-
54
46
  // Total milliseconds (truncated).
55
- as_millis : (fn(self: *(Self)) -> i64)(
56
- ((self.secs * i64(1000)) + (self.nanos / i64(1000000)))
47
+ as_millis : (fn(self : *(Self)) -> i64)(
48
+ (self.secs * i64(1000)) + (self.nanos / i64(1000000))
57
49
  ),
58
-
59
50
  // Total microseconds (truncated).
60
- as_micros : (fn(self: *(Self)) -> i64)(
61
- ((self.secs * i64(1000000)) + (self.nanos / i64(1000)))
51
+ as_micros : (fn(self : *(Self)) -> i64)(
52
+ (self.secs * i64(1000000)) + (self.nanos / i64(1000))
62
53
  ),
63
-
64
54
  // Total nanoseconds.
65
- as_nanos : (fn(self: *(Self)) -> i64)(
66
- ((self.secs * i64(1000000000)) + self.nanos)
55
+ as_nanos : (fn(self : *(Self)) -> i64)(
56
+ (self.secs * i64(1000000000)) + self.nanos
67
57
  ),
68
-
69
58
  // Total seconds as a floating-point number.
70
- as_secs_f64 : (fn(self: *(Self)) -> f64)(
71
- (f64(self.secs) + (f64(self.nanos) / f64(1000000000.0)))
59
+ as_secs_f64 : (fn(self : *(Self)) -> f64)(
60
+ f64(self.secs) + (f64(self.nanos) / f64(1000000000.0))
72
61
  ),
73
-
74
62
  // Add two durations together.
75
- add : (fn(self: *(Self), other: Duration) -> Duration)({
63
+ add : (fn(self : *(Self), other : Duration) -> Duration)({
76
64
  total_nanos := (self.nanos + other.nanos);
77
65
  carry := (total_nanos / i64(1000000000));
78
66
  Duration(
79
- secs: ((self.secs + other.secs) + carry),
80
- nanos: (total_nanos % i64(1000000000))
67
+ secs : ((self.secs + other.secs) + carry),
68
+ nanos : (total_nanos % i64(1000000000))
81
69
  )
82
70
  }),
83
-
84
71
  // Subtract another duration (saturates to zero if negative).
85
- sub : (fn(self: *(Self), other: Duration) -> Duration)({
72
+ sub : (fn(self : *(Self), other : Duration) -> Duration)({
86
73
  self_ns := self.as_nanos();
87
74
  other_ns := other.as_nanos();
88
75
  cond(
89
76
  (self_ns <= other_ns) => Duration.zero(),
90
- true => Duration.from_nanos((self_ns - other_ns))
77
+ true => Duration.from_nanos(self_ns - other_ns)
91
78
  )
92
79
  }),
93
-
94
80
  // Return true if this duration is zero.
95
- is_zero : (fn(self: *(Self)) -> bool)(
96
- ((self.secs == i64(0)) && (self.nanos == i64(0)))
81
+ is_zero : (fn(self : *(Self)) -> bool)(
82
+ (self.secs == i64(0)) && (self.nanos == i64(0))
97
83
  )
98
84
  );
99
-
100
- impl(Duration, ToString(
101
- to_string : (fn(self: *(Self)) -> String)({
102
- buf := Array(u8, usize(64)).fill(u8(0));
103
- buf_ptr := &(buf(usize(0)));
104
- snprintf(*(char)(buf_ptr), usize(64), "%llds %lldns", self.secs, self.nanos);
105
- String.from_cstr(buf_ptr).unwrap()
106
- })
107
- ));
108
-
109
- export Duration;
85
+ impl(
86
+ Duration,
87
+ ToString(
88
+ to_string : (fn(self : *(Self)) -> String)({
89
+ buf := Array(u8, usize(64)).fill(u8(0));
90
+ buf_ptr := &(buf(usize(0)));
91
+ snprintf(*(char)(buf_ptr), usize(64), "%llds %lldns", self.secs, self.nanos);
92
+ String.from_cstr(buf_ptr).unwrap()
93
+ })
94
+ )
95
+ );
96
+ export(Duration);
@@ -10,43 +10,38 @@
10
10
  //! elapsed := start.elapsed();
11
11
  //! println(elapsed.as_millis());
12
12
  //! ```
13
-
14
- { Duration } :: import "./duration";
15
- { CLOCK_MONOTONIC, clock_gettime } :: import "../sys/clock";
16
-
13
+ { Duration } :: import("./duration");
14
+ { CLOCK_MONOTONIC, clock_gettime } :: import("../sys/clock");
17
15
  /// Snapshot from the monotonic clock. Use `elapsed` to measure durations.
18
16
  Instant :: struct(
19
- secs : i64,
17
+ secs : i64,
20
18
  nanos : i64
21
19
  );
22
-
23
- impl(Instant,
20
+ impl(
21
+ Instant,
24
22
  // Capture the current monotonic time.
25
23
  now : (fn() -> Self)({
26
- clk := CLOCK_MONOTONIC;
27
- out_s := i64(0);
24
+ clk := CLOCK_MONOTONIC;
25
+ out_s := i64(0);
28
26
  out_ns := i64(0);
29
- clock_gettime(clk, (&out_s), (&out_ns));
30
- Self(secs: out_s, nanos: out_ns)
27
+ clock_gettime(clk, &(out_s), &(out_ns));
28
+ Self(secs : out_s, nanos : out_ns)
31
29
  }),
32
-
33
30
  // Duration between this instant and an earlier one.
34
31
  // Returns Duration.zero() if `earlier` is actually later.
35
- duration_since : (fn(self: *(Self), earlier: Instant) -> Duration)({
32
+ duration_since : (fn(self : *(Self), earlier : Instant) -> Duration)({
36
33
  self_ns := ((self.secs * i64(1000000000)) + self.nanos);
37
34
  earlier_ns := ((earlier.secs * i64(1000000000)) + earlier.nanos);
38
35
  cond(
39
36
  (self_ns <= earlier_ns) => Duration.zero(),
40
- true => Duration.from_nanos((self_ns - earlier_ns))
37
+ true => Duration.from_nanos(self_ns - earlier_ns)
41
38
  )
42
39
  }),
43
-
44
40
  // Duration elapsed since this instant was created.
45
- elapsed : (fn(self: *(Self)) -> Duration)({
41
+ elapsed : (fn(self : *(Self)) -> Duration)({
46
42
  current := Instant.now();
47
43
  cur_ptr := (&(current));
48
44
  cur_ptr.duration_since(self.*)
49
45
  })
50
46
  );
51
-
52
- export Instant;
47
+ export(Instant);
package/std/time/sleep.yo CHANGED
@@ -6,14 +6,10 @@
6
6
  //! { sleep } :: import "std/time/sleep";
7
7
  //! sleep(usize(100)); // sleep 100ms
8
8
  //! ```
9
-
10
- extern "Yo",
11
- __yo_ms_sleep : (fn(ms: usize) -> unit)
12
- ;
13
-
9
+ extern(
10
+ "Yo",
11
+ __yo_ms_sleep : (fn(ms : usize) -> unit)
12
+ );
14
13
  /// Block the current thread for the given number of milliseconds.
15
14
  sleep :: __yo_ms_sleep;
16
-
17
- export
18
- sleep
19
- ;
15
+ export(sleep);