@shd101wyy/yo 0.1.26 → 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 (167) hide show
  1. package/.github/skills/yo-async-effects/SKILL.md +4 -4
  2. package/.github/skills/yo-async-effects/async-effects-recipes.md +34 -34
  3. package/.github/skills/yo-core-patterns/SKILL.md +1 -1
  4. package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +26 -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 +73 -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 +456 -438
  12. package/out/cjs/yo-cli.cjs +576 -543
  13. package/out/cjs/yo-lsp.cjs +559 -532
  14. package/out/esm/index.mjs +281 -263
  15. package/out/types/src/formatter.d.ts +11 -0
  16. package/out/types/src/lsp/formatting.d.ts +2 -0
  17. package/out/types/src/tests/formatter.test.d.ts +1 -0
  18. package/out/types/tsconfig.tsbuildinfo +1 -1
  19. package/package.json +1 -1
  20. package/std/alg/hash.yo +13 -21
  21. package/std/allocator.yo +25 -40
  22. package/std/async.yo +3 -7
  23. package/std/build.yo +105 -151
  24. package/std/cli/arg_parser.yo +184 -169
  25. package/std/collections/array_list.yo +350 -314
  26. package/std/collections/btree_map.yo +142 -131
  27. package/std/collections/deque.yo +132 -128
  28. package/std/collections/hash_map.yo +542 -566
  29. package/std/collections/hash_set.yo +623 -687
  30. package/std/collections/linked_list.yo +275 -293
  31. package/std/collections/ordered_map.yo +113 -85
  32. package/std/collections/priority_queue.yo +73 -73
  33. package/std/crypto/md5.yo +191 -95
  34. package/std/crypto/random.yo +56 -64
  35. package/std/crypto/sha256.yo +151 -107
  36. package/std/encoding/base64.yo +87 -81
  37. package/std/encoding/hex.yo +43 -50
  38. package/std/encoding/html.yo +56 -81
  39. package/std/encoding/html_char_utils.yo +7 -13
  40. package/std/encoding/html_entities.yo +2248 -2253
  41. package/std/encoding/json.yo +316 -224
  42. package/std/encoding/punycode.yo +86 -116
  43. package/std/encoding/toml.yo +67 -66
  44. package/std/encoding/utf16.yo +37 -44
  45. package/std/env.yo +62 -91
  46. package/std/error.yo +7 -15
  47. package/std/fmt/display.yo +5 -9
  48. package/std/fmt/index.yo +8 -14
  49. package/std/fmt/to_string.yo +330 -315
  50. package/std/fmt/writer.yo +58 -87
  51. package/std/fs/dir.yo +83 -102
  52. package/std/fs/file.yo +147 -180
  53. package/std/fs/metadata.yo +45 -78
  54. package/std/fs/temp.yo +55 -65
  55. package/std/fs/types.yo +27 -40
  56. package/std/fs/walker.yo +53 -68
  57. package/std/gc.yo +5 -8
  58. package/std/glob.yo +30 -43
  59. package/std/http/client.yo +107 -120
  60. package/std/http/http.yo +106 -96
  61. package/std/http/index.yo +4 -6
  62. package/std/imm/list.yo +88 -93
  63. package/std/imm/map.yo +528 -464
  64. package/std/imm/set.yo +52 -57
  65. package/std/imm/sorted_map.yo +340 -286
  66. package/std/imm/sorted_set.yo +57 -63
  67. package/std/imm/string.yo +404 -345
  68. package/std/imm/vec.yo +173 -181
  69. package/std/io/reader.yo +3 -6
  70. package/std/io/writer.yo +4 -8
  71. package/std/libc/assert.yo +5 -9
  72. package/std/libc/ctype.yo +32 -22
  73. package/std/libc/dirent.yo +26 -25
  74. package/std/libc/errno.yo +164 -90
  75. package/std/libc/fcntl.yo +52 -45
  76. package/std/libc/float.yo +66 -44
  77. package/std/libc/limits.yo +42 -33
  78. package/std/libc/math.yo +53 -82
  79. package/std/libc/signal.yo +72 -47
  80. package/std/libc/stdatomic.yo +217 -188
  81. package/std/libc/stdint.yo +5 -29
  82. package/std/libc/stdio.yo +5 -29
  83. package/std/libc/stdlib.yo +32 -39
  84. package/std/libc/string.yo +5 -23
  85. package/std/libc/sys/stat.yo +58 -56
  86. package/std/libc/time.yo +5 -19
  87. package/std/libc/unistd.yo +5 -20
  88. package/std/libc/wctype.yo +6 -9
  89. package/std/libc/windows.yo +26 -30
  90. package/std/log.yo +41 -55
  91. package/std/net/addr.yo +102 -97
  92. package/std/net/dns.yo +27 -28
  93. package/std/net/errors.yo +50 -49
  94. package/std/net/tcp.yo +113 -124
  95. package/std/net/udp.yo +55 -66
  96. package/std/os/env.yo +35 -33
  97. package/std/os/signal.yo +15 -25
  98. package/std/path.yo +276 -311
  99. package/std/prelude.yo +6304 -4315
  100. package/std/process/command.yo +87 -103
  101. package/std/process/index.yo +12 -31
  102. package/std/regex/compiler.yo +196 -95
  103. package/std/regex/flags.yo +58 -39
  104. package/std/regex/index.yo +157 -173
  105. package/std/regex/match.yo +20 -31
  106. package/std/regex/node.yo +134 -152
  107. package/std/regex/parser.yo +283 -259
  108. package/std/regex/unicode.yo +172 -202
  109. package/std/regex/vm.yo +155 -171
  110. package/std/string/index.yo +5 -7
  111. package/std/string/rune.yo +45 -55
  112. package/std/string/string.yo +937 -964
  113. package/std/string/string_builder.yo +94 -104
  114. package/std/string/unicode.yo +46 -64
  115. package/std/sync/channel.yo +72 -73
  116. package/std/sync/cond.yo +31 -36
  117. package/std/sync/mutex.yo +30 -32
  118. package/std/sync/once.yo +13 -16
  119. package/std/sync/rwlock.yo +26 -31
  120. package/std/sync/waitgroup.yo +20 -25
  121. package/std/sys/advise.yo +16 -24
  122. package/std/sys/bufio/buf_reader.yo +77 -93
  123. package/std/sys/bufio/buf_writer.yo +52 -65
  124. package/std/sys/clock.yo +4 -9
  125. package/std/sys/constants.yo +77 -61
  126. package/std/sys/copy.yo +4 -10
  127. package/std/sys/dir.yo +26 -43
  128. package/std/sys/dns.yo +41 -61
  129. package/std/sys/errors.yo +95 -103
  130. package/std/sys/events.yo +45 -57
  131. package/std/sys/externs.yo +319 -267
  132. package/std/sys/fallocate.yo +7 -11
  133. package/std/sys/fcntl.yo +14 -22
  134. package/std/sys/file.yo +26 -40
  135. package/std/sys/future.yo +5 -8
  136. package/std/sys/iov.yo +12 -25
  137. package/std/sys/lock.yo +12 -13
  138. package/std/sys/mmap.yo +38 -43
  139. package/std/sys/path.yo +3 -8
  140. package/std/sys/perm.yo +7 -21
  141. package/std/sys/pipe.yo +5 -12
  142. package/std/sys/process.yo +23 -29
  143. package/std/sys/seek.yo +10 -12
  144. package/std/sys/signal.yo +7 -13
  145. package/std/sys/signals.yo +52 -35
  146. package/std/sys/socket.yo +63 -58
  147. package/std/sys/socketpair.yo +3 -6
  148. package/std/sys/sockinfo.yo +11 -20
  149. package/std/sys/statfs.yo +11 -34
  150. package/std/sys/statx.yo +25 -52
  151. package/std/sys/sysinfo.yo +15 -20
  152. package/std/sys/tcp.yo +62 -92
  153. package/std/sys/temp.yo +5 -9
  154. package/std/sys/time.yo +5 -15
  155. package/std/sys/timer.yo +6 -11
  156. package/std/sys/tty.yo +10 -18
  157. package/std/sys/udp.yo +22 -39
  158. package/std/sys/umask.yo +3 -6
  159. package/std/sys/unix.yo +33 -52
  160. package/std/testing/bench.yo +49 -52
  161. package/std/thread.yo +10 -15
  162. package/std/time/datetime.yo +105 -89
  163. package/std/time/duration.yo +43 -56
  164. package/std/time/instant.yo +13 -18
  165. package/std/time/sleep.yo +5 -9
  166. package/std/url/index.yo +184 -209
  167. package/std/worker.yo +6 -10
