typenative 0.1.2 → 0.2.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.
Files changed (504) hide show
  1. package/.gitattributes +1 -0
  2. package/.github/workflows/ci.yml +1 -1
  3. package/.github/workflows/npm-publish-github-packages.yml +1 -1
  4. package/CHANGELOG.md +247 -0
  5. package/CONTRIBUTION.md +1 -1
  6. package/README.md +30 -21
  7. package/bin/cli.js +3 -1
  8. package/bin/go/bridge.js +919 -0
  9. package/bin/go/convert.js +238 -0
  10. package/bin/go/metadata.js +211 -0
  11. package/bin/go/overrides.js +68 -0
  12. package/bin/go/stdlib.generated.js +175 -0
  13. package/bin/index.js +98 -6
  14. package/bin/main.js +4 -1
  15. package/bin/node/assert.js +344 -0
  16. package/bin/node/async_hooks.js +273 -0
  17. package/bin/node/buffer.js +765 -0
  18. package/bin/node/child_process.js +600 -0
  19. package/bin/node/cluster.js +1002 -0
  20. package/bin/node/console.js +121 -0
  21. package/bin/node/core.js +111 -0
  22. package/bin/node/crypto.js +414 -0
  23. package/bin/node/crypto_keys.js +2685 -0
  24. package/bin/node/dgram.js +388 -0
  25. package/bin/node/diagnostics_channel.js +534 -0
  26. package/bin/node/dns.js +635 -0
  27. package/bin/node/events.js +743 -0
  28. package/bin/node/fetch.js +737 -0
  29. package/bin/node/fs.js +998 -0
  30. package/bin/node/http.js +1500 -0
  31. package/bin/node/http2.js +688 -0
  32. package/bin/node/net.js +1143 -0
  33. package/bin/node/os.js +257 -0
  34. package/bin/node/path.js +758 -0
  35. package/bin/node/process.js +316 -0
  36. package/bin/node/punycode.js +195 -0
  37. package/bin/node/querystring.js +143 -0
  38. package/bin/node/readline.js +299 -0
  39. package/bin/node/registry.js +161 -0
  40. package/bin/node/sqlite.js +1142 -0
  41. package/bin/node/stream.js +1221 -0
  42. package/bin/node/stream_web.js +2259 -0
  43. package/bin/node/string_decoder.js +101 -0
  44. package/bin/node/system_extra.js +661 -0
  45. package/bin/node/test.js +1068 -0
  46. package/bin/node/timers.js +250 -0
  47. package/bin/node/tls.js +719 -0
  48. package/bin/node/url.js +861 -0
  49. package/bin/node/util.js +1311 -0
  50. package/bin/node/util_extra.js +599 -0
  51. package/bin/node/worker_threads.js +745 -0
  52. package/bin/node/zlib.js +263 -0
  53. package/bin/parse-native.js +3 -2
  54. package/bin/parse-node.js +18 -2
  55. package/bin/transpiler.js +3529 -597
  56. package/bin/version.js +2 -0
  57. package/conformance.md +724 -258
  58. package/govendor/github.com/ncruces/go-sqlite3/LICENSE +21 -0
  59. package/govendor/github.com/ncruces/go-sqlite3/README.md +121 -0
  60. package/govendor/github.com/ncruces/go-sqlite3/backup.go +132 -0
  61. package/govendor/github.com/ncruces/go-sqlite3/blob.go +266 -0
  62. package/govendor/github.com/ncruces/go-sqlite3/config.go +397 -0
  63. package/govendor/github.com/ncruces/go-sqlite3/conn.go +540 -0
  64. package/govendor/github.com/ncruces/go-sqlite3/conn_127.go +93 -0
  65. package/govendor/github.com/ncruces/go-sqlite3/const.go +436 -0
  66. package/govendor/github.com/ncruces/go-sqlite3/context.go +222 -0
  67. package/govendor/github.com/ncruces/go-sqlite3/error.go +182 -0
  68. package/govendor/github.com/ncruces/go-sqlite3/ext.go +153 -0
  69. package/govendor/github.com/ncruces/go-sqlite3/func.go +309 -0
  70. package/govendor/github.com/ncruces/go-sqlite3/go.mod +3 -0
  71. package/govendor/github.com/ncruces/go-sqlite3/internal/dotlk/dotlk.go +29 -0
  72. package/govendor/github.com/ncruces/go-sqlite3/internal/dotlk/dotlk_other.go +13 -0
  73. package/govendor/github.com/ncruces/go-sqlite3/internal/dotlk/dotlk_unix.go +57 -0
  74. package/govendor/github.com/ncruces/go-sqlite3/internal/errutil/error.go +41 -0
  75. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/alloc.go +128 -0
  76. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/const.go +122 -0
  77. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/error.go +77 -0
  78. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/mem.go +116 -0
  79. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/mem_other.go +34 -0
  80. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/mem_unix.go +87 -0
  81. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/mem_windows.go +149 -0
  82. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/mmap_unix.go +80 -0
  83. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/mmap_windows.go +129 -0
  84. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/sys_windows.go +60 -0
  85. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/wrap.go +82 -0
  86. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/wrap_sys.go +113 -0
  87. package/govendor/github.com/ncruces/go-sqlite3/internal/sqlite3_wrap/wrap_vfs.go +181 -0
  88. package/govendor/github.com/ncruces/go-sqlite3/internal/testenv/env.go +55 -0
  89. package/govendor/github.com/ncruces/go-sqlite3/internal/util/json.go +54 -0
  90. package/govendor/github.com/ncruces/go-sqlite3/internal/util/json_v2.go +54 -0
  91. package/govendor/github.com/ncruces/go-sqlite3/internal/util/math.go +29 -0
  92. package/govendor/github.com/ncruces/go-sqlite3/internal/util/page.go +5 -0
  93. package/govendor/github.com/ncruces/go-sqlite3/internal/util/parse.go +142 -0
  94. package/govendor/github.com/ncruces/go-sqlite3/internal/util/pointer.go +3 -0
  95. package/govendor/github.com/ncruces/go-sqlite3/internal/util/reflect.go +10 -0
  96. package/govendor/github.com/ncruces/go-sqlite3/json.go +100 -0
  97. package/govendor/github.com/ncruces/go-sqlite3/json_v2.go +116 -0
  98. package/govendor/github.com/ncruces/go-sqlite3/pointer.go +13 -0
  99. package/govendor/github.com/ncruces/go-sqlite3/quote.go +140 -0
  100. package/govendor/github.com/ncruces/go-sqlite3/stmt.go +692 -0
  101. package/govendor/github.com/ncruces/go-sqlite3/time.go +360 -0
  102. package/govendor/github.com/ncruces/go-sqlite3/txn.go +374 -0
  103. package/govendor/github.com/ncruces/go-sqlite3/value.go +212 -0
  104. package/govendor/github.com/ncruces/go-sqlite3/vfs/README.md +133 -0
  105. package/govendor/github.com/ncruces/go-sqlite3/vfs/api.go +239 -0
  106. package/govendor/github.com/ncruces/go-sqlite3/vfs/cksm.go +143 -0
  107. package/govendor/github.com/ncruces/go-sqlite3/vfs/const.go +256 -0
  108. package/govendor/github.com/ncruces/go-sqlite3/vfs/file.go +260 -0
  109. package/govendor/github.com/ncruces/go-sqlite3/vfs/filename.go +187 -0
  110. package/govendor/github.com/ncruces/go-sqlite3/vfs/lock.go +128 -0
  111. package/govendor/github.com/ncruces/go-sqlite3/vfs/lock_other.go +23 -0
  112. package/govendor/github.com/ncruces/go-sqlite3/vfs/map.go +63 -0
  113. package/govendor/github.com/ncruces/go-sqlite3/vfs/map_other.go +13 -0
  114. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go +110 -0
  115. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_darwin.go +131 -0
  116. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_dotlk.go +140 -0
  117. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_f2fs_linux.go +56 -0
  118. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go +117 -0
  119. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_ofd.go +59 -0
  120. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_std.go +50 -0
  121. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_std_alloc.go +19 -0
  122. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_std_atomic.go +9 -0
  123. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_std_rw.go +13 -0
  124. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_std_sync.go +9 -0
  125. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_std_temp.go +16 -0
  126. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_unix.go +108 -0
  127. package/govendor/github.com/ncruces/go-sqlite3/vfs/os_windows.go +180 -0
  128. package/govendor/github.com/ncruces/go-sqlite3/vfs/registry.go +48 -0
  129. package/govendor/github.com/ncruces/go-sqlite3/vfs/shm.go +26 -0
  130. package/govendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go +258 -0
  131. package/govendor/github.com/ncruces/go-sqlite3/vfs/shm_copy.go +90 -0
  132. package/govendor/github.com/ncruces/go-sqlite3/vfs/shm_dotlk.go +168 -0
  133. package/govendor/github.com/ncruces/go-sqlite3/vfs/shm_memlk.go +52 -0
  134. package/govendor/github.com/ncruces/go-sqlite3/vfs/shm_ofd.go +185 -0
  135. package/govendor/github.com/ncruces/go-sqlite3/vfs/shm_other.go +21 -0
  136. package/govendor/github.com/ncruces/go-sqlite3/vfs/shm_windows.go +124 -0
  137. package/govendor/github.com/ncruces/go-sqlite3/vfs/vfs.go +455 -0
  138. package/govendor/github.com/ncruces/go-sqlite3/vtab.go +677 -0
  139. package/govendor/github.com/ncruces/go-sqlite3/wrap.go +48 -0
  140. package/govendor/github.com/ncruces/go-sqlite3-wasm/v6/LICENSE +18 -0
  141. package/govendor/github.com/ncruces/go-sqlite3-wasm/v6/README.md +11 -0
  142. package/govendor/github.com/ncruces/go-sqlite3-wasm/v6/go.mod +3 -0
  143. package/govendor/github.com/ncruces/go-sqlite3-wasm/v6/libc.go +215 -0
  144. package/govendor/github.com/ncruces/go-sqlite3-wasm/v6/sqlite3.dat +0 -0
  145. package/govendor/github.com/ncruces/go-sqlite3-wasm/v6/sqlite3.go +157903 -0
  146. package/govendor/github.com/ncruces/go-sqlite3-wasm/v6/tools.sh +38 -0
  147. package/govendor/github.com/ncruces/julianday/LICENSE +21 -0
  148. package/govendor/github.com/ncruces/julianday/README.md +9 -0
  149. package/govendor/github.com/ncruces/julianday/go.mod +3 -0
  150. package/govendor/github.com/ncruces/julianday/julianday.go +124 -0
  151. package/govendor/golang.org/x/sys/LICENSE +27 -0
  152. package/govendor/golang.org/x/sys/PATENTS +22 -0
  153. package/govendor/golang.org/x/sys/go.mod +3 -0
  154. package/govendor/golang.org/x/sys/unix/README.md +184 -0
  155. package/govendor/golang.org/x/sys/unix/affinity_linux.go +189 -0
  156. package/govendor/golang.org/x/sys/unix/aliases.go +13 -0
  157. package/govendor/golang.org/x/sys/unix/asm_aix_ppc64.s +17 -0
  158. package/govendor/golang.org/x/sys/unix/asm_bsd_386.s +27 -0
  159. package/govendor/golang.org/x/sys/unix/asm_bsd_amd64.s +27 -0
  160. package/govendor/golang.org/x/sys/unix/asm_bsd_arm.s +27 -0
  161. package/govendor/golang.org/x/sys/unix/asm_bsd_arm64.s +27 -0
  162. package/govendor/golang.org/x/sys/unix/asm_bsd_ppc64.s +29 -0
  163. package/govendor/golang.org/x/sys/unix/asm_bsd_riscv64.s +27 -0
  164. package/govendor/golang.org/x/sys/unix/asm_linux_386.s +65 -0
  165. package/govendor/golang.org/x/sys/unix/asm_linux_amd64.s +57 -0
  166. package/govendor/golang.org/x/sys/unix/asm_linux_arm.s +56 -0
  167. package/govendor/golang.org/x/sys/unix/asm_linux_arm64.s +50 -0
  168. package/govendor/golang.org/x/sys/unix/asm_linux_loong64.s +51 -0
  169. package/govendor/golang.org/x/sys/unix/asm_linux_mips64x.s +54 -0
  170. package/govendor/golang.org/x/sys/unix/asm_linux_mipsx.s +52 -0
  171. package/govendor/golang.org/x/sys/unix/asm_linux_ppc64x.s +42 -0
  172. package/govendor/golang.org/x/sys/unix/asm_linux_riscv64.s +47 -0
  173. package/govendor/golang.org/x/sys/unix/asm_linux_s390x.s +54 -0
  174. package/govendor/golang.org/x/sys/unix/asm_openbsd_mips64.s +29 -0
  175. package/govendor/golang.org/x/sys/unix/asm_solaris_amd64.s +17 -0
  176. package/govendor/golang.org/x/sys/unix/asm_zos_s390x.s +382 -0
  177. package/govendor/golang.org/x/sys/unix/auxv.go +36 -0
  178. package/govendor/golang.org/x/sys/unix/auxv_unsupported.go +13 -0
  179. package/govendor/golang.org/x/sys/unix/bluetooth_linux.go +36 -0
  180. package/govendor/golang.org/x/sys/unix/bpxsvc_zos.go +657 -0
  181. package/govendor/golang.org/x/sys/unix/bpxsvc_zos.s +192 -0
  182. package/govendor/golang.org/x/sys/unix/cap_freebsd.go +195 -0
  183. package/govendor/golang.org/x/sys/unix/constants.go +13 -0
  184. package/govendor/golang.org/x/sys/unix/dev_aix_ppc.go +26 -0
  185. package/govendor/golang.org/x/sys/unix/dev_aix_ppc64.go +28 -0
  186. package/govendor/golang.org/x/sys/unix/dev_darwin.go +24 -0
  187. package/govendor/golang.org/x/sys/unix/dev_dragonfly.go +30 -0
  188. package/govendor/golang.org/x/sys/unix/dev_freebsd.go +30 -0
  189. package/govendor/golang.org/x/sys/unix/dev_linux.go +42 -0
  190. package/govendor/golang.org/x/sys/unix/dev_netbsd.go +29 -0
  191. package/govendor/golang.org/x/sys/unix/dev_openbsd.go +29 -0
  192. package/govendor/golang.org/x/sys/unix/dev_zos.go +28 -0
  193. package/govendor/golang.org/x/sys/unix/dirent.go +102 -0
  194. package/govendor/golang.org/x/sys/unix/endian_big.go +9 -0
  195. package/govendor/golang.org/x/sys/unix/endian_little.go +9 -0
  196. package/govendor/golang.org/x/sys/unix/env_unix.go +31 -0
  197. package/govendor/golang.org/x/sys/unix/fcntl.go +36 -0
  198. package/govendor/golang.org/x/sys/unix/fcntl_darwin.go +24 -0
  199. package/govendor/golang.org/x/sys/unix/fcntl_linux_32bit.go +13 -0
  200. package/govendor/golang.org/x/sys/unix/fdset.go +27 -0
  201. package/govendor/golang.org/x/sys/unix/gccgo.go +59 -0
  202. package/govendor/golang.org/x/sys/unix/gccgo_c.c +44 -0
  203. package/govendor/golang.org/x/sys/unix/gccgo_linux_amd64.go +20 -0
  204. package/govendor/golang.org/x/sys/unix/ifreq_linux.go +145 -0
  205. package/govendor/golang.org/x/sys/unix/ioctl_linux.go +341 -0
  206. package/govendor/golang.org/x/sys/unix/ioctl_signed.go +74 -0
  207. package/govendor/golang.org/x/sys/unix/ioctl_unsigned.go +74 -0
  208. package/govendor/golang.org/x/sys/unix/ioctl_zos.go +71 -0
  209. package/govendor/golang.org/x/sys/unix/mkall.sh +250 -0
  210. package/govendor/golang.org/x/sys/unix/mkerrors.sh +807 -0
  211. package/govendor/golang.org/x/sys/unix/mmap_nomremap.go +13 -0
  212. package/govendor/golang.org/x/sys/unix/mremap.go +57 -0
  213. package/govendor/golang.org/x/sys/unix/pagesize_unix.go +15 -0
  214. package/govendor/golang.org/x/sys/unix/pledge_openbsd.go +111 -0
  215. package/govendor/golang.org/x/sys/unix/ptrace_darwin.go +11 -0
  216. package/govendor/golang.org/x/sys/unix/ptrace_ios.go +11 -0
  217. package/govendor/golang.org/x/sys/unix/race.go +30 -0
  218. package/govendor/golang.org/x/sys/unix/race0.go +25 -0
  219. package/govendor/golang.org/x/sys/unix/readdirent_getdents.go +12 -0
  220. package/govendor/golang.org/x/sys/unix/readdirent_getdirentries.go +19 -0
  221. package/govendor/golang.org/x/sys/unix/readv_unix.go +103 -0
  222. package/govendor/golang.org/x/sys/unix/sockcmsg_dragonfly.go +16 -0
  223. package/govendor/golang.org/x/sys/unix/sockcmsg_linux.go +85 -0
  224. package/govendor/golang.org/x/sys/unix/sockcmsg_unix.go +106 -0
  225. package/govendor/golang.org/x/sys/unix/sockcmsg_unix_other.go +46 -0
  226. package/govendor/golang.org/x/sys/unix/sockcmsg_zos.go +58 -0
  227. package/govendor/golang.org/x/sys/unix/symaddr_zos_s390x.s +75 -0
  228. package/govendor/golang.org/x/sys/unix/syscall.go +86 -0
  229. package/govendor/golang.org/x/sys/unix/syscall_aix.go +582 -0
  230. package/govendor/golang.org/x/sys/unix/syscall_aix_ppc.go +52 -0
  231. package/govendor/golang.org/x/sys/unix/syscall_aix_ppc64.go +83 -0
  232. package/govendor/golang.org/x/sys/unix/syscall_bsd.go +609 -0
  233. package/govendor/golang.org/x/sys/unix/syscall_darwin.go +711 -0
  234. package/govendor/golang.org/x/sys/unix/syscall_darwin_amd64.go +50 -0
  235. package/govendor/golang.org/x/sys/unix/syscall_darwin_arm64.go +50 -0
  236. package/govendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go +26 -0
  237. package/govendor/golang.org/x/sys/unix/syscall_dragonfly.go +359 -0
  238. package/govendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go +56 -0
  239. package/govendor/golang.org/x/sys/unix/syscall_freebsd.go +455 -0
  240. package/govendor/golang.org/x/sys/unix/syscall_freebsd_386.go +64 -0
  241. package/govendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go +64 -0
  242. package/govendor/golang.org/x/sys/unix/syscall_freebsd_arm.go +60 -0
  243. package/govendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go +60 -0
  244. package/govendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go +60 -0
  245. package/govendor/golang.org/x/sys/unix/syscall_hurd.go +30 -0
  246. package/govendor/golang.org/x/sys/unix/syscall_hurd_386.go +28 -0
  247. package/govendor/golang.org/x/sys/unix/syscall_illumos.go +78 -0
  248. package/govendor/golang.org/x/sys/unix/syscall_linux.go +2574 -0
  249. package/govendor/golang.org/x/sys/unix/syscall_linux_386.go +313 -0
  250. package/govendor/golang.org/x/sys/unix/syscall_linux_alarm.go +12 -0
  251. package/govendor/golang.org/x/sys/unix/syscall_linux_amd64.go +144 -0
  252. package/govendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go +12 -0
  253. package/govendor/golang.org/x/sys/unix/syscall_linux_arm.go +218 -0
  254. package/govendor/golang.org/x/sys/unix/syscall_linux_arm64.go +188 -0
  255. package/govendor/golang.org/x/sys/unix/syscall_linux_gc.go +14 -0
  256. package/govendor/golang.org/x/sys/unix/syscall_linux_gc_386.go +16 -0
  257. package/govendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go +13 -0
  258. package/govendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go +30 -0
  259. package/govendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go +20 -0
  260. package/govendor/golang.org/x/sys/unix/syscall_linux_loong64.go +220 -0
  261. package/govendor/golang.org/x/sys/unix/syscall_linux_mips64x.go +187 -0
  262. package/govendor/golang.org/x/sys/unix/syscall_linux_mipsx.go +173 -0
  263. package/govendor/golang.org/x/sys/unix/syscall_linux_ppc.go +203 -0
  264. package/govendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +114 -0
  265. package/govendor/golang.org/x/sys/unix/syscall_linux_riscv64.go +193 -0
  266. package/govendor/golang.org/x/sys/unix/syscall_linux_s390x.go +295 -0
  267. package/govendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +111 -0
  268. package/govendor/golang.org/x/sys/unix/syscall_netbsd.go +388 -0
  269. package/govendor/golang.org/x/sys/unix/syscall_netbsd_386.go +37 -0
  270. package/govendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go +37 -0
  271. package/govendor/golang.org/x/sys/unix/syscall_netbsd_arm.go +37 -0
  272. package/govendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go +37 -0
  273. package/govendor/golang.org/x/sys/unix/syscall_openbsd.go +346 -0
  274. package/govendor/golang.org/x/sys/unix/syscall_openbsd_386.go +41 -0
  275. package/govendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go +41 -0
  276. package/govendor/golang.org/x/sys/unix/syscall_openbsd_arm.go +41 -0
  277. package/govendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go +41 -0
  278. package/govendor/golang.org/x/sys/unix/syscall_openbsd_libc.go +26 -0
  279. package/govendor/golang.org/x/sys/unix/syscall_openbsd_mips64.go +39 -0
  280. package/govendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go +41 -0
  281. package/govendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go +41 -0
  282. package/govendor/golang.org/x/sys/unix/syscall_solaris.go +1183 -0
  283. package/govendor/golang.org/x/sys/unix/syscall_solaris_amd64.go +27 -0
  284. package/govendor/golang.org/x/sys/unix/syscall_unix.go +619 -0
  285. package/govendor/golang.org/x/sys/unix/syscall_unix_gc.go +14 -0
  286. package/govendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go +22 -0
  287. package/govendor/golang.org/x/sys/unix/syscall_zos_s390x.go +3213 -0
  288. package/govendor/golang.org/x/sys/unix/sysvshm_linux.go +20 -0
  289. package/govendor/golang.org/x/sys/unix/sysvshm_unix.go +51 -0
  290. package/govendor/golang.org/x/sys/unix/sysvshm_unix_other.go +13 -0
  291. package/govendor/golang.org/x/sys/unix/timestruct.go +76 -0
  292. package/govendor/golang.org/x/sys/unix/unveil_openbsd.go +51 -0
  293. package/govendor/golang.org/x/sys/unix/vgetrandom_linux.go +13 -0
  294. package/govendor/golang.org/x/sys/unix/vgetrandom_unsupported.go +11 -0
  295. package/govendor/golang.org/x/sys/unix/xattr_bsd.go +280 -0
  296. package/govendor/golang.org/x/sys/unix/zerrors_aix_ppc.go +1384 -0
  297. package/govendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go +1385 -0
  298. package/govendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +1922 -0
  299. package/govendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +1922 -0
  300. package/govendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go +1737 -0
  301. package/govendor/golang.org/x/sys/unix/zerrors_freebsd_386.go +2042 -0
  302. package/govendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go +2039 -0
  303. package/govendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go +2033 -0
  304. package/govendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go +2033 -0
  305. package/govendor/golang.org/x/sys/unix/zerrors_freebsd_riscv64.go +2147 -0
  306. package/govendor/golang.org/x/sys/unix/zerrors_linux.go +4209 -0
  307. package/govendor/golang.org/x/sys/unix/zerrors_linux_386.go +882 -0
  308. package/govendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +882 -0
  309. package/govendor/golang.org/x/sys/unix/zerrors_linux_arm.go +887 -0
  310. package/govendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +884 -0
  311. package/govendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +874 -0
  312. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips.go +888 -0
  313. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +888 -0
  314. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +888 -0
  315. package/govendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +888 -0
  316. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +940 -0
  317. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +944 -0
  318. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +944 -0
  319. package/govendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +884 -0
  320. package/govendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +943 -0
  321. package/govendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +992 -0
  322. package/govendor/golang.org/x/sys/unix/zerrors_netbsd_386.go +1779 -0
  323. package/govendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go +1769 -0
  324. package/govendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go +1758 -0
  325. package/govendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go +1769 -0
  326. package/govendor/golang.org/x/sys/unix/zerrors_openbsd_386.go +1905 -0
  327. package/govendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go +1905 -0
  328. package/govendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go +1905 -0
  329. package/govendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go +1905 -0
  330. package/govendor/golang.org/x/sys/unix/zerrors_openbsd_mips64.go +1905 -0
  331. package/govendor/golang.org/x/sys/unix/zerrors_openbsd_ppc64.go +1904 -0
  332. package/govendor/golang.org/x/sys/unix/zerrors_openbsd_riscv64.go +1903 -0
  333. package/govendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go +1556 -0
  334. package/govendor/golang.org/x/sys/unix/zerrors_zos_s390x.go +990 -0
  335. package/govendor/golang.org/x/sys/unix/zptrace_armnn_linux.go +40 -0
  336. package/govendor/golang.org/x/sys/unix/zptrace_linux_arm64.go +17 -0
  337. package/govendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go +49 -0
  338. package/govendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go +49 -0
  339. package/govendor/golang.org/x/sys/unix/zptrace_x86_linux.go +79 -0
  340. package/govendor/golang.org/x/sys/unix/zsymaddr_zos_s390x.s +364 -0
  341. package/govendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go +1461 -0
  342. package/govendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go +1420 -0
  343. package/govendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go +1188 -0
  344. package/govendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go +1069 -0
  345. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +2728 -0
  346. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +799 -0
  347. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +2728 -0
  348. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +799 -0
  349. package/govendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go +1666 -0
  350. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +1886 -0
  351. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +1886 -0
  352. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +1886 -0
  353. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +1886 -0
  354. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go +1886 -0
  355. package/govendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go +101 -0
  356. package/govendor/golang.org/x/sys/unix/zsyscall_linux.go +2267 -0
  357. package/govendor/golang.org/x/sys/unix/zsyscall_linux_386.go +469 -0
  358. package/govendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +636 -0
  359. package/govendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +584 -0
  360. package/govendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +535 -0
  361. package/govendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go +469 -0
  362. package/govendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +636 -0
  363. package/govendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +630 -0
  364. package/govendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +619 -0
  365. package/govendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +636 -0
  366. package/govendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go +641 -0
  367. package/govendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +687 -0
  368. package/govendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +687 -0
  369. package/govendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go +531 -0
  370. package/govendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +478 -0
  371. package/govendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +631 -0
  372. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +1848 -0
  373. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +1848 -0
  374. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +1848 -0
  375. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +1848 -0
  376. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +2407 -0
  377. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +719 -0
  378. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +2407 -0
  379. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +719 -0
  380. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +2407 -0
  381. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +719 -0
  382. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +2407 -0
  383. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +719 -0
  384. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +2407 -0
  385. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +719 -0
  386. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +2407 -0
  387. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +862 -0
  388. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +2407 -0
  389. package/govendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +719 -0
  390. package/govendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +2217 -0
  391. package/govendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go +3458 -0
  392. package/govendor/golang.org/x/sys/unix/zsysctl_openbsd_386.go +280 -0
  393. package/govendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go +280 -0
  394. package/govendor/golang.org/x/sys/unix/zsysctl_openbsd_arm.go +280 -0
  395. package/govendor/golang.org/x/sys/unix/zsysctl_openbsd_arm64.go +280 -0
  396. package/govendor/golang.org/x/sys/unix/zsysctl_openbsd_mips64.go +280 -0
  397. package/govendor/golang.org/x/sys/unix/zsysctl_openbsd_ppc64.go +280 -0
  398. package/govendor/golang.org/x/sys/unix/zsysctl_openbsd_riscv64.go +281 -0
  399. package/govendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go +439 -0
  400. package/govendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go +437 -0
  401. package/govendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go +316 -0
  402. package/govendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go +393 -0
  403. package/govendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go +393 -0
  404. package/govendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go +393 -0
  405. package/govendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go +393 -0
  406. package/govendor/golang.org/x/sys/unix/zsysnum_freebsd_riscv64.go +393 -0
  407. package/govendor/golang.org/x/sys/unix/zsysnum_linux_386.go +470 -0
  408. package/govendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +394 -0
  409. package/govendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +434 -0
  410. package/govendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +337 -0
  411. package/govendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +334 -0
  412. package/govendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +454 -0
  413. package/govendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +384 -0
  414. package/govendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +384 -0
  415. package/govendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +454 -0
  416. package/govendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +461 -0
  417. package/govendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +433 -0
  418. package/govendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +433 -0
  419. package/govendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +338 -0
  420. package/govendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +399 -0
  421. package/govendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +413 -0
  422. package/govendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go +274 -0
  423. package/govendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go +274 -0
  424. package/govendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go +274 -0
  425. package/govendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go +274 -0
  426. package/govendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go +219 -0
  427. package/govendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go +219 -0
  428. package/govendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go +219 -0
  429. package/govendor/golang.org/x/sys/unix/zsysnum_openbsd_arm64.go +218 -0
  430. package/govendor/golang.org/x/sys/unix/zsysnum_openbsd_mips64.go +221 -0
  431. package/govendor/golang.org/x/sys/unix/zsysnum_openbsd_ppc64.go +217 -0
  432. package/govendor/golang.org/x/sys/unix/zsysnum_openbsd_riscv64.go +218 -0
  433. package/govendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go +2852 -0
  434. package/govendor/golang.org/x/sys/unix/ztypes_aix_ppc.go +353 -0
  435. package/govendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go +357 -0
  436. package/govendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +878 -0
  437. package/govendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +878 -0
  438. package/govendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go +473 -0
  439. package/govendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +651 -0
  440. package/govendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +656 -0
  441. package/govendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +642 -0
  442. package/govendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +636 -0
  443. package/govendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go +638 -0
  444. package/govendor/golang.org/x/sys/unix/ztypes_linux.go +6547 -0
  445. package/govendor/golang.org/x/sys/unix/ztypes_linux_386.go +747 -0
  446. package/govendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +761 -0
  447. package/govendor/golang.org/x/sys/unix/ztypes_linux_arm.go +741 -0
  448. package/govendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +740 -0
  449. package/govendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +741 -0
  450. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips.go +746 -0
  451. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +743 -0
  452. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +743 -0
  453. package/govendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +746 -0
  454. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +754 -0
  455. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +749 -0
  456. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +749 -0
  457. package/govendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +828 -0
  458. package/govendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +763 -0
  459. package/govendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +744 -0
  460. package/govendor/golang.org/x/sys/unix/ztypes_netbsd_386.go +585 -0
  461. package/govendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go +593 -0
  462. package/govendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go +590 -0
  463. package/govendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go +593 -0
  464. package/govendor/golang.org/x/sys/unix/ztypes_openbsd_386.go +568 -0
  465. package/govendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go +568 -0
  466. package/govendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go +575 -0
  467. package/govendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go +568 -0
  468. package/govendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go +568 -0
  469. package/govendor/golang.org/x/sys/unix/ztypes_openbsd_ppc64.go +570 -0
  470. package/govendor/golang.org/x/sys/unix/ztypes_openbsd_riscv64.go +570 -0
  471. package/govendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go +516 -0
  472. package/govendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +552 -0
  473. package/govendor/golang.org/x/sys/windows/aliases.go +13 -0
  474. package/govendor/golang.org/x/sys/windows/dll_windows.go +380 -0
  475. package/govendor/golang.org/x/sys/windows/env_windows.go +57 -0
  476. package/govendor/golang.org/x/sys/windows/eventlog.go +20 -0
  477. package/govendor/golang.org/x/sys/windows/exec_windows.go +248 -0
  478. package/govendor/golang.org/x/sys/windows/memory_windows.go +48 -0
  479. package/govendor/golang.org/x/sys/windows/mkerrors.bash +70 -0
  480. package/govendor/golang.org/x/sys/windows/mkknownfolderids.bash +27 -0
  481. package/govendor/golang.org/x/sys/windows/mksyscall.go +9 -0
  482. package/govendor/golang.org/x/sys/windows/race.go +30 -0
  483. package/govendor/golang.org/x/sys/windows/race0.go +25 -0
  484. package/govendor/golang.org/x/sys/windows/security_windows.go +1537 -0
  485. package/govendor/golang.org/x/sys/windows/service.go +257 -0
  486. package/govendor/golang.org/x/sys/windows/setupapi_windows.go +1425 -0
  487. package/govendor/golang.org/x/sys/windows/str.go +22 -0
  488. package/govendor/golang.org/x/sys/windows/syscall.go +104 -0
  489. package/govendor/golang.org/x/sys/windows/syscall_windows.go +1952 -0
  490. package/govendor/golang.org/x/sys/windows/types_windows.go +4058 -0
  491. package/govendor/golang.org/x/sys/windows/types_windows_386.go +35 -0
  492. package/govendor/golang.org/x/sys/windows/types_windows_amd64.go +34 -0
  493. package/govendor/golang.org/x/sys/windows/types_windows_arm.go +35 -0
  494. package/govendor/golang.org/x/sys/windows/types_windows_arm64.go +34 -0
  495. package/govendor/golang.org/x/sys/windows/zerrors_windows.go +9468 -0
  496. package/govendor/golang.org/x/sys/windows/zknownfolderids_windows.go +149 -0
  497. package/govendor/golang.org/x/sys/windows/zsyscall_windows.go +4828 -0
  498. package/govendor/manifest.txt +7 -0
  499. package/package.json +6 -1
  500. package/tsparser/main.go +37 -3
  501. package/tsparser/tsparser.exe +2 -2
  502. package/types/typenative-go.d.ts +15159 -5
  503. package/types/typenative-npm.d.ts +2637 -30
  504. package/types/typenative.d.ts +1092 -56
