typenative 0.3.1 → 0.4.1

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 (170) hide show
  1. package/.github/workflows/ci.yml +2 -0
  2. package/CHANGELOG.md +258 -0
  3. package/CONTRIBUTION.md +1 -1
  4. package/README.md +17 -1
  5. package/bin/cli.js +26 -11
  6. package/bin/go/bridge.js +74 -14
  7. package/bin/go/convert.js +59 -1
  8. package/bin/go/metadata.js +13 -4
  9. package/bin/go/overrides.js +4 -6
  10. package/bin/go/stdlib.generated.js +2 -0
  11. package/bin/index.js +338 -47
  12. package/bin/main.js +36 -14
  13. package/bin/node/assert.js +2 -2
  14. package/bin/node/buffer.js +9 -0
  15. package/bin/node/child_process.js +51 -3
  16. package/bin/node/cluster.js +41 -3
  17. package/bin/node/core.js +1 -1
  18. package/bin/node/crypto.js +205 -4
  19. package/bin/node/dgram.js +230 -6
  20. package/bin/node/dns.js +471 -8
  21. package/bin/node/errno_tables.js +445 -0
  22. package/bin/node/events.js +1 -1
  23. package/bin/node/fs.js +22 -15
  24. package/bin/node/fs_watch.js +407 -0
  25. package/bin/node/http.js +128 -30
  26. package/bin/node/http2.js +37 -7
  27. package/bin/node/module_v8.js +142 -0
  28. package/bin/node/net.js +9 -6
  29. package/bin/node/process.js +242 -0
  30. package/bin/node/readline.js +272 -1
  31. package/bin/node/registry.js +3 -1
  32. package/bin/node/sqlite.js +60 -12
  33. package/bin/node/stream.js +145 -10
  34. package/bin/node/test.js +311 -19
  35. package/bin/node/timers.js +1 -1
  36. package/bin/node/typed_arrays.js +608 -0
  37. package/bin/node/url.js +23 -5
  38. package/bin/node/util.js +21 -1
  39. package/bin/node/util_extra.js +6 -30
  40. package/bin/node/worker_threads.js +79 -19
  41. package/bin/node/zlib.js +131 -16
  42. package/bin/transpiler.js +4729 -616
  43. package/bin/typecheck-node.js +1 -0
  44. package/bin/version.js +1 -1
  45. package/conformance.md +1030 -877
  46. package/examples/README.md +54 -0
  47. package/examples/fibonacci/README.md +89 -0
  48. package/examples/fibonacci/bench.mjs +87 -0
  49. package/examples/fibonacci/main.ts +21 -0
  50. package/examples/hello-world/README.md +62 -0
  51. package/examples/hello-world/bench.mjs +66 -0
  52. package/examples/hello-world/main.ts +7 -0
  53. package/examples/json-server/README.md +127 -0
  54. package/examples/json-server/bench.mjs +263 -0
  55. package/examples/json-server/main.ts +67 -0
  56. package/govendor/github.com/andybalholm/brotli/LICENSE +19 -0
  57. package/govendor/github.com/andybalholm/brotli/README.md +19 -0
  58. package/govendor/github.com/andybalholm/brotli/backward_references.go +185 -0
  59. package/govendor/github.com/andybalholm/brotli/backward_references_hq.go +796 -0
  60. package/govendor/github.com/andybalholm/brotli/bit_cost.go +436 -0
  61. package/govendor/github.com/andybalholm/brotli/bit_reader.go +266 -0
  62. package/govendor/github.com/andybalholm/brotli/bitwriter.go +56 -0
  63. package/govendor/github.com/andybalholm/brotli/block_splitter.go +144 -0
  64. package/govendor/github.com/andybalholm/brotli/block_splitter_command.go +434 -0
  65. package/govendor/github.com/andybalholm/brotli/block_splitter_distance.go +433 -0
  66. package/govendor/github.com/andybalholm/brotli/block_splitter_literal.go +433 -0
  67. package/govendor/github.com/andybalholm/brotli/brotli_bit_stream.go +1435 -0
  68. package/govendor/github.com/andybalholm/brotli/cluster.go +30 -0
  69. package/govendor/github.com/andybalholm/brotli/cluster_command.go +164 -0
  70. package/govendor/github.com/andybalholm/brotli/cluster_distance.go +326 -0
  71. package/govendor/github.com/andybalholm/brotli/cluster_literal.go +326 -0
  72. package/govendor/github.com/andybalholm/brotli/command.go +254 -0
  73. package/govendor/github.com/andybalholm/brotli/compress_fragment.go +834 -0
  74. package/govendor/github.com/andybalholm/brotli/compress_fragment_two_pass.go +775 -0
  75. package/govendor/github.com/andybalholm/brotli/constants.go +77 -0
  76. package/govendor/github.com/andybalholm/brotli/context.go +2176 -0
  77. package/govendor/github.com/andybalholm/brotli/decode.go +2570 -0
  78. package/govendor/github.com/andybalholm/brotli/dictionary.go +122890 -0
  79. package/govendor/github.com/andybalholm/brotli/dictionary_hash.go +32779 -0
  80. package/govendor/github.com/andybalholm/brotli/encode.go +1220 -0
  81. package/govendor/github.com/andybalholm/brotli/encoder.go +177 -0
  82. package/govendor/github.com/andybalholm/brotli/encoder_dict.go +22 -0
  83. package/govendor/github.com/andybalholm/brotli/encoder_fast.go +201 -0
  84. package/govendor/github.com/andybalholm/brotli/entropy_encode.go +592 -0
  85. package/govendor/github.com/andybalholm/brotli/entropy_encode_static.go +4399 -0
  86. package/govendor/github.com/andybalholm/brotli/fast_log.go +290 -0
  87. package/govendor/github.com/andybalholm/brotli/find_match_length.go +45 -0
  88. package/govendor/github.com/andybalholm/brotli/go.mod +3 -0
  89. package/govendor/github.com/andybalholm/brotli/h10.go +287 -0
  90. package/govendor/github.com/andybalholm/brotli/h5.go +214 -0
  91. package/govendor/github.com/andybalholm/brotli/h6.go +216 -0
  92. package/govendor/github.com/andybalholm/brotli/hash.go +342 -0
  93. package/govendor/github.com/andybalholm/brotli/hash_composite.go +93 -0
  94. package/govendor/github.com/andybalholm/brotli/hash_forgetful_chain.go +252 -0
  95. package/govendor/github.com/andybalholm/brotli/hash_longest_match_quickly.go +214 -0
  96. package/govendor/github.com/andybalholm/brotli/hash_rolling.go +168 -0
  97. package/govendor/github.com/andybalholm/brotli/histogram.go +226 -0
  98. package/govendor/github.com/andybalholm/brotli/http.go +201 -0
  99. package/govendor/github.com/andybalholm/brotli/huffman.go +653 -0
  100. package/govendor/github.com/andybalholm/brotli/literal_cost.go +182 -0
  101. package/govendor/github.com/andybalholm/brotli/matchfinder/bargain1.go +212 -0
  102. package/govendor/github.com/andybalholm/brotli/matchfinder/bargain2.go +248 -0
  103. package/govendor/github.com/andybalholm/brotli/matchfinder/bargain3.go +278 -0
  104. package/govendor/github.com/andybalholm/brotli/matchfinder/emitter.go +34 -0
  105. package/govendor/github.com/andybalholm/brotli/matchfinder/m0.go +175 -0
  106. package/govendor/github.com/andybalholm/brotli/matchfinder/m4.go +339 -0
  107. package/govendor/github.com/andybalholm/brotli/matchfinder/matchfinder.go +103 -0
  108. package/govendor/github.com/andybalholm/brotli/matchfinder/pathfinder.go +328 -0
  109. package/govendor/github.com/andybalholm/brotli/matchfinder/textencoder.go +53 -0
  110. package/govendor/github.com/andybalholm/brotli/matchfinder/trio.go +327 -0
  111. package/govendor/github.com/andybalholm/brotli/matchfinder/zdfast.go +258 -0
  112. package/govendor/github.com/andybalholm/brotli/matchfinder/zfast.go +206 -0
  113. package/govendor/github.com/andybalholm/brotli/matchfinder/zm.go +302 -0
  114. package/govendor/github.com/andybalholm/brotli/memory.go +66 -0
  115. package/govendor/github.com/andybalholm/brotli/metablock.go +574 -0
  116. package/govendor/github.com/andybalholm/brotli/metablock_command.go +165 -0
  117. package/govendor/github.com/andybalholm/brotli/metablock_distance.go +165 -0
  118. package/govendor/github.com/andybalholm/brotli/metablock_literal.go +165 -0
  119. package/govendor/github.com/andybalholm/brotli/params.go +37 -0
  120. package/govendor/github.com/andybalholm/brotli/platform.go +103 -0
  121. package/govendor/github.com/andybalholm/brotli/prefix.go +30 -0
  122. package/govendor/github.com/andybalholm/brotli/prefix_dec.go +723 -0
  123. package/govendor/github.com/andybalholm/brotli/quality.go +196 -0
  124. package/govendor/github.com/andybalholm/brotli/reader.go +127 -0
  125. package/govendor/github.com/andybalholm/brotli/ringbuffer.go +134 -0
  126. package/govendor/github.com/andybalholm/brotli/state.go +313 -0
  127. package/govendor/github.com/andybalholm/brotli/static_dict.go +662 -0
  128. package/govendor/github.com/andybalholm/brotli/static_dict_lut.go +75094 -0
  129. package/govendor/github.com/andybalholm/brotli/symbol_list.go +22 -0
  130. package/govendor/github.com/andybalholm/brotli/transform.go +641 -0
  131. package/govendor/github.com/andybalholm/brotli/utf8_util.go +70 -0
  132. package/govendor/github.com/andybalholm/brotli/util.go +7 -0
  133. package/govendor/github.com/andybalholm/brotli/write_bits.go +52 -0
  134. package/govendor/github.com/andybalholm/brotli/writer.go +162 -0
  135. package/govendor/github.com/fsnotify/fsnotify/.mailmap +2 -0
  136. package/govendor/github.com/fsnotify/fsnotify/CHANGELOG.md +651 -0
  137. package/govendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md +147 -0
  138. package/govendor/github.com/fsnotify/fsnotify/LICENSE +25 -0
  139. package/govendor/github.com/fsnotify/fsnotify/README.md +214 -0
  140. package/govendor/github.com/fsnotify/fsnotify/backend_fen.go +469 -0
  141. package/govendor/github.com/fsnotify/fsnotify/backend_inotify.go +597 -0
  142. package/govendor/github.com/fsnotify/fsnotify/backend_kqueue.go +735 -0
  143. package/govendor/github.com/fsnotify/fsnotify/backend_other.go +22 -0
  144. package/govendor/github.com/fsnotify/fsnotify/backend_windows.go +702 -0
  145. package/govendor/github.com/fsnotify/fsnotify/fsnotify.go +526 -0
  146. package/govendor/github.com/fsnotify/fsnotify/go.mod +3 -0
  147. package/govendor/github.com/fsnotify/fsnotify/internal/darwin.go +20 -0
  148. package/govendor/github.com/fsnotify/fsnotify/internal/debug_darwin.go +15 -0
  149. package/govendor/github.com/fsnotify/fsnotify/internal/debug_dragonfly.go +15 -0
  150. package/govendor/github.com/fsnotify/fsnotify/internal/debug_freebsd.go +20 -0
  151. package/govendor/github.com/fsnotify/fsnotify/internal/debug_kqueue.go +32 -0
  152. package/govendor/github.com/fsnotify/fsnotify/internal/debug_linux.go +56 -0
  153. package/govendor/github.com/fsnotify/fsnotify/internal/debug_netbsd.go +15 -0
  154. package/govendor/github.com/fsnotify/fsnotify/internal/debug_openbsd.go +16 -0
  155. package/govendor/github.com/fsnotify/fsnotify/internal/debug_solaris.go +45 -0
  156. package/govendor/github.com/fsnotify/fsnotify/internal/debug_windows.go +40 -0
  157. package/govendor/github.com/fsnotify/fsnotify/internal/freebsd.go +20 -0
  158. package/govendor/github.com/fsnotify/fsnotify/internal/internal.go +2 -0
  159. package/govendor/github.com/fsnotify/fsnotify/internal/unix.go +20 -0
  160. package/govendor/github.com/fsnotify/fsnotify/internal/unix2.go +25 -0
  161. package/govendor/github.com/fsnotify/fsnotify/internal/windows.go +40 -0
  162. package/govendor/github.com/fsnotify/fsnotify/shared.go +64 -0
  163. package/govendor/github.com/fsnotify/fsnotify/staticcheck.conf +3 -0
  164. package/govendor/github.com/fsnotify/fsnotify/system_bsd.go +7 -0
  165. package/govendor/github.com/fsnotify/fsnotify/system_darwin.go +8 -0
  166. package/govendor/manifest.txt +3 -1
  167. package/package.json +1 -1
  168. package/types/typenative-go.d.ts +23 -0
  169. package/types/typenative-npm.d.ts +241 -5
  170. package/types/typenative.d.ts +302 -12
