goscript 0.0.25 → 0.0.28

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 (190) hide show
  1. package/README.md +4 -4
  2. package/cmd/goscript/cmd_compile.go +0 -3
  3. package/cmd/goscript/deps.go +11 -0
  4. package/compiler/analysis.go +259 -55
  5. package/compiler/assignment.go +2 -2
  6. package/compiler/builtin_test.go +1 -1
  7. package/compiler/compiler.go +201 -49
  8. package/compiler/compiler_test.go +53 -0
  9. package/compiler/composite-lit.go +32 -8
  10. package/compiler/decl.go +6 -6
  11. package/compiler/expr-call.go +83 -0
  12. package/compiler/expr.go +1 -1
  13. package/compiler/protobuf.go +557 -0
  14. package/compiler/spec-struct.go +4 -0
  15. package/compiler/spec-value.go +11 -3
  16. package/compiler/spec.go +18 -1
  17. package/compiler/stmt-assign.go +35 -0
  18. package/compiler/type-assert.go +87 -0
  19. package/compiler/type.go +5 -2
  20. package/dist/gs/builtin/builtin.d.ts +19 -1
  21. package/dist/gs/builtin/builtin.js +85 -5
  22. package/dist/gs/builtin/builtin.js.map +1 -1
  23. package/dist/gs/builtin/channel.js.map +1 -1
  24. package/dist/gs/builtin/slice.d.ts +1 -1
  25. package/dist/gs/builtin/slice.js +59 -26
  26. package/dist/gs/builtin/slice.js.map +1 -1
  27. package/dist/gs/cmp/index.js.map +1 -1
  28. package/dist/gs/context/context.d.ts +1 -1
  29. package/dist/gs/context/context.js +20 -11
  30. package/dist/gs/context/context.js.map +1 -1
  31. package/dist/gs/errors/errors.d.ts +7 -0
  32. package/dist/gs/errors/errors.js +190 -0
  33. package/dist/gs/errors/errors.js.map +1 -0
  34. package/dist/gs/errors/index.d.ts +1 -0
  35. package/dist/gs/errors/index.js +2 -0
  36. package/dist/gs/errors/index.js.map +1 -0
  37. package/dist/gs/internal/goarch/index.js +1 -1
  38. package/dist/gs/internal/goarch/index.js.map +1 -1
  39. package/dist/gs/io/index.d.ts +1 -0
  40. package/dist/gs/io/index.js +2 -0
  41. package/dist/gs/io/index.js.map +1 -0
  42. package/dist/gs/io/io.d.ts +107 -0
  43. package/dist/gs/io/io.js +385 -0
  44. package/dist/gs/io/io.js.map +1 -0
  45. package/dist/gs/iter/iter.js.map +1 -1
  46. package/dist/gs/math/bits/index.js +34 -32
  47. package/dist/gs/math/bits/index.js.map +1 -1
  48. package/dist/gs/runtime/runtime.d.ts +1 -0
  49. package/dist/gs/runtime/runtime.js +15 -18
  50. package/dist/gs/runtime/runtime.js.map +1 -1
  51. package/dist/gs/slices/slices.d.ts +1 -1
  52. package/dist/gs/slices/slices.js +1 -1
  53. package/dist/gs/slices/slices.js.map +1 -1
  54. package/dist/gs/strings/builder.d.ts +18 -0
  55. package/dist/gs/strings/builder.js +205 -0
  56. package/dist/gs/strings/builder.js.map +1 -0
  57. package/dist/gs/strings/clone.d.ts +1 -0
  58. package/dist/gs/strings/clone.js +16 -0
  59. package/dist/gs/strings/clone.js.map +1 -0
  60. package/dist/gs/strings/compare.d.ts +1 -0
  61. package/dist/gs/strings/compare.js +14 -0
  62. package/dist/gs/strings/compare.js.map +1 -0
  63. package/dist/gs/strings/index.d.ts +2 -0
  64. package/dist/gs/strings/index.js +3 -0
  65. package/dist/gs/strings/index.js.map +1 -0
  66. package/dist/gs/strings/iter.d.ts +8 -0
  67. package/dist/gs/strings/iter.js +160 -0
  68. package/dist/gs/strings/iter.js.map +1 -0
  69. package/dist/gs/strings/reader.d.ts +34 -0
  70. package/dist/gs/strings/reader.js +418 -0
  71. package/dist/gs/strings/reader.js.map +1 -0
  72. package/dist/gs/strings/replace.d.ts +106 -0
  73. package/dist/gs/strings/replace.js +1136 -0
  74. package/dist/gs/strings/replace.js.map +1 -0
  75. package/dist/gs/strings/search.d.ts +24 -0
  76. package/dist/gs/strings/search.js +169 -0
  77. package/dist/gs/strings/search.js.map +1 -0
  78. package/dist/gs/strings/strings.d.ts +47 -0
  79. package/dist/gs/strings/strings.js +418 -0
  80. package/dist/gs/strings/strings.js.map +1 -0
  81. package/dist/gs/stringslite/index.d.ts +1 -0
  82. package/dist/gs/stringslite/index.js +2 -0
  83. package/dist/gs/stringslite/index.js.map +1 -0
  84. package/dist/gs/stringslite/strings.d.ts +11 -0
  85. package/dist/gs/stringslite/strings.js +67 -0
  86. package/dist/gs/stringslite/strings.js.map +1 -0
  87. package/dist/gs/sync/index.d.ts +1 -0
  88. package/dist/gs/sync/index.js +2 -0
  89. package/dist/gs/sync/index.js.map +1 -0
  90. package/dist/gs/sync/sync.d.ts +79 -0
  91. package/dist/gs/sync/sync.js +392 -0
  92. package/dist/gs/sync/sync.js.map +1 -0
  93. package/dist/gs/time/time.js +7 -7
  94. package/dist/gs/time/time.js.map +1 -1
  95. package/dist/gs/unicode/index.d.ts +1 -0
  96. package/dist/gs/unicode/index.js +2 -0
  97. package/dist/gs/unicode/index.js.map +1 -0
  98. package/dist/gs/unicode/unicode.d.ts +105 -0
  99. package/dist/gs/unicode/unicode.js +332 -0
  100. package/dist/gs/unicode/unicode.js.map +1 -0
  101. package/dist/gs/unicode/utf8/index.d.ts +1 -0
  102. package/dist/gs/unicode/utf8/index.js +3 -0
  103. package/dist/gs/unicode/utf8/index.js.map +1 -0
  104. package/dist/gs/unicode/utf8/utf8.d.ts +20 -0
  105. package/dist/gs/unicode/utf8/utf8.js +196 -0
  106. package/dist/gs/unicode/utf8/utf8.js.map +1 -0
  107. package/dist/gs/unsafe/index.d.ts +1 -0
  108. package/dist/gs/unsafe/index.js +2 -0
  109. package/dist/gs/unsafe/index.js.map +1 -0
  110. package/dist/gs/unsafe/unsafe.d.ts +11 -0
  111. package/dist/gs/unsafe/unsafe.js +44 -0
  112. package/dist/gs/unsafe/unsafe.js.map +1 -0
  113. package/go.mod +2 -1
  114. package/go.sum +6 -2
  115. package/gs/README.md +6 -0
  116. package/gs/builtin/builtin.ts +158 -0
  117. package/gs/builtin/channel.ts +683 -0
  118. package/gs/builtin/defer.ts +58 -0
  119. package/gs/builtin/index.ts +1 -0
  120. package/gs/builtin/io.ts +22 -0
  121. package/gs/builtin/map.ts +50 -0
  122. package/gs/builtin/slice.ts +1030 -0
  123. package/gs/builtin/type.ts +1106 -0
  124. package/gs/builtin/varRef.ts +25 -0
  125. package/gs/cmp/godoc.txt +8 -0
  126. package/gs/cmp/index.ts +29 -0
  127. package/gs/context/context.ts +401 -0
  128. package/gs/context/godoc.txt +69 -0
  129. package/gs/context/index.ts +1 -0
  130. package/gs/errors/errors.ts +223 -0
  131. package/gs/errors/godoc.txt +63 -0
  132. package/gs/errors/index.ts +1 -0
  133. package/gs/internal/goarch/godoc.txt +39 -0
  134. package/gs/internal/goarch/index.ts +18 -0
  135. package/gs/io/godoc.txt +61 -0
  136. package/gs/io/index.ts +1 -0
  137. package/gs/io/io.go +75 -0
  138. package/gs/io/io.ts +546 -0
  139. package/gs/iter/godoc.txt +203 -0
  140. package/gs/iter/index.ts +1 -0
  141. package/gs/iter/iter.ts +117 -0
  142. package/gs/math/bits/index.ts +356 -0
  143. package/gs/math/godoc.txt +76 -0
  144. package/gs/runtime/godoc.txt +331 -0
  145. package/gs/runtime/index.ts +1 -0
  146. package/gs/runtime/runtime.ts +178 -0
  147. package/gs/slices/godoc.txt +44 -0
  148. package/gs/slices/index.ts +1 -0
  149. package/gs/slices/slices.ts +22 -0
  150. package/gs/strings/builder.test.ts +121 -0
  151. package/gs/strings/builder.ts +223 -0
  152. package/gs/strings/clone.test.ts +43 -0
  153. package/gs/strings/clone.ts +17 -0
  154. package/gs/strings/compare.test.ts +84 -0
  155. package/gs/strings/compare.ts +13 -0
  156. package/gs/strings/godoc.txt +66 -0
  157. package/gs/strings/index.ts +2 -0
  158. package/gs/strings/iter.test.ts +343 -0
  159. package/gs/strings/iter.ts +171 -0
  160. package/gs/strings/reader.test.ts +243 -0
  161. package/gs/strings/reader.ts +451 -0
  162. package/gs/strings/replace.test.ts +181 -0
  163. package/gs/strings/replace.ts +1310 -0
  164. package/gs/strings/search.test.ts +214 -0
  165. package/gs/strings/search.ts +213 -0
  166. package/gs/strings/strings.test.ts +477 -0
  167. package/gs/strings/strings.ts +510 -0
  168. package/gs/stringslite/godoc.txt +17 -0
  169. package/gs/stringslite/index.ts +1 -0
  170. package/gs/stringslite/strings.ts +82 -0
  171. package/gs/sync/godoc.txt +21 -0
  172. package/gs/sync/index.ts +1 -0
  173. package/gs/sync/sync.go +64 -0
  174. package/gs/sync/sync.ts +449 -0
  175. package/gs/time/godoc.md +116 -0
  176. package/gs/time/godoc.txt +116 -0
  177. package/gs/time/index.ts +1 -0
  178. package/gs/time/time.ts +272 -0
  179. package/gs/unicode/godoc.txt +52 -0
  180. package/gs/unicode/index.ts +1 -0
  181. package/gs/unicode/unicode.go +38 -0
  182. package/gs/unicode/unicode.ts +418 -0
  183. package/gs/unicode/utf8/godoc.txt +22 -0
  184. package/gs/unicode/utf8/index.ts +2 -0
  185. package/gs/unicode/utf8/utf8.ts +227 -0
  186. package/gs/unsafe/godoc.txt +19 -0
  187. package/gs/unsafe/index.ts +1 -0
  188. package/gs/unsafe/unsafe.test.ts +68 -0
  189. package/gs/unsafe/unsafe.ts +77 -0
  190. package/package.json +6 -4