@@ -0,0 +1,1311 @@
1
+ // node:util (+ node:util/types, node:sys): inspect / format (Node's layout
2
+ // rules, ported), isDeepStrictEqual, types.*, deprecate, styleText,
3
+ // stripVTControlCharacters. console.log formats non-string arguments with it.
4
+ import { defineHelper, defineModule, setResults } from './registry.js';
5
+ const utilHelper = `// node:util — inspect / format over TypeNative values (Node's layout rules)
6
+ type tnInspector struct {
7
+ depth float64
8
+ breakLength int
9
+ compact int
10
+ indentationLvl int
11
+ currentDepth int
12
+ seen []uintptr
13
+ circular map[uintptr]int
14
+ topIsMap bool
15
+ }
16
+
17
+ func tnNewInspector(options ...interface{}) *tnInspector {
18
+ ins := &tnInspector{depth: 2, breakLength: 80, compact: 3, circular: map[uintptr]int{}}
19
+ if len(options) > 0 && options[0] != nil {
20
+ opts := options[0]
21
+ if d, ok := TnGet(opts, "depth").(float64); ok {
22
+ ins.depth = d
23
+ } else if TnHas(opts, "depth") && TnGet(opts, "depth") == nil {
24
+ ins.depth = math.Inf(1)
25
+ }
26
+ if b, ok := TnGet(opts, "breakLength").(float64); ok {
27
+ if math.IsInf(b, 1) {
28
+ ins.breakLength = math.MaxInt32
29
+ } else {
30
+ ins.breakLength = int(b)
31
+ }
32
+ }
33
+ if c, ok := TnGet(opts, "compact").(float64); ok {
34
+ ins.compact = int(c)
35
+ } else if c, ok := TnGet(opts, "compact").(bool); ok && !c {
36
+ ins.compact = 0
37
+ }
38
+ }
39
+ return ins
40
+ }
41
+
42
+ // util.inspect(value, options?)
43
+ func TnInspect(v interface{}, options ...interface{}) string {
44
+ return tnNewInspector(options...).format(v, 0)
45
+ }
46
+
47
+ // util.inspect of a Map<K, V> variable (Records and Maps share TnMap)
48
+ func TnInspectMap(v interface{}, options ...interface{}) string {
49
+ ins := tnNewInspector(options...)
50
+ ins.topIsMap = true
51
+ return ins.format(v, 0)
52
+ }
53
+
54
+ var tnIdentifierKey = regexp.MustCompile("^[A-Za-z_$][A-Za-z0-9_$]*$")
55
+
56
+ // Node's strEscape: single quotes unless the string contains them
57
+ func tnQuoteJS(s string) string {
58
+ quote := byte('\\'')
59
+ if strings.Contains(s, "'") {
60
+ if !strings.Contains(s, "\\"") {
61
+ quote = '"'
62
+ } else if !strings.Contains(s, "\`") && !strings.Contains(s, "\${") {
63
+ quote = '\`'
64
+ }
65
+ }
66
+ var sb strings.Builder
67
+ sb.WriteByte(quote)
68
+ for _, r := range s {
69
+ switch {
70
+ case r == rune(quote) || r == '\\\\':
71
+ sb.WriteByte('\\\\')
72
+ sb.WriteRune(r)
73
+ case r == '\\n':
74
+ sb.WriteString("\\\\n")
75
+ case r == '\\t':
76
+ sb.WriteString("\\\\t")
77
+ case r == '\\r':
78
+ sb.WriteString("\\\\r")
79
+ case r == '\\b':
80
+ sb.WriteString("\\\\b")
81
+ case r == '\\f':
82
+ sb.WriteString("\\\\f")
83
+ case r == '\\v':
84
+ sb.WriteString("\\\\v")
85
+ case r < 0x20 || r == 0x7f:
86
+ sb.WriteString(fmt.Sprintf("\\\\x%02X", r))
87
+ default:
88
+ sb.WriteRune(r)
89
+ }
90
+ }
91
+ sb.WriteByte(quote)
92
+ return sb.String()
93
+ }
94
+
95
+ func tnInspectNumber(f float64) string {
96
+ if f == 0 && math.Signbit(f) {
97
+ return "-0"
98
+ }
99
+ return TnNumStr(f)
100
+ }
101
+
102
+ func tnInspectKey(k string) string {
103
+ if tnIdentifierKey.MatchString(k) {
104
+ return k
105
+ }
106
+ return tnQuoteJS(k)
107
+ }
108
+
109
+ // A struct field read through a pointer (unexported fields too)
110
+ func tnFieldValue(rv reflect.Value, i int) interface{} {
111
+ f := rv.Field(i)
112
+ if f.CanAddr() {
113
+ return reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Elem().Interface()
114
+ }
115
+ return nil
116
+ }
117
+
118
+ type tnField struct {
119
+ name string
120
+ value interface{}
121
+ }
122
+
123
+ // Fields of a struct, embedded structs flattened (class inheritance embeds the parent)
124
+ func tnStructFields(rv reflect.Value) ([]tnField, *TnError) {
125
+ if !rv.CanAddr() {
126
+ tmp := reflect.New(rv.Type()).Elem()
127
+ tmp.Set(rv)
128
+ rv = tmp
129
+ }
130
+ fields := []tnField{}
131
+ var embeddedError *TnError
132
+ t := rv.Type()
133
+ for i := 0; i < t.NumField(); i++ {
134
+ sf := t.Field(i)
135
+ if sf.Anonymous {
136
+ if sf.Type == reflect.TypeOf(TnError{}) {
137
+ e := tnFieldValue(rv, i).(TnError)
138
+ embeddedError = &e
139
+ continue
140
+ }
141
+ if sf.Type.Kind() == reflect.Struct {
142
+ inner, innerErr := tnStructFields(rv.Field(i))
143
+ if innerErr != nil {
144
+ embeddedError = innerErr
145
+ }
146
+ fields = append(fields, inner...)
147
+ continue
148
+ }
149
+ }
150
+ if strings.HasPrefix(sf.Name, "__") {
151
+ continue
152
+ }
153
+ name := strings.TrimSuffix(sf.Name, "_")
154
+ fields = append(fields, tnField{name: name, value: tnFieldValue(rv, i)})
155
+ }
156
+ return fields, embeddedError
157
+ }
158
+
159
+ func tnFunctionName(rv reflect.Value) string {
160
+ fn := runtime.FuncForPC(rv.Pointer())
161
+ if fn != nil {
162
+ name := fn.Name()
163
+ if strings.HasPrefix(name, "main.") {
164
+ name = name[5:]
165
+ if !strings.Contains(name, ".") && !strings.HasPrefix(name, "Tn") {
166
+ return "[Function: " + name + "]"
167
+ }
168
+ }
169
+ }
170
+ return "[Function (anonymous)]"
171
+ }
172
+
173
+ func (ins *tnInspector) format(v interface{}, depth int) string {
174
+ switch x := v.(type) {
175
+ case nil:
176
+ return "undefined"
177
+ case string:
178
+ return tnQuoteJS(x)
179
+ case float64:
180
+ return tnInspectNumber(x)
181
+ case bool:
182
+ if x {
183
+ return "true"
184
+ }
185
+ return "false"
186
+ case int:
187
+ return strconv.Itoa(x)
188
+ case *tnbig.Int:
189
+ if x == nil {
190
+ return "null"
191
+ }
192
+ return x.String() + "n"
193
+ case []byte:
194
+ return TnBufferInspect(x)
195
+ case time.Time:
196
+ return x.UTC().Format("2006-01-02T15:04:05.000Z07:00")
197
+ case *regexp.Regexp:
198
+ if x == nil {
199
+ return "null"
200
+ }
201
+ return "/" + x.String() + "/"
202
+ case *TnError:
203
+ if x == nil {
204
+ return "null"
205
+ }
206
+ return ins.formatError(x, x.Get_name(), nil, depth)
207
+ }
208
+ if reflect.TypeOf(v).String() == "*main.TnSymbol" {
209
+ return fmt.Sprintf("Symbol(%v)", TnGet(v, "description"))
210
+ }
211
+ rv := reflect.ValueOf(v)
212
+ switch rv.Kind() {
213
+ case reflect.Func:
214
+ if rv.IsNil() {
215
+ return "null"
216
+ }
217
+ return tnFunctionName(rv)
218
+ case reflect.Chan:
219
+ return "Promise { <pending> }"
220
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
221
+ return strconv.FormatInt(rv.Int(), 10)
222
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
223
+ return strconv.FormatUint(rv.Uint(), 10)
224
+ case reflect.Float32:
225
+ return tnInspectNumber(rv.Float())
226
+ case reflect.String:
227
+ return tnQuoteJS(rv.String())
228
+ case reflect.Interface:
229
+ if rv.IsNil() {
230
+ return "undefined"
231
+ }
232
+ return ins.format(rv.Elem().Interface(), depth)
233
+ case reflect.Slice, reflect.Array:
234
+ if rv.Kind() == reflect.Slice && rv.IsNil() {
235
+ return "[]"
236
+ }
237
+ return ins.formatCompound(v, rv, depth)
238
+ case reflect.Map:
239
+ if rv.IsNil() {
240
+ return "{}"
241
+ }
242
+ return ins.formatCompound(v, rv, depth)
243
+ case reflect.Pointer:
244
+ if rv.IsNil() {
245
+ return "null"
246
+ }
247
+ if rv.Elem().Kind() == reflect.Slice {
248
+ return ins.format(rv.Elem().Interface(), depth)
249
+ }
250
+ if rv.Elem().Kind() == reflect.Struct {
251
+ return ins.formatCompound(v, rv, depth)
252
+ }
253
+ return ins.format(rv.Elem().Interface(), depth)
254
+ case reflect.Struct:
255
+ return ins.formatCompound(v, rv, depth)
256
+ }
257
+ if e, ok := v.(error); ok {
258
+ return e.Error()
259
+ }
260
+ return fmt.Sprint(v)
261
+ }
262
+
263
+ func (ins *tnInspector) formatError(e *TnError, name string, fields []tnField, depth int) string {
264
+ base := name + ": " + e.message
265
+ if e.message == "" {
266
+ base = name
267
+ }
268
+ out := []string{}
269
+ if e.code != "" {
270
+ out = append(out, "code: "+tnQuoteJS(e.code))
271
+ }
272
+ for _, key := range []string{"syscall", "path", "errno"} {
273
+ if val := e.prop(key); val != nil {
274
+ out = append(out, key+": "+ins.format(val, depth+1))
275
+ }
276
+ }
277
+ for _, f := range fields {
278
+ out = append(out, tnInspectKey(f.name)+": "+ins.format(f.value, depth+1))
279
+ }
280
+ if len(out) == 0 {
281
+ return base
282
+ }
283
+ return base + " {\\n " + strings.Join(out, ",\\n ") + "\\n}"
284
+ }
285
+
286
+ func tnInspectSetLike(rv reflect.Value) bool {
287
+ t := rv.Type()
288
+ if t.Kind() == reflect.Pointer {
289
+ t = t.Elem()
290
+ }
291
+ if t.Kind() != reflect.Struct || t.NumField() < 2 {
292
+ return false
293
+ }
294
+ values := t.Field(1).Type
295
+ return values.Kind() == reflect.Map && values.Elem().Kind() == reflect.Struct && values.Elem().NumField() == 0
296
+ }
297
+
298
+ func (ins *tnInspector) formatCompound(v interface{}, rv reflect.Value, depth int) string {
299
+ var ptr uintptr
300
+ if rv.Kind() == reflect.Pointer || rv.Kind() == reflect.Map || (rv.Kind() == reflect.Slice && rv.Len() > 0) {
301
+ ptr = rv.Pointer()
302
+ if rv.Kind() == reflect.Slice {
303
+ ptr = 0
304
+ }
305
+ }
306
+ if ptr != 0 {
307
+ for _, s := range ins.seen {
308
+ if s == ptr {
309
+ idx, ok := ins.circular[ptr]
310
+ if !ok {
311
+ idx = len(ins.circular) + 1
312
+ ins.circular[ptr] = idx
313
+ }
314
+ return fmt.Sprintf("[Circular *%d]", idx)
315
+ }
316
+ }
317
+ }
318
+ // What kind of value: array, Map, Set, object, class instance
319
+ kind := "object"
320
+ prefix := ""
321
+ var entries [][]interface{}
322
+ var fields []tnField
323
+ var embeddedError *TnError
324
+ isTop := depth == 0
325
+ if withEntries, ok := v.(interface{ Entries() [][]interface{} }); ok {
326
+ entries = withEntries.Entries()
327
+ if tnInspectSetLike(rv) {
328
+ kind = "set"
329
+ } else {
330
+ kind = "map"
331
+ stringKeys := true
332
+ for _, e := range entries {
333
+ if _, isString := e[0].(string); !isString {
334
+ stringKeys = false
335
+ }
336
+ }
337
+ if stringKeys && !(isTop && ins.topIsMap) {
338
+ kind = "object"
339
+ for _, e := range entries {
340
+ fields = append(fields, tnField{name: e[0].(string), value: e[1]})
341
+ }
342
+ }
343
+ }
344
+ } else {
345
+ switch rv.Kind() {
346
+ case reflect.Slice, reflect.Array:
347
+ kind = "array"
348
+ case reflect.Map:
349
+ keys := rv.MapKeys()
350
+ sort.Slice(keys, func(i, j int) bool { return fmt.Sprint(keys[i].Interface()) < fmt.Sprint(keys[j].Interface()) })
351
+ for _, k := range keys {
352
+ fields = append(fields, tnField{name: fmt.Sprint(k.Interface()), value: rv.MapIndex(k).Interface()})
353
+ }
354
+ default:
355
+ sv := rv
356
+ if sv.Kind() == reflect.Pointer {
357
+ sv = sv.Elem()
358
+ }
359
+ fields, embeddedError = tnStructFields(sv)
360
+ name := sv.Type().Name()
361
+ if embeddedError != nil {
362
+ return ins.formatError(embeddedError, name, fields, depth)
363
+ }
364
+ if tnInspectClassNames[name] {
365
+ prefix = name + " "
366
+ }
367
+ }
368
+ }
369
+ if ins.depth >= 0 && float64(depth) > ins.depth {
370
+ switch kind {
371
+ case "array":
372
+ return "[Array]"
373
+ case "map":
374
+ return "[Map]"
375
+ case "set":
376
+ return "[Set]"
377
+ }
378
+ if prefix != "" {
379
+ return "[" + strings.TrimSpace(prefix) + "]"
380
+ }
381
+ return "[Object]"
382
+ }
383
+ if ptr != 0 {
384
+ ins.seen = append(ins.seen, ptr)
385
+ defer func() { ins.seen = ins.seen[:len(ins.seen)-1] }()
386
+ }
387
+ ins.currentDepth = depth
388
+ output := []string{}
389
+ braces := [2]string{prefix + "{", "}"}
390
+ isArray := false
391
+ ins.indentationLvl += 2
392
+ switch kind {
393
+ case "array":
394
+ isArray = true
395
+ braces = [2]string{"[", "]"}
396
+ n := rv.Len()
397
+ shown := n
398
+ if shown > 100 {
399
+ shown = 100
400
+ }
401
+ for i := 0; i < shown; i++ {
402
+ output = append(output, ins.format(rv.Index(i).Interface(), depth+1))
403
+ }
404
+ if n > shown {
405
+ more := n - shown
406
+ if more == 1 {
407
+ output = append(output, "... 1 more item")
408
+ } else {
409
+ output = append(output, fmt.Sprintf("... %d more items", more))
410
+ }
411
+ }
412
+ case "map":
413
+ braces = [2]string{fmt.Sprintf("Map(%d) {", len(entries)), "}"}
414
+ for _, e := range entries {
415
+ output = append(output, ins.format(e[0], depth+1)+" => "+ins.format(e[1], depth+1))
416
+ }
417
+ case "set":
418
+ braces = [2]string{fmt.Sprintf("Set(%d) {", len(entries)), "}"}
419
+ for _, e := range entries {
420
+ output = append(output, ins.format(e[0], depth+1))
421
+ }
422
+ default:
423
+ for _, f := range fields {
424
+ value := ""
425
+ if fv := reflect.ValueOf(f.value); f.value != nil && fv.Kind() == reflect.Func {
426
+ if fv.IsNil() {
427
+ value = "undefined"
428
+ } else {
429
+ value = "[Function: " + f.name + "]"
430
+ }
431
+ } else {
432
+ value = ins.format(f.value, depth+1)
433
+ }
434
+ output = append(output, tnInspectKey(f.name)+": "+value)
435
+ }
436
+ }
437
+ ins.indentationLvl -= 2
438
+ ref := ""
439
+ if ptr != 0 {
440
+ if idx, ok := ins.circular[ptr]; ok {
441
+ ref = fmt.Sprintf("<ref *%d> ", idx)
442
+ }
443
+ }
444
+ if len(output) == 0 {
445
+ if isArray {
446
+ return ref + "[]"
447
+ }
448
+ return ref + braces[0] + "}"
449
+ }
450
+ return ref + ins.reduceToSingleString(output, braces, isArray, depth, rv)
451
+ }
452
+
453
+ func (ins *tnInspector) isBelowBreakLength(output []string, start int) bool {
454
+ total := len(output) + start
455
+ if total+len(output) > ins.breakLength {
456
+ return false
457
+ }
458
+ for _, o := range output {
459
+ total += len(o)
460
+ if total > ins.breakLength {
461
+ return false
462
+ }
463
+ }
464
+ return true
465
+ }
466
+
467
+ func (ins *tnInspector) reduceToSingleString(output []string, braces [2]string, isArray bool, depth int, rv reflect.Value) string {
468
+ if ins.compact >= 1 {
469
+ entries := len(output)
470
+ if isArray && entries > 6 {
471
+ output = ins.groupArrayElements(output, rv)
472
+ }
473
+ if ins.currentDepth-depth < ins.compact && entries == len(output) {
474
+ start := len(output) + ins.indentationLvl + len(braces[0]) + 10
475
+ if ins.isBelowBreakLength(output, start) {
476
+ joined := strings.Join(output, ", ")
477
+ if !strings.Contains(joined, "\\n") {
478
+ return braces[0] + " " + joined + " " + braces[1]
479
+ }
480
+ }
481
+ }
482
+ }
483
+ indentation := "\\n" + strings.Repeat(" ", ins.indentationLvl)
484
+ return braces[0] + indentation + " " + strings.Join(output, ","+indentation+" ") + indentation + braces[1]
485
+ }
486
+
487
+ // Node's groupArrayElements: long arrays of short entries print in columns
488
+ func (ins *tnInspector) groupArrayElements(output []string, rv reflect.Value) []string {
489
+ totalLength := 0
490
+ maxLength := 0
491
+ outputLength := len(output)
492
+ if strings.HasPrefix(output[len(output)-1], "... ") {
493
+ outputLength--
494
+ }
495
+ separatorSpace := 2
496
+ dataLen := make([]int, outputLength)
497
+ for i := 0; i < outputLength; i++ {
498
+ l := utf8.RuneCountInString(output[i])
499
+ dataLen[i] = l
500
+ totalLength += l + separatorSpace
501
+ if maxLength < l {
502
+ maxLength = l
503
+ }
504
+ }
505
+ actualMax := maxLength + separatorSpace
506
+ if actualMax*3+ins.indentationLvl < ins.breakLength &&
507
+ (float64(totalLength)/float64(actualMax) > 5 || maxLength <= 6) {
508
+ averageBias := math.Sqrt(float64(actualMax) - float64(totalLength)/float64(len(output)))
509
+ biasedMax := math.Max(float64(actualMax)-3-averageBias, 1)
510
+ columns := int(math.Min(math.Min(math.Round(math.Sqrt(2.5*biasedMax*float64(outputLength))/biasedMax),
511
+ math.Floor(float64(ins.breakLength-ins.indentationLvl)/float64(actualMax))),
512
+ math.Min(float64(ins.compact*4), 15)))
513
+ if columns <= 1 {
514
+ return output
515
+ }
516
+ maxLineLength := []int{}
517
+ for i := 0; i < columns; i++ {
518
+ lineLength := 0
519
+ for j := i; j < len(output); j += columns {
520
+ if j < outputLength && dataLen[j] > lineLength {
521
+ lineLength = dataLen[j]
522
+ }
523
+ }
524
+ maxLineLength = append(maxLineLength, lineLength+separatorSpace)
525
+ }
526
+ padStart := true
527
+ for i := 0; i < rv.Len() && i < outputLength; i++ {
528
+ k := reflect.ValueOf(rv.Index(i).Interface()).Kind()
529
+ if k != reflect.Float64 && k != reflect.Int {
530
+ padStart = false
531
+ break
532
+ }
533
+ }
534
+ tmp := []string{}
535
+ for i := 0; i < outputLength; i += columns {
536
+ maxIdx := i + columns
537
+ if maxIdx > outputLength {
538
+ maxIdx = outputLength
539
+ }
540
+ str := ""
541
+ j := i
542
+ for ; j < maxIdx-1; j++ {
543
+ cell := output[j] + ", "
544
+ pad := maxLineLength[j-i] - dataLen[j] - separatorSpace
545
+ if padStart {
546
+ str += strings.Repeat(" ", max(pad, 0)) + cell
547
+ } else {
548
+ str += cell + strings.Repeat(" ", max(pad, 0))
549
+ }
550
+ }
551
+ if padStart {
552
+ pad := maxLineLength[j-i] - separatorSpace - dataLen[j]
553
+ str += strings.Repeat(" ", max(pad, 0)) + output[j]
554
+ } else {
555
+ str += output[j]
556
+ }
557
+ tmp = append(tmp, str)
558
+ }
559
+ if outputLength < len(output) {
560
+ tmp = append(tmp, output[outputLength])
561
+ }
562
+ return tmp
563
+ }
564
+ return output
565
+ }
566
+
567
+ // An argument printed by console.log / util.format: strings as-is
568
+ func tnFormatArg(v interface{}) string {
569
+ if s, ok := v.(string); ok {
570
+ return s
571
+ }
572
+ return TnInspect(v)
573
+ }
574
+
575
+ // console.table(data, [properties]): a box-drawn table of an array / object / Map / Set;
576
+ // anything else is logged as is
577
+ func TnConsoleTableString(data interface{}, properties ...interface{}) string {
578
+ rv := reflect.ValueOf(data)
579
+ var filter []string
580
+ hasFilter := false
581
+ if len(properties) > 0 && properties[0] != nil {
582
+ hasFilter = true
583
+ switch p := properties[0].(type) {
584
+ case []string:
585
+ filter = p
586
+ case []interface{}:
587
+ for _, x := range p {
588
+ filter = append(filter, fmt.Sprint(x))
589
+ }
590
+ }
591
+ }
592
+ type row struct {
593
+ index string
594
+ value interface{}
595
+ }
596
+ rows := []row{}
597
+ indexHeader := "(index)"
598
+ var mapKeys []string
599
+ isMap, isSet := TnIsMapValue(data), TnIsSetValue(data)
600
+ if entries, ok := tnEntriesOf(rv); ok && (isMap || isSet) {
601
+ indexHeader = "(iteration index)"
602
+ for i, e := range entries {
603
+ value := e[1]
604
+ if isSet {
605
+ value = e[0]
606
+ }
607
+ rows = append(rows, row{index: strconv.Itoa(i), value: value})
608
+ if isMap {
609
+ mapKeys = append(mapKeys, TnInspect(e[0]))
610
+ }
611
+ }
612
+ } else if rv.Kind() == reflect.Slice && !tnIsBytes(rv) {
613
+ for i := 0; i < rv.Len(); i++ {
614
+ rows = append(rows, row{index: strconv.Itoa(i), value: rv.Index(i).Interface()})
615
+ }
616
+ } else if fields, _, ok := tnObjectFields(rv); ok && data != nil {
617
+ if rv.Kind() == reflect.Map {
618
+ sort.Slice(fields, func(i, j int) bool { return fields[i].name < fields[j].name })
619
+ }
620
+ for _, f := range fields {
621
+ rows = append(rows, row{index: f.name, value: f.value})
622
+ }
623
+ } else {
624
+ return TnUtilFormat(data)
625
+ }
626
+ columns := []string{}
627
+ cells := map[string]map[int]string{}
628
+ addColumn := func(name string) {
629
+ if _, ok := cells[name]; !ok {
630
+ cells[name] = map[int]string{}
631
+ columns = append(columns, name)
632
+ }
633
+ }
634
+ for _, name := range filter {
635
+ addColumn(name)
636
+ }
637
+ values := map[int]string{}
638
+ hasValues := false
639
+ for i, r := range rows {
640
+ if mapKeys != nil {
641
+ values[i] = TnInspect(r.value)
642
+ hasValues = true
643
+ continue
644
+ }
645
+ vv := reflect.ValueOf(r.value)
646
+ var fields []tnField
647
+ object := false
648
+ if vv.Kind() == reflect.Slice && !tnIsBytes(vv) {
649
+ object = true
650
+ for j := 0; j < vv.Len(); j++ {
651
+ fields = append(fields, tnField{name: strconv.Itoa(j), value: vv.Index(j).Interface()})
652
+ }
653
+ } else if fs, _, ok := tnObjectFields(vv); ok && r.value != nil && !isSet {
654
+ object = true
655
+ fields = fs
656
+ if vv.Kind() == reflect.Map {
657
+ sort.Slice(fields, func(a, b int) bool { return fields[a].name < fields[b].name })
658
+ }
659
+ }
660
+ if !object {
661
+ if !hasFilter {
662
+ values[i] = TnInspect(r.value)
663
+ hasValues = true
664
+ }
665
+ continue
666
+ }
667
+ for _, f := range fields {
668
+ if hasFilter {
669
+ if _, wanted := cells[f.name]; !wanted {
670
+ continue
671
+ }
672
+ } else {
673
+ addColumn(f.name)
674
+ }
675
+ cells[f.name][i] = TnInspect(f.value)
676
+ }
677
+ }
678
+ header := []string{indexHeader}
679
+ if mapKeys != nil {
680
+ header = append(header, "Key")
681
+ }
682
+ header = append(header, columns...)
683
+ if hasValues {
684
+ header = append(header, "Values")
685
+ }
686
+ table := [][]string{}
687
+ for i, r := range rows {
688
+ line := []string{r.index}
689
+ if mapKeys != nil {
690
+ line = append(line, mapKeys[i])
691
+ }
692
+ for _, c := range columns {
693
+ line = append(line, cells[c][i])
694
+ }
695
+ if hasValues {
696
+ line = append(line, values[i])
697
+ }
698
+ table = append(table, line)
699
+ }
700
+ width := func(s string) int { return utf8.RuneCountInString(TnStripVTControlCharacters(s)) }
701
+ widths := make([]int, len(header))
702
+ for i, h := range header {
703
+ widths[i] = width(h) + 2
704
+ for _, line := range table {
705
+ if w := width(line[i]) + 2; w > widths[i] {
706
+ widths[i] = w
707
+ }
708
+ }
709
+ }
710
+ divider := func(left, mid, right string) string {
711
+ parts := make([]string, len(widths))
712
+ for i, w := range widths {
713
+ parts[i] = strings.Repeat("─", w)
714
+ }
715
+ return left + strings.Join(parts, mid) + right
716
+ }
717
+ render := func(line []string) string {
718
+ out := "│"
719
+ for i, cell := range line {
720
+ out += " " + cell + strings.Repeat(" ", widths[i]-1-width(cell)) + "│"
721
+ }
722
+ return out
723
+ }
724
+ out := []string{divider("┌", "┬", "┐"), render(header), divider("├", "┼", "┤")}
725
+ for _, line := range table {
726
+ out = append(out, render(line))
727
+ }
728
+ out = append(out, divider("└", "┴", "┘"))
729
+ return strings.Join(out, "\\n")
730
+ }
731
+
732
+ func tnIsBytes(v reflect.Value) bool {
733
+ return v.Kind() == reflect.Slice && v.Type().Elem().Kind() == reflect.Uint8
734
+ }
735
+
736
+ // util.format(format, ...args) — also console.log's formatting
737
+ func TnUtilFormat(args ...interface{}) string {
738
+ if len(args) == 0 {
739
+ return ""
740
+ }
741
+ // Nullable primitives (optional chaining results) print as their value
742
+ for i, a := range args {
743
+ switch p := a.(type) {
744
+ case *string:
745
+ if p == nil {
746
+ args[i] = nil
747
+ } else {
748
+ args[i] = *p
749
+ }
750
+ case *float64:
751
+ if p == nil {
752
+ args[i] = nil
753
+ } else {
754
+ args[i] = *p
755
+ }
756
+ case *bool:
757
+ if p == nil {
758
+ args[i] = nil
759
+ } else {
760
+ args[i] = *p
761
+ }
762
+ }
763
+ }
764
+ first, isString := args[0].(string)
765
+ if isString && len(args) == 1 {
766
+ return first
767
+ }
768
+ if !isString {
769
+ parts := make([]string, len(args))
770
+ for i, a := range args {
771
+ parts[i] = tnFormatArg(a)
772
+ }
773
+ return strings.Join(parts, " ")
774
+ }
775
+ var sb strings.Builder
776
+ next := 1
777
+ for j := 0; j < len(first); j++ {
778
+ c := first[j]
779
+ if c == '%' && j+1 < len(first) {
780
+ spec := first[j+1]
781
+ if spec == '%' {
782
+ sb.WriteByte('%')
783
+ j++
784
+ continue
785
+ }
786
+ if next < len(args) && strings.IndexByte("sdifjoOc", spec) >= 0 {
787
+ arg := args[next]
788
+ next++
789
+ j++
790
+ switch spec {
791
+ case 's':
792
+ switch x := arg.(type) {
793
+ case string:
794
+ sb.WriteString(x)
795
+ case float64:
796
+ sb.WriteString(tnInspectNumber(x))
797
+ default:
798
+ sb.WriteString(TnInspect(arg, map[string]interface{}{"depth": float64(0)}))
799
+ }
800
+ case 'd', 'i', 'f':
801
+ if b, ok := arg.(*tnbig.Int); ok {
802
+ sb.WriteString(b.String() + "n")
803
+ break
804
+ }
805
+ n := math.NaN()
806
+ switch x := arg.(type) {
807
+ case float64:
808
+ n = x
809
+ case string:
810
+ n = TnParseFloat(x)
811
+ case bool:
812
+ n = TnNumber(x)
813
+ }
814
+ if spec == 'i' {
815
+ n = math.Trunc(n)
816
+ }
817
+ sb.WriteString(tnInspectNumber(n))
818
+ case 'j':
819
+ sb.WriteString(TnJSONStringify(arg, ""))
820
+ case 'o', 'O':
821
+ sb.WriteString(TnInspect(arg))
822
+ case 'c':
823
+ }
824
+ continue
825
+ }
826
+ }
827
+ sb.WriteByte(c)
828
+ }
829
+ for ; next < len(args); next++ {
830
+ sb.WriteString(" ")
831
+ sb.WriteString(tnFormatArg(args[next]))
832
+ }
833
+ return sb.String()
834
+ }
835
+
836
+ // isDeepStrictEqual / assert.deepStrictEqual (strict) and deepEqual (loose)
837
+ func TnDeepEqual(a interface{}, b interface{}, strict bool) bool {
838
+ return tnDeepEqual(reflect.ValueOf(a), reflect.ValueOf(b), strict, 0)
839
+ }
840
+
841
+ func tnDeref(v reflect.Value) reflect.Value {
842
+ for v.IsValid() && v.Kind() == reflect.Interface {
843
+ if v.IsNil() {
844
+ return reflect.Value{}
845
+ }
846
+ v = v.Elem()
847
+ }
848
+ if v.IsValid() && v.Kind() == reflect.Pointer && !v.IsNil() && v.Elem().Kind() == reflect.Slice {
849
+ v = v.Elem()
850
+ }
851
+ return v
852
+ }
853
+
854
+ func tnIsNilValue(v reflect.Value) bool {
855
+ if !v.IsValid() {
856
+ return true
857
+ }
858
+ switch v.Kind() {
859
+ case reflect.Pointer, reflect.Map, reflect.Func, reflect.Chan, reflect.Interface:
860
+ return v.IsNil()
861
+ }
862
+ return false
863
+ }
864
+
865
+ func tnEntriesOf(v reflect.Value) ([][]interface{}, bool) {
866
+ if !v.IsValid() || !v.CanInterface() {
867
+ return nil, false
868
+ }
869
+ if e, ok := v.Interface().(interface{ Entries() [][]interface{} }); ok {
870
+ return e.Entries(), true
871
+ }
872
+ return nil, false
873
+ }
874
+
875
+ // A plain object's properties: structs (class instances, object literals),
876
+ // map[string]interface{} and string-keyed TnMaps (Records); ok=false otherwise
877
+ func tnObjectFields(v reflect.Value) ([]tnField, string, bool) {
878
+ if !v.IsValid() {
879
+ return nil, "", false
880
+ }
881
+ if entries, ok := tnEntriesOf(v); ok {
882
+ if tnInspectSetLike(v) {
883
+ return nil, "", false
884
+ }
885
+ fields := []tnField{}
886
+ for _, e := range entries {
887
+ key, isString := e[0].(string)
888
+ if !isString {
889
+ return nil, "", false
890
+ }
891
+ fields = append(fields, tnField{name: key, value: e[1]})
892
+ }
893
+ return fields, "", true
894
+ }
895
+ switch v.Kind() {
896
+ case reflect.Map:
897
+ if v.Type().Key().Kind() != reflect.String {
898
+ return nil, "", false
899
+ }
900
+ fields := []tnField{}
901
+ for _, k := range v.MapKeys() {
902
+ fields = append(fields, tnField{name: k.String(), value: v.MapIndex(k).Interface()})
903
+ }
904
+ return fields, "", true
905
+ case reflect.Pointer:
906
+ if v.IsNil() || v.Elem().Kind() != reflect.Struct {
907
+ return nil, "", false
908
+ }
909
+ v = v.Elem()
910
+ fallthrough
911
+ case reflect.Struct:
912
+ fields, _ := tnStructFields(v)
913
+ name := v.Type().Name()
914
+ if !tnInspectClassNames[name] {
915
+ name = ""
916
+ }
917
+ return fields, name, true
918
+ }
919
+ return nil, "", false
920
+ }
921
+
922
+ func tnDeepEqualObjects(af []tnField, bf []tnField, strict bool, level int) bool {
923
+ if len(af) != len(bf) {
924
+ return false
925
+ }
926
+ for _, x := range af {
927
+ found := false
928
+ for _, y := range bf {
929
+ if x.name == y.name {
930
+ if !tnDeepEqual(reflect.ValueOf(x.value), reflect.ValueOf(y.value), strict, level+1) {
931
+ return false
932
+ }
933
+ found = true
934
+ break
935
+ }
936
+ }
937
+ if !found {
938
+ return false
939
+ }
940
+ }
941
+ return true
942
+ }
943
+
944
+ func tnDeepEqual(a reflect.Value, b reflect.Value, strict bool, level int) bool {
945
+ a, b = tnDeref(a), tnDeref(b)
946
+ if tnIsNilValue(a) || tnIsNilValue(b) {
947
+ return tnIsNilValue(a) && tnIsNilValue(b)
948
+ }
949
+ if level > 100 {
950
+ return true
951
+ }
952
+ if a.Kind() == reflect.Float64 && b.Kind() == reflect.Float64 {
953
+ x, y := a.Float(), b.Float()
954
+ if math.IsNaN(x) && math.IsNaN(y) {
955
+ return true
956
+ }
957
+ if strict && x == 0 && y == 0 {
958
+ return math.Signbit(x) == math.Signbit(y)
959
+ }
960
+ return x == y
961
+ }
962
+ if !strict && a.Kind() != b.Kind() && a.CanInterface() && b.CanInterface() {
963
+ _, aPrim := a.Interface().(string)
964
+ _, bPrim := b.Interface().(string)
965
+ if aPrim || bPrim || a.Kind() == reflect.Float64 || b.Kind() == reflect.Float64 || a.Kind() == reflect.Bool || b.Kind() == reflect.Bool {
966
+ return TnNumber(a.Interface()) == TnNumber(b.Interface())
967
+ }
968
+ }
969
+ if a.CanInterface() && b.CanInterface() {
970
+ if ab, ok := a.Interface().([]byte); ok {
971
+ if bb, ok := b.Interface().([]byte); ok {
972
+ return bytes.Equal(ab, bb)
973
+ }
974
+ }
975
+ if at, ok := a.Interface().(time.Time); ok {
976
+ if bt, ok := b.Interface().(time.Time); ok {
977
+ return at.Equal(bt)
978
+ }
979
+ }
980
+ }
981
+ if a.Kind() == reflect.Pointer && b.Kind() == reflect.Pointer && a.Pointer() == b.Pointer() {
982
+ return true
983
+ }
984
+ if af, aClass, ok := tnObjectFields(a); ok {
985
+ if bf, bClass, ok := tnObjectFields(b); ok {
986
+ if strict && aClass != bClass {
987
+ return false
988
+ }
989
+ return tnDeepEqualObjects(af, bf, strict, level)
990
+ }
991
+ }
992
+ if ae, ok := tnEntriesOf(a); ok {
993
+ be, ok := tnEntriesOf(b)
994
+ if !ok || len(ae) != len(be) {
995
+ return false
996
+ }
997
+ for _, x := range ae {
998
+ found := false
999
+ for _, y := range be {
1000
+ if tnDeepEqual(reflect.ValueOf(x[0]), reflect.ValueOf(y[0]), strict, level+1) {
1001
+ found = tnDeepEqual(reflect.ValueOf(x[1]), reflect.ValueOf(y[1]), strict, level+1)
1002
+ break
1003
+ }
1004
+ }
1005
+ if !found {
1006
+ return false
1007
+ }
1008
+ }
1009
+ return true
1010
+ }
1011
+ if strict && a.Type() != b.Type() {
1012
+ aSeq := a.Kind() == reflect.Slice || a.Kind() == reflect.Array
1013
+ bSeq := b.Kind() == reflect.Slice || b.Kind() == reflect.Array
1014
+ if !(aSeq && bSeq) && !(a.Kind() == reflect.Map && b.Kind() == reflect.Map) {
1015
+ return false
1016
+ }
1017
+ }
1018
+ switch a.Kind() {
1019
+ case reflect.Slice, reflect.Array:
1020
+ if b.Kind() != reflect.Slice && b.Kind() != reflect.Array {
1021
+ return false
1022
+ }
1023
+ if a.Len() != b.Len() {
1024
+ return false
1025
+ }
1026
+ for i := 0; i < a.Len(); i++ {
1027
+ if !tnDeepEqual(a.Index(i), b.Index(i), strict, level+1) {
1028
+ return false
1029
+ }
1030
+ }
1031
+ return true
1032
+ case reflect.Map:
1033
+ if b.Kind() != reflect.Map || a.Len() != b.Len() {
1034
+ return false
1035
+ }
1036
+ for _, k := range a.MapKeys() {
1037
+ bv := b.MapIndex(k)
1038
+ if !bv.IsValid() || !tnDeepEqual(a.MapIndex(k), bv, strict, level+1) {
1039
+ return false
1040
+ }
1041
+ }
1042
+ return true
1043
+ case reflect.Pointer:
1044
+ if b.Kind() != reflect.Pointer {
1045
+ return false
1046
+ }
1047
+ if a.Pointer() == b.Pointer() {
1048
+ return true
1049
+ }
1050
+ return tnDeepEqual(a.Elem(), b.Elem(), strict, level+1)
1051
+ case reflect.Struct:
1052
+ if b.Kind() != reflect.Struct {
1053
+ return false
1054
+ }
1055
+ af, _ := tnStructFields(a)
1056
+ bf, _ := tnStructFields(b)
1057
+ if len(af) != len(bf) {
1058
+ return false
1059
+ }
1060
+ for i := range af {
1061
+ if af[i].name != bf[i].name || !tnDeepEqual(reflect.ValueOf(af[i].value), reflect.ValueOf(bf[i].value), strict, level+1) {
1062
+ return false
1063
+ }
1064
+ }
1065
+ return true
1066
+ case reflect.Func:
1067
+ return a.Pointer() == b.Pointer()
1068
+ }
1069
+ if a.CanInterface() && b.CanInterface() {
1070
+ if strict {
1071
+ return a.Interface() == b.Interface()
1072
+ }
1073
+ return TnSame(a.Interface(), b.Interface()) || fmt.Sprint(a.Interface()) == fmt.Sprint(b.Interface())
1074
+ }
1075
+ return false
1076
+ }
1077
+
1078
+ func TnTypeName(v interface{}) string {
1079
+ if v == nil {
1080
+ return ""
1081
+ }
1082
+ return reflect.TypeOf(v).String()
1083
+ }
1084
+
1085
+ func TnIsNativeError(v interface{}) bool {
1086
+ if _, ok := v.(*TnError); ok {
1087
+ return true
1088
+ }
1089
+ rv := reflect.ValueOf(v)
1090
+ if rv.Kind() == reflect.Pointer && !rv.IsNil() && rv.Elem().Kind() == reflect.Struct {
1091
+ _, e := tnStructFields(rv.Elem())
1092
+ return e != nil
1093
+ }
1094
+ return false
1095
+ }
1096
+
1097
+ func TnIsMapValue(v interface{}) bool {
1098
+ _, ok := v.(interface{ Entries() [][]interface{} })
1099
+ return ok && !tnInspectSetLike(reflect.ValueOf(v))
1100
+ }
1101
+
1102
+ func TnIsSetValue(v interface{}) bool {
1103
+ _, ok := v.(interface{ Entries() [][]interface{} })
1104
+ return ok && tnInspectSetLike(reflect.ValueOf(v))
1105
+ }
1106
+
1107
+ // util.deprecate(fn, msg): the warning prints once, on the first call
1108
+ func TnDeprecate[F any](fn F, msg string, code ...string) F {
1109
+ var once sync.Once
1110
+ target := reflect.ValueOf(fn)
1111
+ wrapped := reflect.MakeFunc(target.Type(), func(args []reflect.Value) []reflect.Value {
1112
+ once.Do(func() {
1113
+ prefix := "DeprecationWarning"
1114
+ if len(code) > 0 && code[0] != "" {
1115
+ prefix = "[" + code[0] + "] DeprecationWarning"
1116
+ }
1117
+ fmt.Fprintf(os.Stderr, "(node:%d) %s: %s\\n", os.Getpid(), prefix, msg)
1118
+ })
1119
+ if target.Type().IsVariadic() {
1120
+ return target.CallSlice(args)
1121
+ }
1122
+ return target.Call(args)
1123
+ })
1124
+ return wrapped.Interface().(F)
1125
+ }
1126
+
1127
+ // util.promisify(fn) of a user function taking (…args, (err, value) => void)
1128
+ func TnPromisify(fn interface{}) func(args ...interface{}) chan interface{} {
1129
+ return func(args ...interface{}) chan interface{} {
1130
+ ch := make(chan interface{}, 1)
1131
+ TnLoopRef()
1132
+ callback := func(cbArgs ...interface{}) {
1133
+ defer TnLoopUnref()
1134
+ if len(cbArgs) > 0 && cbArgs[0] != nil && !TnIsNil(cbArgs[0]) {
1135
+ TnReject(ch, cbArgs[0])
1136
+ return
1137
+ }
1138
+ var value interface{}
1139
+ if len(cbArgs) > 1 {
1140
+ value = cbArgs[1]
1141
+ }
1142
+ ch <- value
1143
+ }
1144
+ TnInvoke(fn, append(append([]interface{}{}, args...), TnCallback(callback))...)
1145
+ return ch
1146
+ }
1147
+ }
1148
+
1149
+ // util.callbackify(asyncFn): (…args, (err, value) => void)
1150
+ func TnCallbackify(fn interface{}) func(args ...interface{}) {
1151
+ return func(args ...interface{}) {
1152
+ if len(args) == 0 {
1153
+ return
1154
+ }
1155
+ cb := args[len(args)-1]
1156
+ result := reflect.ValueOf(TnInvoke(fn, args[:len(args)-1]...))
1157
+ TnLoopRef()
1158
+ go func() {
1159
+ defer TnLoopUnref()
1160
+ if result.Kind() != reflect.Chan {
1161
+ value := result.Interface()
1162
+ TnLoopPost(func() { TnInvoke(cb, nil, value) })
1163
+ return
1164
+ }
1165
+ v, ok := result.Recv()
1166
+ var reason interface{}
1167
+ rejected := false
1168
+ if !ok {
1169
+ reason, rejected = tnRejections.Load(result.Interface())
1170
+ }
1171
+ TnLoopPost(func() {
1172
+ if rejected {
1173
+ TnInvoke(cb, reason)
1174
+ return
1175
+ }
1176
+ var value interface{}
1177
+ if v.IsValid() {
1178
+ value = v.Interface()
1179
+ }
1180
+ TnInvoke(cb, nil, value)
1181
+ })
1182
+ }()
1183
+ }
1184
+ }
1185
+
1186
+ var tnAnsiPattern = regexp.MustCompile("[\\\\x1b\\\\x9b][[\\\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]+)*|[a-zA-Z\\\\d]+(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*)?\\\\x07)|(?:(?:\\\\d{1,4}(?:;\\\\d{0,4})*)?[\\\\dA-PR-TZcf-ntqry=><~]))")
1187
+
1188
+ func TnStripVTControlCharacters(s string) string { return tnAnsiPattern.ReplaceAllString(s, "") }
1189
+
1190
+ var tnStyles = map[string][2]int{
1191
+ "reset": {0, 0}, "bold": {1, 22}, "dim": {2, 22}, "italic": {3, 23}, "underline": {4, 24},
1192
+ "blink": {5, 25}, "inverse": {7, 27}, "hidden": {8, 28}, "strikethrough": {9, 29},
1193
+ "black": {30, 39}, "red": {31, 39}, "green": {32, 39}, "yellow": {33, 39}, "blue": {34, 39},
1194
+ "magenta": {35, 39}, "cyan": {36, 39}, "white": {37, 39}, "gray": {90, 39}, "grey": {90, 39},
1195
+ "bgBlack": {40, 49}, "bgRed": {41, 49}, "bgGreen": {42, 49}, "bgYellow": {43, 49},
1196
+ "bgBlue": {44, 49}, "bgMagenta": {45, 49}, "bgCyan": {46, 49}, "bgWhite": {47, 49},
1197
+ }
1198
+
1199
+ // util.styleText(format, text, { validateStream }): colors only when stdout is a TTY
1200
+ func TnStyleText(format interface{}, text string, options ...interface{}) string {
1201
+ names := []string{}
1202
+ switch f := format.(type) {
1203
+ case string:
1204
+ names = append(names, f)
1205
+ case []string:
1206
+ names = f
1207
+ case []interface{}:
1208
+ for _, n := range f {
1209
+ names = append(names, fmt.Sprint(n))
1210
+ }
1211
+ }
1212
+ validate := true
1213
+ if len(options) > 0 && options[0] != nil {
1214
+ if v, ok := TnGet(options[0], "validateStream").(bool); ok {
1215
+ validate = v
1216
+ }
1217
+ }
1218
+ if validate {
1219
+ info, err := os.Stdout.Stat()
1220
+ if err != nil || info.Mode()&os.ModeCharDevice == 0 || os.Getenv("NO_COLOR") != "" {
1221
+ return text
1222
+ }
1223
+ }
1224
+ for i := len(names) - 1; i >= 0; i-- {
1225
+ codes, ok := tnStyles[names[i]]
1226
+ if !ok {
1227
+ panic(TnNodeError("TypeError", "ERR_INVALID_ARG_VALUE", "The argument 'format' must be one of the color names. Received "+tnQuoteJS(names[i])))
1228
+ }
1229
+ text = fmt.Sprintf("\\x1b[%dm%s\\x1b[%dm", codes[0], text, codes[1])
1230
+ }
1231
+ return text
1232
+ }`;
1233
+ export function registerUtil(r) {
1234
+ defineModule(r, 'util');
1235
+ defineModule(r, 'util/types');
1236
+ r.aliases['sys'] = 'util';
1237
+ r.namespaces['util.types'] = 'util/types';
1238
+ defineHelper(r, 'nodeUtil', ['bytes', 'fmt', 'math', 'math/big', 'os', 'reflect', 'regexp', 'runtime', 'sort', 'strconv', 'strings', 'sync', 'time', 'unicode/utf8', 'unsafe'], ['error', 'dynamic', 'buffer', 'jsonStringify', 'orderedMap', 'nodeInvoke', 'promise', 'eventLoop'], utilHelper);
1239
+ const use = () => r.helper('nodeUtil');
1240
+ r.functions['util.format'] = (call) => {
1241
+ use();
1242
+ return `TnUtilFormat(${call.args.join(', ')})`;
1243
+ };
1244
+ r.functions['util.formatWithOptions'] = (call) => {
1245
+ use();
1246
+ return `TnUtilFormat(${call.args.slice(1).join(', ')})`;
1247
+ };
1248
+ r.functions['util.inspect'] = (call) => {
1249
+ use();
1250
+ const node = call.nodes[0];
1251
+ const isMap = !!node && nodeIsMapVariable(r, node);
1252
+ return `${isMap ? 'TnInspectMap' : 'TnInspect'}(${call.args.join(', ')})`;
1253
+ };
1254
+ r.functions['util.isDeepStrictEqual'] = (call) => {
1255
+ use();
1256
+ return `TnDeepEqual(${call.args[0]}, ${call.args[1]}, true)`;
1257
+ };
1258
+ r.functions['util.deprecate'] = (call) => {
1259
+ use();
1260
+ return `TnDeprecate(${call.args.join(', ')})`;
1261
+ };
1262
+ r.typers['util.deprecate'] = (c) => c.types[0] ?? '';
1263
+ r.functions['util.stripVTControlCharacters'] = (call) => {
1264
+ use();
1265
+ return `TnStripVTControlCharacters(${call.args[0]})`;
1266
+ };
1267
+ r.functions['util.styleText'] = (call) => {
1268
+ use();
1269
+ return `TnStyleText(${call.args.join(', ')})`;
1270
+ };
1271
+ r.functions['util.promisify'] = (call) => {
1272
+ use();
1273
+ return `TnPromisify(${call.args[0]})`;
1274
+ };
1275
+ r.results['util.promisify'] = 'func(...interface{}) chan interface{}';
1276
+ r.functions['util.callbackify'] = (call) => {
1277
+ use();
1278
+ return `TnCallbackify(${call.args[0]})`;
1279
+ };
1280
+ r.results['util.callbackify'] = 'func(...interface{})';
1281
+ r.functions['util.isArray'] = (call) => {
1282
+ r.pkg('reflect');
1283
+ return `(reflect.ValueOf(${call.args[0]}).Kind() == reflect.Slice)`;
1284
+ };
1285
+ setResults(r, 'util', 'format=string; formatWithOptions=string; inspect=string; isDeepStrictEqual=bool; stripVTControlCharacters=string; styleText=string; isArray=bool');
1286
+ // util.types / node:util/types
1287
+ const typeCheck = (name, emit) => {
1288
+ r.functions[`util/types.${name}`] = (call) => {
1289
+ use();
1290
+ return emit(call.args[0]);
1291
+ };
1292
+ r.results[`util/types.${name}`] = 'bool';
1293
+ };
1294
+ typeCheck('isDate', (a) => `(TnTypeName(${a}) == "time.Time")`);
1295
+ typeCheck('isRegExp', (a) => `(TnTypeName(${a}) == "*regexp.Regexp" || TnTypeName(${a}) == "*main.TnRegex")`);
1296
+ typeCheck('isPromise', (a) => `(reflect.ValueOf(${a}).Kind() == reflect.Chan)`);
1297
+ typeCheck('isMap', (a) => `TnIsMapValue(${a})`);
1298
+ typeCheck('isSet', (a) => `TnIsSetValue(${a})`);
1299
+ typeCheck('isNativeError', (a) => `TnIsNativeError(${a})`);
1300
+ typeCheck('isUint8Array', (a) => `(TnTypeName(${a}) == "[]uint8")`);
1301
+ typeCheck('isAnyArrayBuffer', (_a) => 'false');
1302
+ typeCheck('isBoxedPrimitive', (_a) => 'false');
1303
+ typeCheck('isGeneratorObject', (a) => `(reflect.ValueOf(${a}).Kind() == reflect.Chan)`);
1304
+ typeCheck('isAsyncFunction', (_a) => 'false');
1305
+ }
1306
+ // Whether the inspected expression is a Map (not a Record): both lower to TnMap
1307
+ function nodeIsMapVariable(r, node) {
1308
+ if (node.kind === 'NewExpression' && node.expression?.text === 'Map')
1309
+ return true;
1310
+ return r.categoryOf(node) === 'Map';
1311
+ }