@@ -0,0 +1,52 @@
1
+ package brotli
2
+
3
+ import "encoding/binary"
4
+
5
+ /* Copyright 2010 Google Inc. All Rights Reserved.
6
+
7
+ Distributed under MIT license.
8
+ See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
9
+ */
10
+
11
+ /* Write bits into a byte array. */
12
+
13
+ /* This function writes bits into bytes in increasing addresses, and within
14
+ a byte least-significant-bit first.
15
+
16
+ The function can write up to 56 bits in one go with WriteBits
17
+ Example: let's assume that 3 bits (Rs below) have been written already:
18
+
19
+ BYTE-0 BYTE+1 BYTE+2
20
+
21
+ 0000 0RRR 0000 0000 0000 0000
22
+
23
+ Now, we could write 5 or less bits in MSB by just sifting by 3
24
+ and OR'ing to BYTE-0.
25
+
26
+ For n bits, we take the last 5 bits, OR that with high bits in BYTE-0,
27
+ and locate the rest in BYTE+1, BYTE+2, etc. */
28
+ func writeBits(n_bits uint, bits uint64, pos *uint, array []byte) {
29
+ /* This branch of the code can write up to 56 bits at a time,
30
+ 7 bits are lost by being perhaps already in *p and at least
31
+ 1 bit is needed to initialize the bit-stream ahead (i.e. if 7
32
+ bits are in *p and we write 57 bits, then the next write will
33
+ access a byte that was never initialized). */
34
+ p := array[*pos>>3:]
35
+ v := uint64(p[0])
36
+ v |= bits << (*pos & 7)
37
+ binary.LittleEndian.PutUint64(p, v)
38
+ *pos += n_bits
39
+ }
40
+
41
+ func writeSingleBit(bit bool, pos *uint, array []byte) {
42
+ if bit {
43
+ writeBits(1, 1, pos, array)
44
+ } else {
45
+ writeBits(1, 0, pos, array)
46
+ }
47
+ }
48
+
49
+ func writeBitsPrepareStorage(pos uint, array []byte) {
50
+ assert(pos&7 == 0)
51
+ array[pos>>3] = 0
52
+ }
@@ -0,0 +1,162 @@
1
+ package brotli
2
+
3
+ import (
4
+ "errors"
5
+ "io"
6
+
7
+ "github.com/andybalholm/brotli/matchfinder"
8
+ )
9
+
10
+ const (
11
+ BestSpeed = 0
12
+ BestCompression = 11
13
+ DefaultCompression = 6
14
+ )
15
+
16
+ // WriterOptions configures Writer.
17
+ type WriterOptions struct {
18
+ // Quality controls the compression-speed vs compression-density trade-offs.
19
+ // The higher the quality, the slower the compression. Range is 0 to 11.
20
+ Quality int
21
+ // LGWin is the base 2 logarithm of the sliding window size.
22
+ // Range is 10 to 24. 0 indicates automatic configuration based on Quality.
23
+ LGWin int
24
+ }
25
+
26
+ var (
27
+ errEncode = errors.New("brotli: encode error")
28
+ errWriterClosed = errors.New("brotli: Writer is closed")
29
+ )
30
+
31
+ // Writes to the returned writer are compressed and written to dst.
32
+ // It is the caller's responsibility to call Close on the Writer when done.
33
+ // Writes may be buffered and not flushed until Close.
34
+ func NewWriter(dst io.Writer) *Writer {
35
+ return NewWriterLevel(dst, DefaultCompression)
36
+ }
37
+
38
+ // NewWriterLevel is like NewWriter but specifies the compression level instead
39
+ // of assuming DefaultCompression.
40
+ // The compression level can be DefaultCompression or any integer value between
41
+ // BestSpeed and BestCompression inclusive.
42
+ func NewWriterLevel(dst io.Writer, level int) *Writer {
43
+ return NewWriterOptions(dst, WriterOptions{
44
+ Quality: level,
45
+ })
46
+ }
47
+
48
+ // NewWriterOptions is like NewWriter but specifies WriterOptions
49
+ func NewWriterOptions(dst io.Writer, options WriterOptions) *Writer {
50
+ w := new(Writer)
51
+ w.options = options
52
+ w.Reset(dst)
53
+ return w
54
+ }
55
+
56
+ // Reset discards the Writer's state and makes it equivalent to the result of
57
+ // its original state from NewWriter or NewWriterLevel, but writing to dst
58
+ // instead. This permits reusing a Writer rather than allocating a new one.
59
+ func (w *Writer) Reset(dst io.Writer) {
60
+ encoderInitState(w)
61
+ w.params.quality = w.options.Quality
62
+ if w.options.LGWin > 0 {
63
+ w.params.lgwin = uint(w.options.LGWin)
64
+ }
65
+ w.dst = dst
66
+ w.err = nil
67
+ }
68
+
69
+ func (w *Writer) writeChunk(p []byte, op int) (n int, err error) {
70
+ if w.dst == nil {
71
+ return 0, errWriterClosed
72
+ }
73
+ if w.err != nil {
74
+ return 0, w.err
75
+ }
76
+
77
+ for {
78
+ availableIn := uint(len(p))
79
+ nextIn := p
80
+ success := encoderCompressStream(w, op, &availableIn, &nextIn)
81
+ bytesConsumed := len(p) - int(availableIn)
82
+ p = p[bytesConsumed:]
83
+ n += bytesConsumed
84
+ if !success {
85
+ return n, errEncode
86
+ }
87
+
88
+ if len(p) == 0 || w.err != nil {
89
+ return n, w.err
90
+ }
91
+ }
92
+ }
93
+
94
+ // Flush outputs encoded data for all input provided to Write. The resulting
95
+ // output can be decoded to match all input before Flush, but the stream is
96
+ // not yet complete until after Close.
97
+ // Flush has a negative impact on compression.
98
+ func (w *Writer) Flush() error {
99
+ _, err := w.writeChunk(nil, operationFlush)
100
+ return err
101
+ }
102
+
103
+ // Close flushes remaining data to the decorated writer.
104
+ func (w *Writer) Close() error {
105
+ // If stream is already closed, it is reported by `writeChunk`.
106
+ _, err := w.writeChunk(nil, operationFinish)
107
+ w.dst = nil
108
+ return err
109
+ }
110
+
111
+ // Write implements io.Writer. Flush or Close must be called to ensure that the
112
+ // encoded bytes are actually flushed to the underlying Writer.
113
+ func (w *Writer) Write(p []byte) (n int, err error) {
114
+ return w.writeChunk(p, operationProcess)
115
+ }
116
+
117
+ type nopCloser struct {
118
+ io.Writer
119
+ }
120
+
121
+ func (nopCloser) Close() error { return nil }
122
+
123
+ // NewWriterV2 is like NewWriterLevel, but it uses the new implementation
124
+ // based on the matchfinder package. It currently supports up to level 9;
125
+ // if a higher level is specified, level 9 will be used.
126
+ func NewWriterV2(dst io.Writer, level int) *matchfinder.Writer {
127
+ if level < 0 {
128
+ level = 0
129
+ } else if level > 9 {
130
+ level = 9
131
+ }
132
+ var mf matchfinder.MatchFinder
133
+ switch level {
134
+ case 0, 1:
135
+ mf = &matchfinder.ZFast{MaxDistance: 1 << 20}
136
+ case 2:
137
+ mf = &matchfinder.ZDFast{MaxDistance: 1 << 20}
138
+ case 3:
139
+ mf = &matchfinder.ZM{MaxDistance: 1 << 20}
140
+ case 4:
141
+ mf = &matchfinder.Trio{MaxDistance: 1 << 20}
142
+ case 5, 6:
143
+ mf = &matchfinder.Bargain1{MaxDistance: 1 << 20}
144
+ case 7:
145
+ mf = &matchfinder.Bargain2{MaxDistance: 1 << 20, Skip: true}
146
+ case 8:
147
+ mf = &matchfinder.Bargain2{MaxDistance: 1 << 20}
148
+ case 9:
149
+ mf = &matchfinder.Bargain3{MaxDistance: 1 << 20}
150
+ }
151
+
152
+ w := &matchfinder.Writer{
153
+ Dest: dst,
154
+ MatchFinder: mf,
155
+ Encoder: &Encoder{},
156
+ BlockSize: 1 << 16,
157
+ }
158
+ if level < 1 {
159
+ w.Encoder = &FastEncoder{}
160
+ }
161
+ return w
162
+ }
@@ -0,0 +1,2 @@
1
+ Chris Howey <howeyc@gmail.com> <chris@howey.me>
2
+ Nathan Youngman <git@nathany.com> <4566+nathany@users.noreply.github.com>