@mtkruto/node 0.0.996 → 0.0.998

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 (181) hide show
  1. package/esm/0_deps.d.ts +2 -2
  2. package/esm/0_deps.js +2 -2
  3. package/esm/3_types.d.ts +1 -0
  4. package/esm/3_types.js +1 -0
  5. package/esm/4_constants.d.ts +1 -1
  6. package/esm/4_constants.js +1 -1
  7. package/esm/client/0_html.js +1 -1
  8. package/esm/client/3_types.d.ts +3 -2
  9. package/esm/client/3_types.js +1 -1
  10. package/esm/client/4_client.d.ts +11 -4
  11. package/esm/client/4_client.js +60 -9
  12. package/esm/deps/deno.land/std@0.201.0/assert/assert_greater.d.ts +5 -0
  13. package/esm/deps/deno.land/std@0.201.0/assert/assert_greater.js +14 -0
  14. package/esm/deps/deno.land/std@0.201.0/assert/assert_greater_or_equal.d.ts +5 -0
  15. package/esm/deps/deno.land/std@0.201.0/assert/assert_greater_or_equal.js +14 -0
  16. package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_instance_of.js +2 -2
  17. package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_is_error.js +4 -1
  18. package/esm/deps/deno.land/std@0.201.0/assert/assert_less.d.ts +5 -0
  19. package/esm/deps/deno.land/std@0.201.0/assert/assert_less.js +14 -0
  20. package/esm/deps/deno.land/std@0.201.0/assert/assert_less_or_equal.d.ts +5 -0
  21. package/esm/deps/deno.land/std@0.201.0/assert/assert_less_or_equal.js +14 -0
  22. package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/mod.d.ts +4 -0
  23. package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/mod.js +4 -0
  24. package/{script/deps/deno.land/std@0.200.0 → esm/deps/deno.land/std@0.201.0}/fmt/colors.d.ts +8 -1
  25. package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/fmt/colors.js +8 -1
  26. package/esm/tl/3_tl_reader.d.ts +1 -1
  27. package/esm/tl/3_tl_reader.js +6 -0
  28. package/esm/tl/4_tl_writer.js +8 -0
  29. package/esm/tl/6_message.js +3 -0
  30. package/esm/types/0_chat_action.d.ts +1 -0
  31. package/esm/types/0_chat_action.js +1 -0
  32. package/esm/types/0_message_entity.d.ts +10 -10
  33. package/esm/types/0_message_entity.js +12 -12
  34. package/esm/types/1_chat.d.ts +5 -10
  35. package/esm/types/1_chat.js +4 -11
  36. package/esm/types/1_sticker.d.ts +2 -2
  37. package/esm/types/1_sticker.js +1 -1
  38. package/esm/types/3_message.js +3 -3
  39. package/package.json +1 -1
  40. package/script/0_deps.d.ts +2 -2
  41. package/script/0_deps.js +2 -2
  42. package/script/3_types.d.ts +1 -0
  43. package/script/3_types.js +1 -0
  44. package/script/4_constants.d.ts +1 -1
  45. package/script/4_constants.js +1 -1
  46. package/script/client/0_html.js +1 -1
  47. package/script/client/3_types.d.ts +3 -2
  48. package/script/client/3_types.js +3 -0
  49. package/script/client/4_client.d.ts +11 -4
  50. package/script/client/4_client.js +60 -9
  51. package/script/deps/deno.land/std@0.201.0/assert/assert_greater.d.ts +5 -0
  52. package/script/deps/deno.land/std@0.201.0/assert/assert_greater.js +18 -0
  53. package/script/deps/deno.land/std@0.201.0/assert/assert_greater_or_equal.d.ts +5 -0
  54. package/script/deps/deno.land/std@0.201.0/assert/assert_greater_or_equal.js +18 -0
  55. package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_instance_of.js +2 -2
  56. package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_is_error.js +4 -1
  57. package/script/deps/deno.land/std@0.201.0/assert/assert_less.d.ts +5 -0
  58. package/script/deps/deno.land/std@0.201.0/assert/assert_less.js +18 -0
  59. package/script/deps/deno.land/std@0.201.0/assert/assert_less_or_equal.d.ts +5 -0
  60. package/script/deps/deno.land/std@0.201.0/assert/assert_less_or_equal.js +18 -0
  61. package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/mod.d.ts +4 -0
  62. package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/mod.js +4 -0
  63. package/{esm/deps/deno.land/std@0.200.0 → script/deps/deno.land/std@0.201.0}/fmt/colors.d.ts +8 -1
  64. package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/fmt/colors.js +10 -3
  65. package/script/tl/3_tl_reader.d.ts +1 -1
  66. package/script/tl/3_tl_reader.js +6 -0
  67. package/script/tl/4_tl_writer.js +8 -0
  68. package/script/tl/6_message.js +3 -0
  69. package/script/types/0_chat_action.d.ts +1 -0
  70. package/script/types/0_chat_action.js +2 -0
  71. package/script/types/0_message_entity.d.ts +10 -10
  72. package/script/types/0_message_entity.js +12 -12
  73. package/script/types/1_chat.d.ts +5 -10
  74. package/script/types/1_chat.js +5 -12
  75. package/script/types/1_sticker.d.ts +2 -2
  76. package/script/types/1_sticker.js +1 -1
  77. package/script/types/3_message.js +2 -2
  78. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_constants.d.ts +0 -0
  79. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_constants.js +0 -0
  80. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_diff.d.ts +0 -0
  81. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_diff.js +0 -0
  82. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_format.d.ts +0 -0
  83. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_format.js +0 -0
  84. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert.d.ts +0 -0
  85. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert.js +0 -0
  86. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_almost_equals.d.ts +0 -0
  87. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_almost_equals.js +0 -0
  88. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_array_includes.d.ts +0 -0
  89. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_array_includes.js +0 -0
  90. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_equals.d.ts +0 -0
  91. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_equals.js +0 -0
  92. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_exists.d.ts +0 -0
  93. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_exists.js +0 -0
  94. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_false.d.ts +0 -0
  95. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_false.js +0 -0
  96. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_instance_of.d.ts +0 -0
  97. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_is_error.d.ts +0 -0
  98. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_match.d.ts +0 -0
  99. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_match.js +0 -0
  100. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_equals.d.ts +0 -0
  101. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_equals.js +0 -0
  102. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_instance_of.d.ts +0 -0
  103. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_instance_of.js +0 -0
  104. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_match.d.ts +0 -0
  105. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_match.js +0 -0
  106. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_strict_equals.d.ts +0 -0
  107. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_strict_equals.js +0 -0
  108. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_object_match.d.ts +0 -0
  109. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_object_match.js +0 -0
  110. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_rejects.d.ts +0 -0
  111. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_rejects.js +0 -0
  112. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_strict_equals.d.ts +0 -0
  113. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_strict_equals.js +0 -0
  114. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_string_includes.d.ts +0 -0
  115. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_string_includes.js +0 -0
  116. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_throws.d.ts +0 -0
  117. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_throws.js +0 -0
  118. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assertion_error.d.ts +0 -0
  119. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assertion_error.js +0 -0
  120. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/equal.d.ts +0 -0
  121. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/equal.js +0 -0
  122. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/fail.d.ts +0 -0
  123. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/fail.js +0 -0
  124. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/unimplemented.d.ts +0 -0
  125. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/unimplemented.js +0 -0
  126. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/unreachable.d.ts +0 -0
  127. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/unreachable.js +0 -0
  128. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/encoding/base64.d.ts +0 -0
  129. /package/esm/deps/deno.land/{std@0.200.0 → std@0.201.0}/encoding/base64.js +0 -0
  130. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_constants.d.ts +0 -0
  131. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_constants.js +0 -0
  132. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_diff.d.ts +0 -0
  133. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_diff.js +0 -0
  134. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_format.d.ts +0 -0
  135. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/_format.js +0 -0
  136. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert.d.ts +0 -0
  137. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert.js +0 -0
  138. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_almost_equals.d.ts +0 -0
  139. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_almost_equals.js +0 -0
  140. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_array_includes.d.ts +0 -0
  141. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_array_includes.js +0 -0
  142. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_equals.d.ts +0 -0
  143. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_equals.js +0 -0
  144. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_exists.d.ts +0 -0
  145. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_exists.js +0 -0
  146. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_false.d.ts +0 -0
  147. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_false.js +0 -0
  148. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_instance_of.d.ts +0 -0
  149. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_is_error.d.ts +0 -0
  150. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_match.d.ts +0 -0
  151. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_match.js +0 -0
  152. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_equals.d.ts +0 -0
  153. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_equals.js +0 -0
  154. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_instance_of.d.ts +0 -0
  155. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_instance_of.js +0 -0
  156. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_match.d.ts +0 -0
  157. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_match.js +0 -0
  158. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_strict_equals.d.ts +0 -0
  159. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_not_strict_equals.js +0 -0
  160. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_object_match.d.ts +0 -0
  161. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_object_match.js +0 -0
  162. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_rejects.d.ts +0 -0
  163. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_rejects.js +0 -0
  164. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_strict_equals.d.ts +0 -0
  165. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_strict_equals.js +0 -0
  166. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_string_includes.d.ts +0 -0
  167. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_string_includes.js +0 -0
  168. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_throws.d.ts +0 -0
  169. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assert_throws.js +0 -0
  170. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assertion_error.d.ts +0 -0
  171. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/assertion_error.js +0 -0
  172. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/equal.d.ts +0 -0
  173. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/equal.js +0 -0
  174. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/fail.d.ts +0 -0
  175. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/fail.js +0 -0
  176. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/unimplemented.d.ts +0 -0
  177. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/unimplemented.js +0 -0
  178. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/unreachable.d.ts +0 -0
  179. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/assert/unreachable.js +0 -0
  180. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/encoding/base64.d.ts +0 -0
  181. /package/script/deps/deno.land/{std@0.200.0 → std@0.201.0}/encoding/base64.js +0 -0