@@ -17,65 +17,57 @@
17
17
  //! s = s.insert(i32(2));
18
18
  //! // elements are always sorted: 1, 2, 3
19
19
  //! ```
20
-
21
- { SortedMap } :: import "./sorted_map.yo";
22
- { List } :: import "./list.yo";
23
-
20
+ { SortedMap } :: import("./sorted_map.yo");
21
+ { List } :: import("./list.yo");
24
22
  /// Persistent immutable sorted set backed by a left-leaning red-black tree.
25
23
  SortedSet :: (fn(comptime(T) : Type, where(T <: (Eq(T), Ord(T), Send))) -> comptime(Type))(
26
24
  struct(_inner : SortedMap(T, bool))
27
25
  );
28
-
29
- impl(forall(T : Type), where(T <: (Eq(T), Ord(T), Send)), SortedSet(T),
26
+ impl(
27
+ forall(T : Type),
28
+ where(T <: (Eq(T), Ord(T), Send)),
29
+ SortedSet(T),
30
30
  /// Create an empty sorted set.
31
31
  new : (fn() -> Self)(
32
- Self(_inner: SortedMap(T, bool).new())
32
+ Self(_inner : SortedMap(T, bool).new())
33
33
  ),
34
-
35
34
  /// Number of elements.
36
- len : (fn(self: Self) -> usize)(self._inner.len()),
37
-
35
+ len : (fn(self : Self) -> usize)(self._inner.len()),
38
36
  /// Check if the set is empty.
39
- is_empty : (fn(self: Self) -> bool)(self._inner.is_empty()),
40
-
37
+ is_empty : (fn(self : Self) -> bool)(self._inner.is_empty()),
41
38
  /// Check if the set contains `elem`.
42
- contains : (fn(self: Self, elem: T) -> bool)(
39
+ contains : (fn(self : Self, elem : T) -> bool)(
43
40
  self._inner.contains_key(elem)
44
41
  ),
45
-
46
42
  /// Return a new set with `elem` added.
47
- insert : (fn(self: Self, elem: T) -> Self)(
48
- Self(_inner: self._inner.insert(elem, true))
43
+ insert : (fn(self : Self, elem : T) -> Self)(
44
+ Self(_inner : self._inner.insert(elem, true))
49
45
  ),
50
-
51
46
  /// Return a new set with `elem` removed.
52
- remove : (fn(self: Self, elem: T) -> Self)(
53
- Self(_inner: self._inner.remove(elem))
47
+ remove : (fn(self : Self, elem : T) -> Self)(
48
+ Self(_inner : self._inner.remove(elem))
54
49
  ),
55
-
56
50
  /// Get the minimum element.
57
- min : (fn(self: Self) -> Option(T))(
51
+ min : (fn(self : Self) -> Option(T))(
58
52
  self._inner.min_key()
59
53
  ),
60
-
61
54
  /// Get the maximum element.
62
- max : (fn(self: Self) -> Option(T))(
55
+ max : (fn(self : Self) -> Option(T))(
63
56
  self._inner.max_key()
64
57
  ),
65
-
66
58
  /// Return elements as a sorted List.
67
- to_list : (fn(self: Self) -> List(T))(
59
+ to_list : (fn(self : Self) -> List(T))(
68
60
  self._inner.keys()
69
61
  ),
70
-
71
62
  /// Return the union of two sorted sets.
72
- union : (fn(self: Self, other: Self) -> Self)({
63
+ union : (fn(self : Self, other : Self) -> Self)({
73
64
  elems := other.to_list();
74
65
  (result : Self) = self;
75
66
  (cur : List(T)) = elems;
76
67
  (done : bool) = false;
77
- while runtime(!(done)), {
78
- match(cur.head(),
68
+ while(runtime(!(done)), {
69
+ match(
70
+ cur.head(),
79
71
  .Some(elem) => {
80
72
  result = result.insert(elem);
81
73
  cur = cur.tail();
@@ -84,18 +76,18 @@ impl(forall(T : Type), where(T <: (Eq(T), Ord(T), Send)), SortedSet(T),
84
76
  done = true;
85
77
  }
86
78
  );
87
- };
79
+ });
88
80
  result
89
81
  }),
90
-
91
82
  /// Return the intersection of two sorted sets.
92
- intersection : (fn(self: Self, other: Self) -> Self)({
83
+ intersection : (fn(self : Self, other : Self) -> Self)({
93
84
  elems := self.to_list();
94
85
  (result : Self) = Self.new();
95
86
  (cur : List(T)) = elems;
96
87
  (done : bool) = false;
97
- while runtime(!(done)), {
98
- match(cur.head(),
88
+ while(runtime(!(done)), {
89
+ match(
90
+ cur.head(),
99
91
  .Some(elem) => {
100
92
  if(other.contains(elem), {
101
93
  result = result.insert(elem);
@@ -106,18 +98,18 @@ impl(forall(T : Type), where(T <: (Eq(T), Ord(T), Send)), SortedSet(T),
106
98
  done = true;
107
99
  }
108
100
  );
109
- };
101
+ });
110
102
  result
111
103
  }),
112
-
113
104
  /// Return the difference (`self \ other`).
114
- difference : (fn(self: Self, other: Self) -> Self)({
105
+ difference : (fn(self : Self, other : Self) -> Self)({
115
106
  elems := self.to_list();
116
107
  (result : Self) = Self.new();
117
108
  (cur : List(T)) = elems;
118
109
  (done : bool) = false;
119
- while runtime(!(done)), {
120
- match(cur.head(),
110
+ while(runtime(!(done)), {
111
+ match(
112
+ cur.head(),
121
113
  .Some(elem) => {
122
114
  if(!(other.contains(elem)), {
123
115
  result = result.insert(elem);
@@ -128,20 +120,20 @@ impl(forall(T : Type), where(T <: (Eq(T), Ord(T), Send)), SortedSet(T),
128
120
  done = true;
129
121
  }
130
122
  );
131
- };
123
+ });
132
124
  result
133
125
  }),
134
-
135
126
  /// Check if `self` is a subset of `other`.
136
- is_subset : (fn(self: Self, other: Self) -> bool)({
137
- if((self.len() > other.len()), {
138
- return false;
127
+ is_subset : (fn(self : Self, other : Self) -> bool)({
128
+ if(self.len() > other.len(), {
129
+ return(false);
139
130
  });
140
131
  elems := self.to_list();
141
132
  (cur : List(T)) = elems;
142
133
  (result : bool) = true;
143
- while runtime((result && !(cur.is_empty()))), {
144
- match(cur.head(),
134
+ while(runtime(result && !(cur.is_empty())), {
135
+ match(
136
+ cur.head(),
145
137
  .Some(elem) => {
146
138
  if(!(other.contains(elem)), {
147
139
  result = false;
@@ -150,12 +142,11 @@ impl(forall(T : Type), where(T <: (Eq(T), Ord(T), Send)), SortedSet(T),
150
142
  },
151
143
  .None => ()
152
144
  );
153
- };
145
+ });
154
146
  result
155
147
  }),
156
-
157
148
  /// Check if two sorted sets are disjoint.
158
- is_disjoint : (fn(self: Self, other: Self) -> bool)({
149
+ is_disjoint : (fn(self : Self, other : Self) -> bool)({
159
150
  (smaller : Self) = cond(
160
151
  (self.len() <= other.len()) => self,
161
152
  true => other
@@ -167,8 +158,9 @@ impl(forall(T : Type), where(T <: (Eq(T), Ord(T), Send)), SortedSet(T),
167
158
  elems := smaller.to_list();
168
159
  (cur : List(T)) = elems;
169
160
  (result : bool) = true;
170
- while runtime((result && !(cur.is_empty()))), {
171
- match(cur.head(),
161
+ while(runtime(result && !(cur.is_empty())), {
162
+ match(
163
+ cur.head(),
172
164
  .Some(elem) => {
173
165
  if(larger.contains(elem), {
174
166
  result = false;
@@ -177,26 +169,28 @@ impl(forall(T : Type), where(T <: (Eq(T), Ord(T), Send)), SortedSet(T),
177
169
  },
178
170
  .None => ()
179
171
  );
180
- };
172
+ });
181
173
  result
182
174
  }),
183
-
184
175
  /// Create a sorted set from a slice of elements.
185
- from_slice : (fn(s: Slice(T)) -> Self)({
176
+ from_slice : (fn(s : Slice(T)) -> Self)({
186
177
  (result : Self) = Self.new();
187
178
  i := usize(0);
188
179
  slen := s.len();
189
- while (i < slen), (i = (i + usize(1))), {
180
+ while(i < slen, i = (i + usize(1)), {
190
181
  result = result.insert((s.ptr() &+ i).*);
191
- };
182
+ });
192
183
  result
193
184
  })
194
185
  );
195
-
196
- impl(forall(T : Type), where(T <: (Eq(T), Ord(T), Send)), SortedSet(T), Eq(SortedSet(T))(
197
- (==) : (fn(lhs: Self, rhs: Self) -> bool)(
198
- (lhs._inner == rhs._inner)
186
+ impl(
187
+ forall(T : Type),
188
+ where(T <: (Eq(T), Ord(T), Send)),
189
+ SortedSet(T),
190
+ Eq(SortedSet(T))(
191
+ (==) : (fn(lhs : Self, rhs : Self) -> bool)(
192
+ lhs._inner == rhs._inner
193
+ )
199
194
  )
200
- ));
201
-
202
- export SortedSet;
195
+ );
196
+ export(SortedSet);