@@ -0,0 +1,223 @@
1
+ import * as $ from '@goscript/builtin/builtin.js'
2
+
3
+ // GoScriptError implements the Go error interface
4
+ class GoScriptError {
5
+ constructor(private message: string) {}
6
+
7
+ Error(): string {
8
+ return this.message
9
+ }
10
+
11
+ toString(): string {
12
+ return this.message
13
+ }
14
+ }
15
+
16
+ // New returns an error that formats as the given text.
17
+ // Each call to New returns a distinct error value even if the text is identical.
18
+ export function New(text: string): $.GoError {
19
+ return new GoScriptError(text)
20
+ }
21
+
22
+ // ErrUnsupported indicates that a requested operation cannot be performed,
23
+ // because it is unsupported. For example, a call to os.Link when using a
24
+ // file system that does not support hard links.
25
+ //
26
+ // Functions and methods should not return this error but should instead
27
+ // return an error including appropriate context that satisfies
28
+ //
29
+ // errors.Is(err, errors.ErrUnsupported)
30
+ //
31
+ // either by directly wrapping ErrUnsupported or by implementing an Is method.
32
+ export const ErrUnsupported = New('unsupported operation')
33
+
34
+ // Unwrap returns the result of calling the Unwrap method on err, if err's
35
+ // type contains an Unwrap method returning error.
36
+ // Otherwise, Unwrap returns nil.
37
+ export function Unwrap(err: $.GoError): $.GoError {
38
+ if (err === null) {
39
+ return null
40
+ }
41
+
42
+ // Check if the error has an Unwrap method
43
+ if (typeof (err as any).Unwrap === 'function') {
44
+ const result = (err as any).Unwrap()
45
+ if (result && typeof result.Error === 'function') {
46
+ return result
47
+ }
48
+ // Handle case where Unwrap returns []error
49
+ if (
50
+ Array.isArray(result) &&
51
+ result.length > 0 &&
52
+ result[0] &&
53
+ typeof result[0].Error === 'function'
54
+ ) {
55
+ return result[0]
56
+ }
57
+ }
58
+
59
+ return null
60
+ }
61
+
62
+ // Is reports whether any error in err's tree matches target.
63
+ //
64
+ // The tree consists of err itself, followed by the errors obtained by repeatedly
65
+ // calling Unwrap. When err wraps multiple errors, Is examines err followed by a
66
+ // depth-first traversal of its children.
67
+ //
68
+ // An error is considered to match a target if it is equal to that target or if
69
+ // it implements a method Is(error) bool such that Is(target) returns true.
70
+ //
71
+ // An error type might provide an Is method so it can be treated as equivalent
72
+ // to an existing error. For example, if MyError defines
73
+ //
74
+ // func (m MyError) Is(target error) bool { return target == fs.ErrExist }
75
+ //
76
+ // then Is(MyError{}, fs.ErrExist) returns true. See syscall.Errno.Is for
77
+ // an example in the standard library. An Is method should only shallowly
78
+ // compare err and the target and not call Unwrap on either.
79
+ export function Is(err: $.GoError, target: $.GoError): boolean {
80
+ if (target === null) {
81
+ return err === null
82
+ }
83
+
84
+ if (err === null) {
85
+ return false
86
+ }
87
+
88
+ // Check direct equality
89
+ if (err === target) {
90
+ return true
91
+ }
92
+
93
+ // Check if error messages are the same
94
+ if (err.Error() === target.Error()) {
95
+ return true
96
+ }
97
+
98
+ // Check if err has an Is method
99
+ if (typeof (err as any).Is === 'function') {
100
+ if ((err as any).Is(target)) {
101
+ return true
102
+ }
103
+ }
104
+
105
+ // Recursively check wrapped errors
106
+ const unwrapped = Unwrap(err)
107
+ if (unwrapped !== null) {
108
+ return Is(unwrapped, target)
109
+ }
110
+
111
+ // Handle multiple wrapped errors
112
+ if (typeof (err as any).Unwrap === 'function') {
113
+ const result = (err as any).Unwrap()
114
+ if (Array.isArray(result)) {
115
+ for (const wrappedErr of result) {
116
+ if (
117
+ wrappedErr &&
118
+ typeof wrappedErr.Error === 'function' &&
119
+ Is(wrappedErr, target)
120
+ ) {
121
+ return true
122
+ }
123
+ }
124
+ }
125
+ }
126
+
127
+ return false
128
+ }
129
+
130
+ // As finds the first error in err's tree that matches target, and if one is found,
131
+ // sets target to that error value and returns true. Otherwise, it returns false.
132
+ //
133
+ // The tree consists of err itself, followed by the errors obtained by repeatedly
134
+ // calling Unwrap. When err wraps multiple errors, As examines err followed by a
135
+ // depth-first traversal of its children.
136
+ //
137
+ // An error matches target if the error's concrete value is assignable to the value
138
+ // pointed to by target, or if the error has a method As(interface{}) bool such that
139
+ // As(target) returns true. In the latter case, the As method is responsible for
140
+ // setting target.
141
+ //
142
+ // An error type might provide an As method so it can be treated as if it were a
143
+ // different error type.
144
+ //
145
+ // As panics if target is not a non-nil pointer to either a type that implements
146
+ // error, or to any interface type.
147
+ export function As(err: $.GoError, target: any): boolean {
148
+ if (err === null) {
149
+ return false
150
+ }
151
+
152
+ if (target === null || typeof target !== 'object') {
153
+ throw new Error('errors: target cannot be nil')
154
+ }
155
+
156
+ // Check if err matches target type
157
+ if (err.constructor === target.constructor) {
158
+ // Copy properties from err to target
159
+ Object.assign(target, err)
160
+ return true
161
+ }
162
+
163
+ // Check if err has an As method
164
+ if (typeof (err as any).As === 'function') {
165
+ if ((err as any).As(target)) {
166
+ return true
167
+ }
168
+ }
169
+
170
+ // Recursively check wrapped errors
171
+ const unwrapped = Unwrap(err)
172
+ if (unwrapped !== null) {
173
+ return As(unwrapped, target)
174
+ }
175
+
176
+ // Handle multiple wrapped errors
177
+ if (typeof (err as any).Unwrap === 'function') {
178
+ const result = (err as any).Unwrap()
179
+ if (Array.isArray(result)) {
180
+ for (const wrappedErr of result) {
181
+ if (
182
+ wrappedErr &&
183
+ typeof wrappedErr.Error === 'function' &&
184
+ As(wrappedErr, target)
185
+ ) {
186
+ return true
187
+ }
188
+ }
189
+ }
190
+ }
191
+
192
+ return false
193
+ }
194
+
195
+ // Join returns an error that wraps the given errors.
196
+ // Any nil error values are discarded.
197
+ // Join returns nil if every value in errs is nil.
198
+ // The error formats as the concatenation of the strings obtained
199
+ // by calling the Error method of each element of errs, with a newline
200
+ // between each string.
201
+ //
202
+ // A non-nil error returned by Join implements the Unwrap() []error method.
203
+ export function Join(...errs: $.GoError[]): $.GoError {
204
+ const nonNilErrs = errs.filter((err) => err !== null)
205
+
206
+ if (nonNilErrs.length === 0) {
207
+ return null
208
+ }
209
+
210
+ if (nonNilErrs.length === 1) {
211
+ return nonNilErrs[0]
212
+ }
213
+
214
+ const message = nonNilErrs.map((err) => err!.Error()).join('\n')
215
+ const joinedError = new GoScriptError(message)
216
+
217
+ // Add Unwrap method that returns the array of errors
218
+ ;(joinedError as any).Unwrap = function (): $.GoError[] {
219
+ return nonNilErrs
220
+ }
221
+
222
+ return joinedError
223
+ }
@@ -0,0 +1,63 @@
1
+ package errors // import "errors"
2
+
3
+ Package errors implements functions to manipulate errors.
4
+
5
+ The New function creates errors whose only content is a text message.
6
+
7
+ An error e wraps another error if e's type has one of the methods
8
+
9
+ Unwrap() error
10
+ Unwrap() []error
11
+
12
+ If e.Unwrap() returns a non-nil error w or a slice containing w, then we say
13
+ that e wraps w. A nil error returned from e.Unwrap() indicates that e does
14
+ not wrap any error. It is invalid for an Unwrap method to return an []error
15
+ containing a nil error value.
16
+
17
+ An easy way to create wrapped errors is to call fmt.Errorf and apply the %w verb
18
+ to the error argument:
19
+
20
+ wrapsErr := fmt.Errorf("... %w ...", ..., err, ...)
21
+
22
+ Successive unwrapping of an error creates a tree. The Is and As functions
23
+ inspect an error's tree by examining first the error itself followed by the tree
24
+ of each of its children in turn (pre-order, depth-first traversal).
25
+
26
+ See https://go.dev/blog/go1.13-errors for a deeper discussion of the philosophy
27
+ of wrapping and when to wrap.
28
+
29
+ Is examines the tree of its first argument looking for an error that matches the
30
+ second. It reports whether it finds a match. It should be used in preference to
31
+ simple equality checks:
32
+
33
+ if errors.Is(err, fs.ErrExist)
34
+
35
+ is preferable to
36
+
37
+ if err == fs.ErrExist
38
+
39
+ because the former will succeed if err wraps io/fs.ErrExist.
40
+
41
+ As examines the tree of its first argument looking for an error that can be
42
+ assigned to its second argument, which must be a pointer. If it succeeds, it
43
+ performs the assignment and returns true. Otherwise, it returns false. The form
44
+
45
+ var perr *fs.PathError
46
+ if errors.As(err, &perr) {
47
+ fmt.Println(perr.Path)
48
+ }
49
+
50
+ is preferable to
51
+
52
+ if perr, ok := err.(*fs.PathError); ok {
53
+ fmt.Println(perr.Path)
54
+ }
55
+
56
+ because the former will succeed if err wraps an *io/fs.PathError.
57
+
58
+ var ErrUnsupported = New("unsupported operation")
59
+ func As(err error, target any) bool
60
+ func Is(err, target error) bool
61
+ func Join(errs ...error) error
62
+ func New(text string) error
63
+ func Unwrap(err error) error
@@ -0,0 +1 @@
1
+ export * from './errors.js'
@@ -0,0 +1,39 @@
1
+ package goarch // import "internal/goarch"
2
+
3
+ package goarch contains GOARCH-specific constants.
4
+
5
+ const BigEndian = IsArmbe|IsArm64be|IsMips|IsMips64|IsPpc|IsPpc64|IsS390|IsS390x|IsSparc|IsSparc64 == 1
6
+ const DefaultPhysPageSize = _DefaultPhysPageSize
7
+ const GOARCH = `arm64`
8
+ const Int64Align = PtrSize
9
+ const Is386 = 0
10
+ const IsAmd64 = 0
11
+ const IsAmd64p32 = 0
12
+ const IsArm = 0
13
+ const IsArm64 = 1
14
+ const IsArm64be = 0
15
+ const IsArmbe = 0
16
+ const IsLoong64 = 0
17
+ const IsMips = 0
18
+ const IsMips64 = 0
19
+ const IsMips64le = 0
20
+ const IsMips64p32 = 0
21
+ const IsMips64p32le = 0
22
+ const IsMipsle = 0
23
+ const IsPpc = 0
24
+ const IsPpc64 = 0
25
+ const IsPpc64le = 0
26
+ const IsRiscv = 0
27
+ const IsRiscv64 = 0
28
+ const IsS390 = 0
29
+ const IsS390x = 0
30
+ const IsSparc = 0
31
+ const IsSparc64 = 0
32
+ const IsWasm = 0
33
+ const MinFrameSize = _MinFrameSize
34
+ const PCQuantum = _PCQuantum
35
+ const PtrSize = 4 << (^uintptr(0) >> 63)
36
+ const StackAlign = _StackAlign
37
+ type ArchFamilyType int
38
+ const AMD64 ArchFamilyType = iota ...
39
+ const ArchFamily ArchFamilyType = _ArchFamily
@@ -0,0 +1,18 @@
1
+ // Architecture constants for JavaScript/WebAssembly target
2
+ // This replaces the auto-generated version with appropriate values for JS
3
+
4
+ // Pointer size in bytes (64-bit in modern JavaScript environments)
5
+ export const PtrSize = 8
6
+
7
+ // JavaScript is little-endian
8
+ export const BigEndian = false
9
+
10
+ // Architecture family
11
+ export const ArchFamily = 'wasm'
12
+
13
+ // Other common architecture constants
14
+ export const Int64Align = 8
15
+ export const MinFrameSize = 0
16
+
17
+ // CPU cache line size (not really applicable in JS, but some code might reference it)
18
+ export const CacheLineSize = 64
@@ -0,0 +1,61 @@
1
+ package io // import "io"
2
+
3
+ Package io provides basic interfaces to I/O primitives. Its primary job is to
4
+ wrap existing implementations of such primitives, such as those in package os,
5
+ into shared public interfaces that abstract the functionality, plus some other
6
+ related primitives.
7
+
8
+ Because these interfaces and primitives wrap lower-level operations with various
9
+ implementations, unless otherwise informed clients should not assume they are
10
+ safe for parallel execution.
11
+
12
+ const SeekStart = 0 ...
13
+ var EOF = errors.New("EOF")
14
+ var ErrClosedPipe = errors.New("io: read/write on closed pipe")
15
+ var ErrNoProgress = errors.New("multiple Read calls return no data or error")
16
+ var ErrShortBuffer = errors.New("short buffer")
17
+ var ErrShortWrite = errors.New("short write")
18
+ var ErrUnexpectedEOF = errors.New("unexpected EOF")
19
+ func Copy(dst Writer, src Reader) (written int64, err error)
20
+ func CopyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error)
21
+ func CopyN(dst Writer, src Reader, n int64) (written int64, err error)
22
+ func Pipe() (*PipeReader, *PipeWriter)
23
+ func ReadAll(r Reader) ([]byte, error)
24
+ func ReadAtLeast(r Reader, buf []byte, min int) (n int, err error)
25
+ func ReadFull(r Reader, buf []byte) (n int, err error)
26
+ func WriteString(w Writer, s string) (n int, err error)
27
+ type ByteReader interface{ ... }
28
+ type ByteScanner interface{ ... }
29
+ type ByteWriter interface{ ... }
30
+ type Closer interface{ ... }
31
+ type LimitedReader struct{ ... }
32
+ type OffsetWriter struct{ ... }
33
+ func NewOffsetWriter(w WriterAt, off int64) *OffsetWriter
34
+ type PipeReader struct{ ... }
35
+ type PipeWriter struct{ ... }
36
+ type ReadCloser interface{ ... }
37
+ func NopCloser(r Reader) ReadCloser
38
+ type ReadSeekCloser interface{ ... }
39
+ type ReadSeeker interface{ ... }
40
+ type ReadWriteCloser interface{ ... }
41
+ type ReadWriteSeeker interface{ ... }
42
+ type ReadWriter interface{ ... }
43
+ type Reader interface{ ... }
44
+ func LimitReader(r Reader, n int64) Reader
45
+ func MultiReader(readers ...Reader) Reader
46
+ func TeeReader(r Reader, w Writer) Reader
47
+ type ReaderAt interface{ ... }
48
+ type ReaderFrom interface{ ... }
49
+ type RuneReader interface{ ... }
50
+ type RuneScanner interface{ ... }
51
+ type SectionReader struct{ ... }
52
+ func NewSectionReader(r ReaderAt, off int64, n int64) *SectionReader
53
+ type Seeker interface{ ... }
54
+ type StringWriter interface{ ... }
55
+ type WriteCloser interface{ ... }
56
+ type WriteSeeker interface{ ... }
57
+ type Writer interface{ ... }
58
+ var Discard Writer = discard{}
59
+ func MultiWriter(writers ...Writer) Writer
60
+ type WriterAt interface{ ... }
61
+ type WriterTo interface{ ... }
package/gs/io/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './io.js'
package/gs/io/io.go ADDED
@@ -0,0 +1,75 @@
1
+ package io
2
+
3
+ import "github.com/aperturerobotics/goscript/compiler"
4
+
5
+ // Metadata for io package functions
6
+ // This defines which functions/methods are async for the compiler analysis
7
+
8
+ // Most io operations are synchronous in our implementation
9
+ // since we're dealing with in-memory operations and simple transformations
10
+
11
+ // Copy functions - these could potentially be async if dealing with large data
12
+ // but for simplicity, we'll keep them sync for now
13
+ var (
14
+ CopyInfo = compiler.FunctionInfo{IsAsync: false}
15
+ CopyBufferInfo = compiler.FunctionInfo{IsAsync: false}
16
+ CopyNInfo = compiler.FunctionInfo{IsAsync: false}
17
+ )
18
+
19
+ // Read functions - sync since they're immediate operations
20
+ var (
21
+ ReadAllInfo = compiler.FunctionInfo{IsAsync: false}
22
+ ReadAtLeastInfo = compiler.FunctionInfo{IsAsync: false}
23
+ ReadFullInfo = compiler.FunctionInfo{IsAsync: false}
24
+ )
25
+
26
+ // Write functions - sync
27
+ var WriteStringInfo = compiler.FunctionInfo{IsAsync: false}
28
+
29
+ // Utility functions - sync
30
+ var (
31
+ LimitReaderInfo = compiler.FunctionInfo{IsAsync: false}
32
+ MultiReaderInfo = compiler.FunctionInfo{IsAsync: false}
33
+ MultiWriterInfo = compiler.FunctionInfo{IsAsync: false}
34
+ TeeReaderInfo = compiler.FunctionInfo{IsAsync: false}
35
+ NopCloserInfo = compiler.FunctionInfo{IsAsync: false}
36
+ NewSectionReaderInfo = compiler.FunctionInfo{IsAsync: false}
37
+ NewOffsetWriterInfo = compiler.FunctionInfo{IsAsync: false}
38
+ )
39
+
40
+ // Interface methods - sync for basic operations
41
+ // Reader methods
42
+ var ReaderReadInfo = compiler.FunctionInfo{IsAsync: false}
43
+
44
+ // Writer methods
45
+ var WriterWriteInfo = compiler.FunctionInfo{IsAsync: false}
46
+
47
+ // Closer methods
48
+ var CloserCloseInfo = compiler.FunctionInfo{IsAsync: false}
49
+
50
+ // Seeker methods
51
+ var SeekerSeekInfo = compiler.FunctionInfo{IsAsync: false}
52
+
53
+ // ReaderAt methods
54
+ var ReaderAtReadAtInfo = compiler.FunctionInfo{IsAsync: false}
55
+
56
+ // WriterAt methods
57
+ var WriterAtWriteAtInfo = compiler.FunctionInfo{IsAsync: false}
58
+
59
+ // LimitedReader methods
60
+ var LimitedReaderReadInfo = compiler.FunctionInfo{IsAsync: false}
61
+
62
+ // SectionReader methods
63
+ var (
64
+ SectionReaderReadInfo = compiler.FunctionInfo{IsAsync: false}
65
+ SectionReaderSeekInfo = compiler.FunctionInfo{IsAsync: false}
66
+ SectionReaderReadAtInfo = compiler.FunctionInfo{IsAsync: false}
67
+ SectionReaderSizeInfo = compiler.FunctionInfo{IsAsync: false}
68
+ )
69
+
70
+ // OffsetWriter methods
71
+ var (
72
+ OffsetWriterWriteInfo = compiler.FunctionInfo{IsAsync: false}
73
+ OffsetWriterWriteAtInfo = compiler.FunctionInfo{IsAsync: false}
74
+ OffsetWriterSeekInfo = compiler.FunctionInfo{IsAsync: false}
75
+ )