@@ -7,7 +7,7 @@ export function constructMessageEntity(obj) {
7
7
  return { type: "hashtag", offset: obj.offset, length: obj.length };
8
8
  }
9
9
  else if (obj instanceof types.MessageEntityBotCommand) {
10
- return { type: "bot_command", offset: obj.offset ?? 0, length: obj.length };
10
+ return { type: "botCommand", offset: obj.offset ?? 0, length: obj.length };
11
11
  }
12
12
  else if (obj instanceof types.MessageEntityURL) {
13
13
  return { type: "url", offset: obj.offset, length: obj.length };
@@ -28,16 +28,16 @@ export function constructMessageEntity(obj) {
28
28
  return { type: "pre", offset: obj.offset, length: obj.length, language: obj.language };
29
29
  }
30
30
  else if (obj instanceof types.MessageEntityTextURL) {
31
- return { type: "text_link", offset: obj.offset, length: obj.length, url: obj.url };
31
+ return { type: "textLink", offset: obj.offset, length: obj.length, url: obj.url };
32
32
  }
33
33
  else if (obj instanceof types.MessageEntityMentionName) {
34
- return { type: "text_mention", offset: obj.offset, length: obj.length, userId: Number(obj.userId) };
34
+ return { type: "textMention", offset: obj.offset, length: obj.length, userId: Number(obj.userId) };
35
35
  }
36
36
  else if (obj instanceof types.MessageEntityCashtag) {
37
37
  return { type: "cashtag", offset: obj.offset, length: obj.length };
38
38
  }
39
39
  else if (obj instanceof types.MessageEntityPhone) {
40
- return { type: "phone_number", offset: obj.offset, length: obj.length };
40
+ return { type: "phoneNumber", offset: obj.offset, length: obj.length };
41
41
  }
42
42
  else if (obj instanceof types.MessageEntityUnderline) {
43
43
  return { type: "underline", offset: obj.offset, length: obj.length };
@@ -49,13 +49,13 @@ export function constructMessageEntity(obj) {
49
49
  return { type: "blockquote", offset: obj.offset, length: obj.length };
50
50
  }
51
51
  else if (obj instanceof types.MessageEntityBankCard) {
52
- return { type: "bank_card", offset: obj.offset, length: obj.length };
52
+ return { type: "bankCard", offset: obj.offset, length: obj.length };
53
53
  }
54
54
  else if (obj instanceof types.MessageEntitySpoiler) {
55
55
  return { type: "spoiler", offset: obj.offset, length: obj.length };
56
56
  }
57
57
  else if (obj instanceof types.MessageEntityCustomEmoji) {
58
- return { type: "custom_emoji", offset: obj.offset, length: obj.length, customEmojiId: String(obj.documentId) };
58
+ return { type: "customEmoji", offset: obj.offset, length: obj.length, customEmojiId: String(obj.documentId) };
59
59
  }
60
60
  else {
61
61
  return null;
@@ -68,7 +68,7 @@ export function messageEntityToTlObject(entity) {
68
68
  return new types.MessageEntityMention({ offset, length });
69
69
  case "hashtag":
70
70
  return new types.MessageEntityHashtag({ offset, length });
71
- case "bot_command":
71
+ case "botCommand":
72
72
  return new types.MessageEntityBotCommand({ offset, length });
73
73
  case "url":
74
74
  return new types.MessageEntityURL({ offset, length });
@@ -82,13 +82,13 @@ export function messageEntityToTlObject(entity) {
82
82
  return new types.MessageEntityCode({ offset, length });
83
83
  case "pre":
84
84
  return new types.MessageEntityPre({ offset, length, language: entity.language });
85
- case "text_link":
85
+ case "textLink":
86
86
  return new types.MessageEntityTextURL({ offset, length, url: entity.url });
87
- case "text_mention":
87
+ case "textMention":
88
88
  return new types.MessageEntityMentionName({ offset, length, userId: BigInt(entity.userId) });
89
89
  case "cashtag":
90
90
  return new types.MessageEntityCashtag({ offset, length });
91
- case "phone_number":
91
+ case "phoneNumber":
92
92
  return new types.MessageEntityPhone({ offset, length });
93
93
  case "underline":
94
94
  return new types.MessageEntityUnderline({ offset, length });
@@ -96,11 +96,11 @@ export function messageEntityToTlObject(entity) {
96
96
  return new types.MessageEntityStrike({ offset, length });
97
97
  case "blockquote":
98
98
  return new types.MessageEntityBlockquote({ offset, length });
99
- case "bank_card":
99
+ case "bankCard":
100
100
  return new types.MessageEntityBankCard({ offset, length });
101
101
  case "spoiler":
102
102
  return new types.MessageEntitySpoiler({ offset, length });
103
- case "custom_emoji":
103
+ case "customEmoji":
104
104
  return new types.MessageEntityCustomEmoji({ offset, length, documentId: BigInt(entity.customEmojiId) });
105
105
  }
106
106
  }
@@ -1,12 +1,7 @@
1
1
  import { types } from "../2_tl.js";
2
2
  import { Color } from "./0_color.js";
3
3
  import { ChatPhoto } from "./0_chat_photo.js";
4
- export declare enum ChatType {
5
- Private = "private",
6
- Group = "group",
7
- Supergroup = "supergroup",
8
- Channel = "channel"
9
- }
4
+ export type ChatType = "private" | "group" | "supergroup" | "channel";
10
5
  export declare namespace Chat {
11
6
  interface Base {
12
7
  /** Type of chat, can be either "private", "group", "supergroup" or "channel" */
@@ -18,7 +13,7 @@ export declare namespace Chat {
18
13
  photo?: ChatPhoto;
19
14
  }
20
15
  interface Private extends Base {
21
- type: ChatType.Private;
16
+ type: "private";
22
17
  /** True, if this user is a bot */
23
18
  isBot?: boolean;
24
19
  /** First name of the other party in a private chat */
@@ -45,7 +40,7 @@ export declare namespace Chat {
45
40
  restrictionReason?: types.RestrictionReason[];
46
41
  }
47
42
  interface Group extends Base {
48
- type: ChatType.Group;
43
+ type: "group";
49
44
  /** Title, for supergroups, channels and group chats */
50
45
  title: string;
51
46
  /** Chat photo. */
@@ -74,7 +69,7 @@ export declare namespace Chat {
74
69
  restrictionReason?: types.RestrictionReason[];
75
70
  }
76
71
  interface Channel extends ChannelBase {
77
- type: ChatType.Channel;
72
+ type: "channel";
78
73
  /** Title, for supergroups, channels and group chats */
79
74
  title: string;
80
75
  /** Username, for private chats, supergroups and channels if available */
@@ -83,7 +78,7 @@ export declare namespace Chat {
83
78
  also?: string[];
84
79
  }
85
80
  interface Supergroup extends ChannelBase {
86
- type: ChatType.Supergroup;
81
+ type: "supergroup";
87
82
  /** True, if the supergroup chat is a forum (has [topics](https://telegram.org/blog/topics-in-groups-collectible-usernames#topics-in-groups) enabled) */
88
83
  isForum: boolean;
89
84
  }
@@ -3,18 +3,11 @@ import { types } from "../2_tl.js";
3
3
  import { ZERO_CHANNEL_ID } from "../4_constants.js";
4
4
  import { getColor } from "./0_color.js";
5
5
  import { constructChatPhoto } from "./0_chat_photo.js";
6
- export var ChatType;
7
- (function (ChatType) {
8
- ChatType["Private"] = "private";
9
- ChatType["Group"] = "group";
10
- ChatType["Supergroup"] = "supergroup";
11
- ChatType["Channel"] = "channel";
12
- })(ChatType || (ChatType = {}));
13
6
  export function constructChat(chat) {
14
7
  if (chat instanceof types.User) {
15
8
  const id = Number(chat.id);
16
9
  const chat_ = {
17
- type: ChatType.Private,
10
+ type: "private",
18
11
  isBot: chat.bot || false,
19
12
  id,
20
13
  color: getColor(id),
@@ -37,7 +30,7 @@ export function constructChat(chat) {
37
30
  else if (chat instanceof types.Chat) {
38
31
  const id = Number(-chat.id);
39
32
  const chat_ = {
40
- type: ChatType.Group,
33
+ type: "group",
41
34
  id,
42
35
  color: getColor(id),
43
36
  title: chat.title,
@@ -56,7 +49,7 @@ export function constructChat(chat) {
56
49
  chat_ = {
57
50
  id,
58
51
  color: getColor(id),
59
- type: ChatType.Supergroup,
52
+ type: "supergroup",
60
53
  title,
61
54
  isScam,
62
55
  isFake,
@@ -70,7 +63,7 @@ export function constructChat(chat) {
70
63
  chat_ = {
71
64
  id,
72
65
  color: getColor(id),
73
- type: ChatType.Channel,
66
+ type: "channel",
74
67
  title,
75
68
  isScam,
76
69
  isFake,
@@ -8,8 +8,8 @@ export interface Sticker {
8
8
  fileId: string;
9
9
  /** Unique identifier for this file, which is supposed to be the same over time and for different users and bots. Can't be used to download or reuse the file. */
10
10
  fileUniqueId: string;
11
- /** Type of the sticker, currently one of "regular", "mask", "custom_emoji". The type of the sticker is independent from its format, which is determined by the fields is_animated and is_video. */
12
- type: "regular" | "mask" | "custom_emoji";
11
+ /** Type of the sticker, currently one of "regular", "mask", "customEmoji". The type of the sticker is independent from its format, which is determined by the fields is_animated and is_video. */
12
+ type: "regular" | "mask" | "customEmoji";
13
13
  /** Sticker width */
14
14
  width: number;
15
15
  /** Sticker height */
@@ -9,7 +9,7 @@ export async function constructSticker(document, fileId, fileUniqueId, getSticke
9
9
  return {
10
10
  fileId,
11
11
  fileUniqueId,
12
- // TODO: custom_emoji type?
12
+ // TODO: custom emoji type?
13
13
  type: stickerAttribute.mask ? "mask" : "regular",
14
14
  width: imageSizeAttribute ? imageSizeAttribute.w : videoAttribute ? videoAttribute.w : 512,
15
15
  height: imageSizeAttribute ? imageSizeAttribute.h : videoAttribute ? videoAttribute.h : 512,
@@ -12,7 +12,7 @@ import { constructVenue } from "./0_venue.js";
12
12
  import { constructLocation } from "./0_location.js";
13
13
  import { constructDice } from "./0_dice.js";
14
14
  import { constructReplyKeyboardRemove } from "./0_reply_keyboard_remove.js";
15
- import { ChatType, constructChat } from "./1_chat.js";
15
+ import { constructChat } from "./1_chat.js";
16
16
  import { constructPhoto } from "./1_photo.js";
17
17
  import { constructDocument } from "./1_document.js";
18
18
  import { constructVideo } from "./1_video.js";
@@ -117,10 +117,10 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
117
117
  }
118
118
  }
119
119
  else if (message_.action instanceof types.MessageActionChannelCreate) {
120
- if (message.chat.type == ChatType.Channel) {
120
+ if (message.chat.type == "channel") {
121
121
  message.channelCreated = true;
122
122
  }
123
- else if (message.chat.type == ChatType.Supergroup) {
123
+ else if (message.chat.type == "supergroup") {
124
124
  message.supergroupCreated = true;
125
125
  }
126
126
  else {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "module": "./esm/mod.js",
3
3
  "main": "./script/mod.js",
4
4
  "name": "@mtkruto/node",
5
- "version": "0.0.996",
5
+ "version": "0.0.998",
6
6
  "description": "MTKruto for Node.js",
7
7
  "author": "Roj <rojvv@icloud.com>",
8
8
  "license": "LGPL-3.0-or-later",
@@ -1,8 +1,8 @@
1
- export * from "./deps/deno.land/std@0.200.0/assert/mod.js";
1
+ export * from "./deps/deno.land/std@0.201.0/assert/mod.js";
2
2
  export { ctr256Decrypt, ctr256Encrypt, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.1.3/mod.js";
3
3
  export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/main/gzip/gzip.js";
4
4
  export { Mutex, type MutexInterface } from "async-mutex";
5
5
  export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
6
6
  import { debug as debug_ } from "./deps/raw.githubusercontent.com/MTKruto/debug/main/mod.js";
7
7
  export declare const debug: typeof debug_;
8
- export { decode as base64Decode, encode as base64Encode } from "./deps/deno.land/std@0.200.0/encoding/base64.js";
8
+ export { decode as base64Decode, encode as base64Encode } from "./deps/deno.land/std@0.201.0/encoding/base64.js";
package/script/0_deps.js CHANGED
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.base64Encode = exports.base64Decode = exports.debug = exports.Parser = exports.Mutex = exports.gzip = exports.gunzip = exports.initTgCrypto = exports.ige256Encrypt = exports.ige256Decrypt = exports.factorize = exports.ctr256Encrypt = exports.ctr256Decrypt = void 0;
18
- __exportStar(require("./deps/deno.land/std@0.200.0/assert/mod.js"), exports);
18
+ __exportStar(require("./deps/deno.land/std@0.201.0/assert/mod.js"), exports);
19
19
  var mod_js_1 = require("./deps/deno.land/x/tgcrypto@0.1.3/mod.js");
20
20
  Object.defineProperty(exports, "ctr256Decrypt", { enumerable: true, get: function () { return mod_js_1.ctr256Decrypt; } });
21
21
  Object.defineProperty(exports, "ctr256Encrypt", { enumerable: true, get: function () { return mod_js_1.ctr256Encrypt; } });
@@ -33,6 +33,6 @@ Object.defineProperty(exports, "Parser", { enumerable: true, get: function () {
33
33
  const mod_js_3 = require("./deps/raw.githubusercontent.com/MTKruto/debug/main/mod.js");
34
34
  const debug = (v) => (0, mod_js_3.debug)(v);
35
35
  exports.debug = debug;
36
- var base64_js_1 = require("./deps/deno.land/std@0.200.0/encoding/base64.js");
36
+ var base64_js_1 = require("./deps/deno.land/std@0.201.0/encoding/base64.js");
37
37
  Object.defineProperty(exports, "base64Decode", { enumerable: true, get: function () { return base64_js_1.decode; } });
38
38
  Object.defineProperty(exports, "base64Encode", { enumerable: true, get: function () { return base64_js_1.encode; } });
@@ -1,5 +1,6 @@
1
1
  export * from "./types/!0_file_id.js";
2
2
  export * from "./types/0_audio.js";
3
+ export * from "./types/0_chat_action.js";
3
4
  export * from "./types/0_chat_administrator_rights.js";
4
5
  export * from "./types/0_chat_photo.js";
5
6
  export * from "./types/0_contact.js";
package/script/3_types.js CHANGED
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./types/!0_file_id.js"), exports);
18
18
  __exportStar(require("./types/0_audio.js"), exports);
19
+ __exportStar(require("./types/0_chat_action.js"), exports);
19
20
  __exportStar(require("./types/0_chat_administrator_rights.js"), exports);
20
21
  __exportStar(require("./types/0_chat_photo.js"), exports);
21
22
  __exportStar(require("./types/0_contact.js"), exports);
@@ -5,7 +5,7 @@ export declare const PUBLIC_KEYS: PublicKeys;
5
5
  export declare const VECTOR_CONSTRUCTOR = 481674261;
6
6
  export declare const INITIAL_DC: DC;
7
7
  export declare const LAYER = 161;
8
- export declare const APP_VERSION = "MTKruto 0.0.996";
8
+ export declare const APP_VERSION = "MTKruto 0.0.998";
9
9
  export declare const DEVICE_MODEL: string;
10
10
  export declare const LANG_CODE: string;
11
11
  export declare const LANG_PACK = "";
@@ -80,7 +80,7 @@ exports.PUBLIC_KEYS = Object.freeze([
80
80
  exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
81
81
  exports.INITIAL_DC = "2-test";
82
82
  exports.LAYER = 161;
83
- exports.APP_VERSION = "MTKruto 0.0.996";
83
+ exports.APP_VERSION = "MTKruto 0.0.998";
84
84
  // @ts-ignore: lib
85
85
  exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
86
86
  exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
@@ -30,7 +30,7 @@ function parseHtml(html) {
30
30
  if (!url) {
31
31
  throw new Error("Missing attribute href");
32
32
  }
33
- queue.push({ type: "text_link", offset: text.length, length: 0, url });
33
+ queue.push({ type: "textLink", offset: text.length, length: 0, url });
34
34
  break;
35
35
  }
36
36
  case "ins":
@@ -2,7 +2,7 @@ import { MaybePromise } from "../1_utilities.js";
2
2
  import { CallbackQuery, ForceReply, InlineKeyboardMarkup, InlineQuery, Message, MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "../3_types.js";
3
3
  import { With } from "./0_utilities.js";
4
4
  import { ClientPlainParams } from "./2_client_plain.js";
5
- export type ParseMode = "html" | "none";
5
+ export type ParseMode = "HTML" | null;
6
6
  export interface ClientParams extends ClientPlainParams {
7
7
  /**
8
8
  * A parse mode to use when the `parseMode` parameter is not specified when sending or editing messages. Defauls to `ParseMode.None`.
@@ -196,7 +196,7 @@ export interface SendPollParams {
196
196
  */
197
197
  protectContent?: boolean;
198
198
  }
199
- export type ConnectionState = "not-connected" | "updating" | "ready";
199
+ export type ConnectionState = "notConnected" | "updating" | "ready";
200
200
  export type AuthorizationState = {
201
201
  authorized: boolean;
202
202
  };
@@ -217,3 +217,4 @@ export interface Handler<U extends Partial<Update> = Partial<Update>> {
217
217
  export type FilterUpdate<U extends Update, T extends keyof U, F extends keyof NonNullable<U[T]>> = With<U, T> & Pick<{
218
218
  [P in T]-?: With<NonNullable<U[T]>, F>;
219
219
  }, T>;
220
+ export declare const skip: Handler;
@@ -1,2 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.skip = void 0;
4
+ const skip = (__, _) => _();
5
+ exports.skip = skip;
@@ -2,7 +2,7 @@ import { MaybePromise } from "../1_utilities.js";
2
2
  import { functions, ReadObject, types } from "../2_tl.js";
3
3
  import { Storage } from "../3_storage.js";
4
4
  import { DC } from "../3_transport.js";
5
- import { Message } from "../3_types.js";
5
+ import { ChatAction, Message } from "../3_types.js";
6
6
  import { With } from "./0_utilities.js";
7
7
  import { ClientAbstract } from "./1_client_abstract.js";
8
8
  import { AnswerCallbackQueryParams, AuthorizeUserParams, ChatID, ClientParams, EditMessageParams, FilterableUpdates, FilterUpdate, ForwardMessagesParams, Handler, ParseMode, SendMessagesParams, SendPollParams, Update } from "./3_types.js";
@@ -36,7 +36,6 @@ export declare class Client extends ClientAbstract {
36
36
  * @param storage The storage provider to use. Defaults to memory storage.
37
37
  * @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
38
38
  * @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
39
- * @param params Other parameters.
40
39
  */
41
40
  constructor(storage?: Storage, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
42
41
  private propagateConnectionState;
@@ -203,10 +202,18 @@ export declare class Client extends ClientAbstract {
203
202
  * @param options The poll's options.
204
203
  */
205
204
  sendPoll(chatId: ChatID, question: string, options: [string, string, ...string[]], params?: SendPollParams): Promise<With<Message, "poll">>;
205
+ /**
206
+ * Send a chat action.
207
+ *
208
+ * @param chatId The chat to send the chat action to.
209
+ * @param action The chat action.
210
+ * @param messageThreadId The thread to send the chat action to.
211
+ */
212
+ sendChatAction(chatId: ChatID, action_: ChatAction, messageThreadId?: number): Promise<void>;
206
213
  private handle;
207
214
  use(handler: Handler): void;
208
215
  branch(predicate: (upd: Update) => MaybePromise<boolean>, trueHandler: Handler, falseHandler: Handler): void;
209
- filter<D extends Update>(predicate: (ctx: Update) => ctx is D, handler: Handler<D>): void;
210
- filter(predicate: (ctx: Update) => MaybePromise<boolean>, handler: Handler): void;
216
+ filter<D extends Update>(predicate: (update: Update) => update is D, handler: Handler<D>): void;
217
+ filter(predicate: (update: Update) => MaybePromise<boolean>, handler: Handler): void;
211
218
  on<T extends keyof Update, F extends keyof NonNullable<Update[T]>>(filter: T extends FilterableUpdates ? T | [T, F, ...F[]] : T, handler: Handler<FilterUpdate<Update, T, F>>): void;
212
219
  }
@@ -13,6 +13,7 @@ const _0_password_js_1 = require("./0_password.js");
13
13
  const _0_html_js_1 = require("./0_html.js");
14
14
  const _2_client_plain_js_1 = require("./2_client_plain.js");
15
15
  const _1_client_abstract_js_1 = require("./1_client_abstract.js");
16
+ const _3_types_js_2 = require("./3_types.js");
16
17
  const d = (0, _0_deps_js_1.debug)("Client");
17
18
  const dGap = (0, _0_deps_js_1.debug)("Client/recoverUpdateGap");
18
19
  const dGapC = (0, _0_deps_js_1.debug)("Client/recoverChannelUpdateGap");
@@ -30,7 +31,6 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
30
31
  * @param storage The storage provider to use. Defaults to memory storage.
31
32
  * @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
32
33
  * @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
33
- * @param params Other parameters.
34
34
  */
35
35
  constructor(storage = new _3_storage_js_1.StorageMemory(), apiId = 0, apiHash = "", params) {
36
36
  super(params);
@@ -155,7 +155,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
155
155
  value: ((connected) => {
156
156
  this.connectMutex.acquire().then(async (release) => {
157
157
  try {
158
- const connectionState = connected ? "ready" : "not-connected";
158
+ const connectionState = connected ? "ready" : "notConnected";
159
159
  if (this.connected == connected && this.lastPropagatedConnectionState != connectionState) {
160
160
  await this.propagateConnectionState(connectionState);
161
161
  this.lastPropagatedConnectionState = connectionState;
@@ -219,9 +219,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
219
219
  enumerable: true,
220
220
  configurable: true,
221
221
  writable: true,
222
- value: _0_utilities_js_1.resolve
222
+ value: _3_types_js_2.skip
223
223
  });
224
- this.parseMode = params?.parseMode ?? "none";
224
+ this.parseMode = params?.parseMode ?? null;
225
225
  this.appVersion = params?.appVersion ?? _4_constants_js_1.APP_VERSION;
226
226
  this.deviceModel = params?.deviceModel ?? _4_constants_js_1.DEVICE_MODEL;
227
227
  this.langCode = params?.langCode ?? _4_constants_js_1.LANG_CODE;
@@ -1180,8 +1180,11 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1180
1180
  return messages;
1181
1181
  }
1182
1182
  async resolveSendAs(params) {
1183
- await this.assertUser("sendAs");
1184
- return params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined;
1183
+ const sendAs = params?.sendAs;
1184
+ if (sendAs !== undefined) {
1185
+ await this.assertUser("sendAs");
1186
+ return sendAs ? await this.getInputPeer(sendAs) : undefined;
1187
+ }
1185
1188
  }
1186
1189
  /**
1187
1190
  * Send a text message.
@@ -1219,9 +1222,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1219
1222
  const entities_ = params?.entities ?? [];
1220
1223
  const parseMode = params?.parseMode ?? this.parseMode;
1221
1224
  switch (parseMode) {
1222
- case "none":
1225
+ case null:
1223
1226
  break;
1224
- case "html": {
1227
+ case "HTML": {
1225
1228
  const [newText, entitiesToPush] = (0, _0_html_js_1.parseHtml)(text);
1226
1229
  text = newText;
1227
1230
  for (const entity of entitiesToPush) {
@@ -1586,6 +1589,54 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1586
1589
  const message = await this.updatesToMessages(chatId, result).then((v) => v[0]);
1587
1590
  return Client.assertMsgHas(message, "poll");
1588
1591
  }
1592
+ /**
1593
+ * Send a chat action.
1594
+ *
1595
+ * @param chatId The chat to send the chat action to.
1596
+ * @param action The chat action.
1597
+ * @param messageThreadId The thread to send the chat action to.
1598
+ */
1599
+ async sendChatAction(chatId, action_, messageThreadId) {
1600
+ let action;
1601
+ switch (action_) {
1602
+ case "type":
1603
+ action = new _2_tl_js_1.types.SendMessageTypingAction();
1604
+ break;
1605
+ case "uploadPhoto":
1606
+ action = new _2_tl_js_1.types.SendMessageUploadPhotoAction({ progress: 0 });
1607
+ break;
1608
+ case "recordVideo":
1609
+ action = new _2_tl_js_1.types.SendMessageRecordVideoAction();
1610
+ break;
1611
+ case "uploadVideo":
1612
+ action = new _2_tl_js_1.types.SendMessageRecordVideoAction();
1613
+ break;
1614
+ case "recordVoice":
1615
+ action = new _2_tl_js_1.types.SendMessageRecordAudioAction();
1616
+ break;
1617
+ case "uploadAudio":
1618
+ action = new _2_tl_js_1.types.SendMessageUploadAudioAction({ progress: 0 });
1619
+ break;
1620
+ case "uploadDocument":
1621
+ action = new _2_tl_js_1.types.SendMessageUploadDocumentAction({ progress: 0 });
1622
+ break;
1623
+ case "chooseSticker":
1624
+ action = new _2_tl_js_1.types.SendMessageChooseStickerAction();
1625
+ break;
1626
+ case "findLocation":
1627
+ action = new _2_tl_js_1.types.SendMessageGeoLocationAction();
1628
+ break;
1629
+ case "recordVideoNote":
1630
+ action = new _2_tl_js_1.types.SendMessageRecordRoundAction();
1631
+ break;
1632
+ case "uploadVideoNote":
1633
+ action = new _2_tl_js_1.types.SendMessageUploadRoundAction({ progress: 0 });
1634
+ break;
1635
+ default:
1636
+ throw new Error("Invalid chat action: " + action_);
1637
+ }
1638
+ await this.invoke(new _2_tl_js_1.functions.MessagesSetTyping({ peer: await this.getInputPeer(chatId), action, topMsgId: messageThreadId }));
1639
+ }
1589
1640
  use(handler) {
1590
1641
  const handle = this.handle;
1591
1642
  this.handle = async (upd, next) => {
@@ -1609,7 +1660,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1609
1660
  });
1610
1661
  }
1611
1662
  filter(predicate, handler) {
1612
- this.branch(predicate, handler, _0_utilities_js_1.resolve);
1663
+ this.branch(predicate, handler, _3_types_js_2.skip);
1613
1664
  }
1614
1665
  on(filter, handler) {
1615
1666
  const type = typeof filter === "string" ? filter : filter[0];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Make an assertion that `actual` is greater than `expected`.
3
+ * If not then throw.
4
+ */
5
+ export declare function assertGreater<T>(actual: T, expected: T, msg?: string): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertGreater = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const _format_js_1 = require("./_format.js");
6
+ const assertion_error_js_1 = require("./assertion_error.js");
7
+ /**
8
+ * Make an assertion that `actual` is greater than `expected`.
9
+ * If not then throw.
10
+ */
11
+ function assertGreater(actual, expected, msg) {
12
+ if (actual > expected)
13
+ return;
14
+ const actualString = (0, _format_js_1.format)(actual);
15
+ const expectedString = (0, _format_js_1.format)(expected);
16
+ throw new assertion_error_js_1.AssertionError(msg ?? `Expect ${actualString} > ${expectedString}`);
17
+ }
18
+ exports.assertGreater = assertGreater;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Make an assertion that `actual` is greater than or equal to `expected`.
3
+ * If not then throw.
4
+ */
5
+ export declare function assertGreaterOrEqual<T>(actual: T, expected: T, msg?: string): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertGreaterOrEqual = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const _format_js_1 = require("./_format.js");
6
+ const assertion_error_js_1 = require("./assertion_error.js");
7
+ /**
8
+ * Make an assertion that `actual` is greater than or equal to `expected`.
9
+ * If not then throw.
10
+ */
11
+ function assertGreaterOrEqual(actual, expected, msg) {
12
+ if (actual >= expected)
13
+ return;
14
+ const actualString = (0, _format_js_1.format)(actual);
15
+ const expectedString = (0, _format_js_1.format)(expected);
16
+ throw new assertion_error_js_1.AssertionError(msg ?? `Expect ${actualString} >= ${expectedString}`);
17
+ }
18
+ exports.assertGreaterOrEqual = assertGreaterOrEqual;
@@ -25,11 +25,11 @@ function assertInstanceOf(actual, expectedType, msg = "") {
25
25
  else {
26
26
  actualTypeStr = typeof actual;
27
27
  }
28
- if (expectedTypeStr == actualTypeStr) {
28
+ if (expectedTypeStr === actualTypeStr) {
29
29
  msg =
30
30
  `Expected object to be an instance of "${expectedTypeStr}"${msgSuffix}`;
31
31
  }
32
- else if (actualTypeStr == "function") {
32
+ else if (actualTypeStr === "function") {
33
33
  msg =
34
34
  `Expected object to be an instance of "${expectedTypeStr}" but was not an instanced object${msgSuffix}`;
35
35
  }
@@ -23,7 +23,10 @@ ErrorClass, msgIncludes, msg) {
23
23
  }
24
24
  if (msgIncludes && (!(error instanceof Error) ||
25
25
  !(0, colors_js_1.stripColor)(error.message).includes((0, colors_js_1.stripColor)(msgIncludes)))) {
26
- msg = `Expected error message to include "${msgIncludes}", but got "${error instanceof Error ? error.message : "[not an Error]"}"${msgSuffix}`;
26
+ msg = `Expected error message to include ${JSON.stringify(msgIncludes)}, but got ${error instanceof Error
27
+ ? JSON.stringify(error.message)
28
+ : '"[not an Error]"' // TODO(kt3k): show more useful information
29
+ }${msgSuffix}`;
27
30
  throw new assertion_error_js_1.AssertionError(msg);
28
31
  }
29
32
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Make an assertion that `actual` is less than `expected`.
3
+ * If not then throw.
4
+ */
5
+ export declare function assertLess<T>(actual: T, expected: T, msg?: string): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertLess = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const _format_js_1 = require("./_format.js");
6
+ const assertion_error_js_1 = require("./assertion_error.js");
7
+ /**
8
+ * Make an assertion that `actual` is less than `expected`.
9
+ * If not then throw.
10
+ */
11
+ function assertLess(actual, expected, msg) {
12
+ if (actual < expected)
13
+ return;
14
+ const actualString = (0, _format_js_1.format)(actual);
15
+ const expectedString = (0, _format_js_1.format)(expected);
16
+ throw new assertion_error_js_1.AssertionError(msg ?? `Expect ${actualString} < ${expectedString}`);
17
+ }
18
+ exports.assertLess = assertLess;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Make an assertion that `actual` is less than or equal to `expected`.
3
+ * If not then throw.
4
+ */
5
+ export declare function assertLessOrEqual<T>(actual: T, expected: T, msg?: string): void;