goscript 0.0.30 → 0.0.32

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 (106) hide show
  1. package/compiler/expr-call.go +54 -0
  2. package/compiler/index.ts +1 -1
  3. package/compiler/stmt-assign.go +14 -0
  4. package/dist/compiler/index.js +1 -1
  5. package/dist/compiler/index.js.map +1 -1
  6. package/dist/gs/builtin/channel.d.ts +6 -6
  7. package/dist/gs/builtin/channel.js +3 -3
  8. package/dist/gs/builtin/channel.js.map +1 -1
  9. package/dist/gs/builtin/slice.js +3 -9
  10. package/dist/gs/builtin/slice.js.map +1 -1
  11. package/dist/gs/context/context.js +2 -2
  12. package/dist/gs/context/context.js.map +1 -1
  13. package/dist/gs/internal/oserror/errors.d.ts +1 -1
  14. package/dist/gs/internal/oserror/errors.js +6 -6
  15. package/dist/gs/internal/oserror/index.d.ts +1 -1
  16. package/dist/gs/internal/oserror/index.js +1 -1
  17. package/dist/gs/internal/oserror/index.js.map +1 -1
  18. package/dist/gs/io/fs/format.d.ts +1 -1
  19. package/dist/gs/io/fs/format.js +12 -12
  20. package/dist/gs/io/fs/format.js.map +1 -1
  21. package/dist/gs/io/fs/fs.d.ts +2 -2
  22. package/dist/gs/io/fs/fs.js +258 -36
  23. package/dist/gs/io/fs/fs.js.map +1 -1
  24. package/dist/gs/io/fs/glob.d.ts +2 -2
  25. package/dist/gs/io/fs/glob.js +40 -14
  26. package/dist/gs/io/fs/glob.js.map +1 -1
  27. package/dist/gs/io/fs/index.d.ts +8 -8
  28. package/dist/gs/io/fs/index.js +8 -8
  29. package/dist/gs/io/fs/readdir.d.ts +2 -2
  30. package/dist/gs/io/fs/readdir.js +78 -9
  31. package/dist/gs/io/fs/readdir.js.map +1 -1
  32. package/dist/gs/io/fs/readfile.d.ts +2 -2
  33. package/dist/gs/io/fs/readfile.js +31 -13
  34. package/dist/gs/io/fs/readfile.js.map +1 -1
  35. package/dist/gs/io/fs/stat.d.ts +2 -2
  36. package/dist/gs/io/fs/stat.js +25 -2
  37. package/dist/gs/io/fs/stat.js.map +1 -1
  38. package/dist/gs/io/fs/sub.d.ts +2 -2
  39. package/dist/gs/io/fs/sub.js +264 -28
  40. package/dist/gs/io/fs/sub.js.map +1 -1
  41. package/dist/gs/io/fs/walk.d.ts +2 -2
  42. package/dist/gs/io/fs/walk.js +7 -7
  43. package/dist/gs/io/fs/walk.js.map +1 -1
  44. package/dist/gs/iter/iter.js +1 -1
  45. package/dist/gs/iter/iter.js.map +1 -1
  46. package/dist/gs/path/index.d.ts +2 -2
  47. package/dist/gs/path/index.js +2 -2
  48. package/dist/gs/path/match.d.ts +1 -1
  49. package/dist/gs/path/match.js +39 -33
  50. package/dist/gs/path/match.js.map +1 -1
  51. package/dist/gs/path/path.js +53 -24
  52. package/dist/gs/path/path.js.map +1 -1
  53. package/dist/gs/runtime/runtime.d.ts +3 -3
  54. package/dist/gs/runtime/runtime.js +3 -3
  55. package/dist/gs/runtime/runtime.js.map +1 -1
  56. package/dist/gs/strings/builder.d.ts +1 -1
  57. package/dist/gs/strings/builder.js +1 -1
  58. package/dist/gs/strings/builder.js.map +1 -1
  59. package/dist/gs/strings/clone.js.map +1 -1
  60. package/dist/gs/strings/compare.js.map +1 -1
  61. package/dist/gs/strings/replace.js +4 -2
  62. package/dist/gs/strings/replace.js.map +1 -1
  63. package/dist/gs/strings/strings.js +0 -12
  64. package/dist/gs/strings/strings.js.map +1 -1
  65. package/dist/gs/sync/sync.d.ts +5 -5
  66. package/dist/gs/sync/sync.js +5 -5
  67. package/dist/gs/sync/sync.js.map +1 -1
  68. package/dist/gs/time/time.d.ts +2 -2
  69. package/dist/gs/time/time.js +62 -16
  70. package/dist/gs/time/time.js.map +1 -1
  71. package/dist/gs/unsafe/unsafe.d.ts +8 -8
  72. package/dist/gs/unsafe/unsafe.js +8 -8
  73. package/dist/gs/unsafe/unsafe.js.map +1 -1
  74. package/gs/builtin/builtin.ts +1 -1
  75. package/gs/builtin/channel.ts +6 -6
  76. package/gs/builtin/slice.ts +3 -9
  77. package/gs/context/context.ts +2 -2
  78. package/gs/internal/oserror/errors.ts +7 -8
  79. package/gs/internal/oserror/index.ts +7 -1
  80. package/gs/io/fs/format.ts +39 -40
  81. package/gs/io/fs/fs.ts +446 -222
  82. package/gs/io/fs/glob.ts +164 -131
  83. package/gs/io/fs/index.ts +8 -8
  84. package/gs/io/fs/readdir.ts +188 -106
  85. package/gs/io/fs/readfile.ts +79 -58
  86. package/gs/io/fs/stat.ts +49 -25
  87. package/gs/io/fs/sub.ts +422 -181
  88. package/gs/io/fs/walk.ts +67 -63
  89. package/gs/iter/iter.ts +1 -1
  90. package/gs/path/index.ts +2 -2
  91. package/gs/path/match.ts +263 -250
  92. package/gs/path/path.ts +259 -232
  93. package/gs/runtime/runtime.ts +4 -4
  94. package/gs/strings/builder.test.ts +0 -1
  95. package/gs/strings/builder.ts +1 -1
  96. package/gs/strings/clone.ts +0 -2
  97. package/gs/strings/compare.ts +0 -2
  98. package/gs/strings/iter.test.ts +0 -1
  99. package/gs/strings/replace.test.ts +3 -4
  100. package/gs/strings/replace.ts +4 -7
  101. package/gs/strings/strings.test.ts +6 -6
  102. package/gs/strings/strings.ts +0 -14
  103. package/gs/sync/sync.ts +5 -5
  104. package/gs/time/time.ts +86 -29
  105. package/gs/unsafe/unsafe.ts +8 -8
  106. package/package.json +1 -1
package/gs/path/path.ts CHANGED
@@ -1,89 +1,112 @@
1
- import * as $ from "@goscript/builtin/builtin.js";
1
+ import * as $ from '@goscript/builtin/builtin.js'
2
2
 
3
3
  class lazybuf {
4
- public get s(): string {
5
- return this._fields.s.value
6
- }
7
- public set s(value: string) {
8
- this._fields.s.value = value
9
- }
10
-
11
- public get buf(): Uint8Array | null {
12
- return this._fields.buf.value
13
- }
14
- public set buf(value: Uint8Array | null) {
15
- this._fields.buf.value = value
16
- }
17
-
18
- public get w(): number {
19
- return this._fields.w.value
20
- }
21
- public set w(value: number) {
22
- this._fields.w.value = value
23
- }
24
-
25
- public _fields: {
26
- s: $.VarRef<string>;
27
- buf: $.VarRef<Uint8Array | null>;
28
- w: $.VarRef<number>;
29
- }
30
-
31
- constructor(init?: Partial<{buf?: Uint8Array, s?: string, w?: number}>) {
32
- this._fields = {
33
- s: $.varRef(init?.s ?? ""),
34
- buf: $.varRef(init?.buf ?? null),
35
- w: $.varRef(init?.w ?? 0)
36
- }
37
- }
38
-
39
- public clone(): lazybuf {
40
- const cloned = new lazybuf()
41
- cloned._fields = {
42
- s: $.varRef(this._fields.s.value),
43
- buf: $.varRef(this._fields.buf.value),
44
- w: $.varRef(this._fields.w.value)
45
- }
46
- return cloned
47
- }
48
-
49
- public index(i: number): number {
50
- const b = this
51
- if (b!.buf != null) {
52
- return b!.buf![i]
53
- }
54
- return $.indexString(b!.s, i)
55
- }
56
-
57
- public append(c: number): void {
58
- const b = this
59
- if (b!.buf == null) {
60
- if (b!.w < $.len(b!.s) && $.indexString(b!.s, b!.w) == c) {
61
- b!.w++
62
- return
63
- }
64
- b!.buf = new Uint8Array($.len(b!.s))
65
- $.copy(b!.buf, $.stringToBytes($.sliceString(b!.s, undefined, b!.w)))
66
- }
67
- b!.buf![b!.w] = c
68
- b!.w++
69
- }
70
-
71
- public _string(): string {
72
- const b = this
73
- if (b!.buf == null) {
74
- return $.sliceString(b!.s, undefined, b!.w)
75
- }
76
- return $.bytesToString(b!.buf.subarray(0, b!.w))
77
- }
78
-
79
- // Register this type with the runtime type system
80
- static __typeInfo = $.registerStructType(
81
- 'lazybuf',
82
- new lazybuf(),
83
- [{ name: "index", args: [{ name: "i", type: { kind: $.TypeKind.Basic, name: "number" } }], returns: [{ type: { kind: $.TypeKind.Basic, name: "number" } }] }, { name: "append", args: [{ name: "c", type: { kind: $.TypeKind.Basic, name: "number" } }], returns: [] }, { name: "string", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "string" } }] }],
84
- lazybuf,
85
- {"s": { kind: $.TypeKind.Basic, name: "string" }, "buf": { kind: $.TypeKind.Slice, elemType: { kind: $.TypeKind.Basic, name: "number" } }, "w": { kind: $.TypeKind.Basic, name: "number" }}
86
- );
4
+ public get s(): string {
5
+ return this._fields.s.value
6
+ }
7
+ public set s(value: string) {
8
+ this._fields.s.value = value
9
+ }
10
+
11
+ public get buf(): Uint8Array | null {
12
+ return this._fields.buf.value
13
+ }
14
+ public set buf(value: Uint8Array | null) {
15
+ this._fields.buf.value = value
16
+ }
17
+
18
+ public get w(): number {
19
+ return this._fields.w.value
20
+ }
21
+ public set w(value: number) {
22
+ this._fields.w.value = value
23
+ }
24
+
25
+ public _fields: {
26
+ s: $.VarRef<string>
27
+ buf: $.VarRef<Uint8Array | null>
28
+ w: $.VarRef<number>
29
+ }
30
+
31
+ constructor(init?: Partial<{ buf?: Uint8Array; s?: string; w?: number }>) {
32
+ this._fields = {
33
+ s: $.varRef(init?.s ?? ''),
34
+ buf: $.varRef(init?.buf ?? null),
35
+ w: $.varRef(init?.w ?? 0),
36
+ }
37
+ }
38
+
39
+ public clone(): lazybuf {
40
+ const cloned = new lazybuf()
41
+ cloned._fields = {
42
+ s: $.varRef(this._fields.s.value),
43
+ buf: $.varRef(this._fields.buf.value),
44
+ w: $.varRef(this._fields.w.value),
45
+ }
46
+ return cloned
47
+ }
48
+
49
+ public index(i: number): number {
50
+ const b = this
51
+ if (b!.buf != null) {
52
+ return b!.buf![i]
53
+ }
54
+ return $.indexString(b!.s, i)
55
+ }
56
+
57
+ public append(c: number): void {
58
+ const b = this
59
+ if (b!.buf == null) {
60
+ if (b!.w < $.len(b!.s) && $.indexString(b!.s, b!.w) == c) {
61
+ b!.w++
62
+ return
63
+ }
64
+ b!.buf = new Uint8Array($.len(b!.s))
65
+ $.copy(b!.buf, $.stringToBytes($.sliceString(b!.s, undefined, b!.w)))
66
+ }
67
+ b!.buf![b!.w] = c
68
+ b!.w++
69
+ }
70
+
71
+ public _string(): string {
72
+ const b = this
73
+ if (b!.buf == null) {
74
+ return $.sliceString(b!.s, undefined, b!.w)
75
+ }
76
+ return $.bytesToString(b!.buf.subarray(0, b!.w))
77
+ }
78
+
79
+ // Register this type with the runtime type system
80
+ static __typeInfo = $.registerStructType(
81
+ 'lazybuf',
82
+ new lazybuf(),
83
+ [
84
+ {
85
+ name: 'index',
86
+ args: [{ name: 'i', type: { kind: $.TypeKind.Basic, name: 'number' } }],
87
+ returns: [{ type: { kind: $.TypeKind.Basic, name: 'number' } }],
88
+ },
89
+ {
90
+ name: 'append',
91
+ args: [{ name: 'c', type: { kind: $.TypeKind.Basic, name: 'number' } }],
92
+ returns: [],
93
+ },
94
+ {
95
+ name: 'string',
96
+ args: [],
97
+ returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }],
98
+ },
99
+ ],
100
+ lazybuf,
101
+ {
102
+ s: { kind: $.TypeKind.Basic, name: 'string' },
103
+ buf: {
104
+ kind: $.TypeKind.Slice,
105
+ elemType: { kind: $.TypeKind.Basic, name: 'number' },
106
+ },
107
+ w: { kind: $.TypeKind.Basic, name: 'number' },
108
+ },
109
+ )
87
110
  }
88
111
 
89
112
  // Clean returns the shortest path name equivalent to path
@@ -106,100 +129,102 @@ class lazybuf {
106
129
  // Getting Dot-Dot Right,"
107
130
  // https://9p.io/sys/doc/lexnames.html
108
131
  export function Clean(path: string): string {
109
- if (path == "") {
110
- return "."
111
- }
112
-
113
- let rooted = $.indexString(path, 0) == 47
114
- let n = $.len(path)
115
-
116
- // Invariants:
117
- // reading from path; r is index of next byte to process.
118
- // writing to buf; w is index of next byte to write.
119
- // dotdot is index in buf where .. must stop, either because
120
- // it is the leading slash or it is a leading ../../.. prefix.
121
- let out = new lazybuf({s: path})
122
- let r = 0
123
- let dotdot = 0
124
- if (rooted) {
125
- out.append(47)
126
- r = 1
127
- dotdot = 1
128
- }
129
-
130
- // empty path element
131
-
132
- // . element
133
-
134
- // .. element: remove to last /
135
-
136
- // can backtrack
137
-
138
- // cannot backtrack, but not rooted, so append .. element.
139
-
140
- // real path element.
141
- // add slash if needed
142
-
143
- // copy element
144
- for (; r < n; ) {
145
-
146
- // empty path element
147
-
148
- // . element
149
-
150
- // .. element: remove to last /
151
-
152
- // can backtrack
153
-
154
- // cannot backtrack, but not rooted, so append .. element.
155
-
156
- // real path element.
157
- // add slash if needed
158
-
159
- // copy element
160
- switch (true) {
161
- case $.indexString(path, r) == 47:
162
- r++
163
- break
164
- case $.indexString(path, r) == 46 && (r + 1 == n || $.indexString(path, r + 1) == 47):
165
- r++
166
- break
167
- case $.indexString(path, r) == 46 && $.indexString(path, r + 1) == 46 && (r + 2 == n || $.indexString(path, r + 2) == 47):
168
- r += 2
169
- switch (true) {
170
- case out.w > dotdot:
171
- out.w--
172
- for (; out.w > dotdot && out.index(out.w) != 47; ) {
173
- out.w--
174
- }
175
- break
176
- case !rooted:
177
- if (out.w > 0) {
178
- out.append(47)
179
- }
180
- out.append(46)
181
- out.append(46)
182
- dotdot = out.w
183
- break
184
- }
185
- break
186
- default:
187
- if (rooted && out.w != 1 || !rooted && out.w != 0) {
188
- out.append(47)
189
- }
190
- for (; r < n && $.indexString(path, r) != 47; r++) {
191
- out.append($.indexString(path, r))
192
- }
193
- break
194
- }
195
- }
196
-
197
- // Turn empty string into "."
198
- if (out.w == 0) {
199
- return "."
200
- }
201
-
202
- return out._string()
132
+ if (path == '') {
133
+ return '.'
134
+ }
135
+
136
+ let rooted = $.indexString(path, 0) == 47
137
+ let n = $.len(path)
138
+
139
+ // Invariants:
140
+ // reading from path; r is index of next byte to process.
141
+ // writing to buf; w is index of next byte to write.
142
+ // dotdot is index in buf where .. must stop, either because
143
+ // it is the leading slash or it is a leading ../../.. prefix.
144
+ let out = new lazybuf({ s: path })
145
+ let r = 0
146
+ let dotdot = 0
147
+ if (rooted) {
148
+ out.append(47)
149
+ r = 1
150
+ dotdot = 1
151
+ }
152
+
153
+ // empty path element
154
+
155
+ // . element
156
+
157
+ // .. element: remove to last /
158
+
159
+ // can backtrack
160
+
161
+ // cannot backtrack, but not rooted, so append .. element.
162
+
163
+ // real path element.
164
+ // add slash if needed
165
+
166
+ // copy element
167
+ for (; r < n; ) {
168
+ // empty path element
169
+
170
+ // . element
171
+
172
+ // .. element: remove to last /
173
+
174
+ // can backtrack
175
+
176
+ // cannot backtrack, but not rooted, so append .. element.
177
+
178
+ // real path element.
179
+ // add slash if needed
180
+
181
+ // copy element
182
+ switch (true) {
183
+ case $.indexString(path, r) == 47:
184
+ r++
185
+ break
186
+ case $.indexString(path, r) == 46 &&
187
+ (r + 1 == n || $.indexString(path, r + 1) == 47):
188
+ r++
189
+ break
190
+ case $.indexString(path, r) == 46 &&
191
+ $.indexString(path, r + 1) == 46 &&
192
+ (r + 2 == n || $.indexString(path, r + 2) == 47):
193
+ r += 2
194
+ switch (true) {
195
+ case out.w > dotdot:
196
+ out.w--
197
+ for (; out.w > dotdot && out.index(out.w) != 47; ) {
198
+ out.w--
199
+ }
200
+ break
201
+ case !rooted:
202
+ if (out.w > 0) {
203
+ out.append(47)
204
+ }
205
+ out.append(46)
206
+ out.append(46)
207
+ dotdot = out.w
208
+ break
209
+ }
210
+ break
211
+ default:
212
+ if ((rooted && out.w != 1) || (!rooted && out.w != 0)) {
213
+ out.append(47)
214
+ }
215
+ for (; r < n && $.indexString(path, r) != 47; r++) {
216
+ out.append($.indexString(path, r))
217
+ }
218
+ break
219
+ }
220
+ }
221
+
222
+ // Turn empty string into "."
223
+ if (out.w == 0) {
224
+ return '.'
225
+ }
226
+
227
+ return out._string()
203
228
  }
204
229
 
205
230
  // Split splits path immediately following the final slash,
@@ -208,8 +233,11 @@ export function Clean(path: string): string {
208
233
  // file set to path.
209
234
  // The returned values have the property that path = dir+file.
210
235
  export function Split(path: string): [string, string] {
211
- let i = path.lastIndexOf("/")
212
- return [$.sliceString(path, undefined, i + 1), $.sliceString(path, i + 1, undefined)]
236
+ let i = path.lastIndexOf('/')
237
+ return [
238
+ $.sliceString(path, undefined, i + 1),
239
+ $.sliceString(path, i + 1, undefined),
240
+ ]
213
241
  }
214
242
 
215
243
  // Join joins any number of path elements into a single path,
@@ -218,29 +246,29 @@ export function Split(path: string): [string, string] {
218
246
  // empty or all its elements are empty, Join returns
219
247
  // an empty string.
220
248
  export function Join(...elem: string[]): string {
221
- let size = 0
222
- for (let _i = 0; _i < $.len(elem); _i++) {
223
- const e = elem![_i]
224
- {
225
- size += $.len(e)
226
- }
227
- }
228
- if (size == 0) {
229
- return ""
230
- }
231
- let buf: string[] = []
232
- for (let _i = 0; _i < $.len(elem); _i++) {
233
- const e = elem![_i]
234
- {
235
- if ($.len(buf) > 0 || e != "") {
236
- if ($.len(buf) > 0) {
237
- buf.push("/")
238
- }
239
- buf.push(e)
240
- }
241
- }
242
- }
243
- return Clean(buf.join(""))
249
+ let size = 0
250
+ for (let _i = 0; _i < $.len(elem); _i++) {
251
+ const e = elem![_i]
252
+ {
253
+ size += $.len(e)
254
+ }
255
+ }
256
+ if (size == 0) {
257
+ return ''
258
+ }
259
+ let buf: string[] = []
260
+ for (let _i = 0; _i < $.len(elem); _i++) {
261
+ const e = elem![_i]
262
+ {
263
+ if ($.len(buf) > 0 || e != '') {
264
+ if ($.len(buf) > 0) {
265
+ buf.push('/')
266
+ }
267
+ buf.push(e)
268
+ }
269
+ }
270
+ }
271
+ return Clean(buf.join(''))
244
272
  }
245
273
 
246
274
  // Ext returns the file name extension used by path.
@@ -248,12 +276,12 @@ export function Join(...elem: string[]): string {
248
276
  // in the final slash-separated element of path;
249
277
  // it is empty if there is no dot.
250
278
  export function Ext(path: string): string {
251
- for (let i = $.len(path) - 1; i >= 0 && $.indexString(path, i) != 47; i--) {
252
- if ($.indexString(path, i) == 46) {
253
- return $.sliceString(path, i, undefined)
254
- }
255
- }
256
- return ""
279
+ for (let i = $.len(path) - 1; i >= 0 && $.indexString(path, i) != 47; i--) {
280
+ if ($.indexString(path, i) == 46) {
281
+ return $.sliceString(path, i, undefined)
282
+ }
283
+ }
284
+ return ''
257
285
  }
258
286
 
259
287
  // Base returns the last element of path.
@@ -261,30 +289,30 @@ export function Ext(path: string): string {
261
289
  // If the path is empty, Base returns ".".
262
290
  // If the path consists entirely of slashes, Base returns "/".
263
291
  export function Base(path: string): string {
264
- if (path == "") {
265
- return "."
266
- }
267
- // Strip trailing slashes.
268
- for (; $.len(path) > 0 && $.indexString(path, $.len(path) - 1) == 47; ) {
269
- path = $.sliceString(path, 0, $.len(path) - 1)
270
- }
271
- // Find the last element
272
- {
273
- let i = path.lastIndexOf("/")
274
- if (i >= 0) {
275
- path = $.sliceString(path, i + 1, undefined)
276
- }
277
- }
278
- // If empty now, it had only slashes.
279
- if (path == "") {
280
- return "/"
281
- }
282
- return path
292
+ if (path == '') {
293
+ return '.'
294
+ }
295
+ // Strip trailing slashes.
296
+ for (; $.len(path) > 0 && $.indexString(path, $.len(path) - 1) == 47; ) {
297
+ path = $.sliceString(path, 0, $.len(path) - 1)
298
+ }
299
+ // Find the last element
300
+ {
301
+ let i = path.lastIndexOf('/')
302
+ if (i >= 0) {
303
+ path = $.sliceString(path, i + 1, undefined)
304
+ }
305
+ }
306
+ // If empty now, it had only slashes.
307
+ if (path == '') {
308
+ return '/'
309
+ }
310
+ return path
283
311
  }
284
312
 
285
313
  // IsAbs reports whether the path is absolute.
286
314
  export function IsAbs(path: string): boolean {
287
- return $.len(path) > 0 && $.indexString(path, 0) == 47
315
+ return $.len(path) > 0 && $.indexString(path, 0) == 47
288
316
  }
289
317
 
290
318
  // Dir returns all but the last element of path, typically the path's directory.
@@ -295,7 +323,6 @@ export function IsAbs(path: string): boolean {
295
323
  // returns a single slash. In any other case, the returned path does not end in a
296
324
  // slash.
297
325
  export function Dir(path: string): string {
298
- let [dir, ] = Split(path)
299
- return Clean(dir)
326
+ let [dir] = Split(path)
327
+ return Clean(dir)
300
328
  }
301
-
@@ -11,7 +11,7 @@ export function Version(): string {
11
11
  // GOMAXPROCS sets the maximum number of operating system threads
12
12
  //
13
13
  // JavaScript is single threaded so this always returns 1.
14
- export function GOMAXPROCS(n: number): number {
14
+ export function GOMAXPROCS(_n: number): number {
15
15
  // In a full implementation, we would set the max procs
16
16
  // Since JavaScript only supports 1, just return 1.
17
17
  return 1
@@ -69,7 +69,7 @@ export function _decrementGoroutineCount(): void {
69
69
 
70
70
  // Caller returns details about the calling goroutine's stack.
71
71
  // This is a simplified version for goscript
72
- export function Caller(skip: number): [number, string, number, boolean] {
72
+ export function Caller(_skip: number): [number, string, number, boolean] {
73
73
  // In JavaScript, we can use Error stack trace, but it's limited
74
74
  // Return dummy values for goscript compatibility
75
75
  const pc = 0 // program counter (not meaningful in JS)
@@ -159,8 +159,8 @@ export class PanicError implements Error {
159
159
  // SetFinalizer sets the finalizer associated with obj to the provided finalizer function.
160
160
  // In goscript/TypeScript environment, finalizers are not supported, so this throws an error.
161
161
  export function SetFinalizer(
162
- obj: object,
163
- finalizer: ((obj: object) => void) | null,
162
+ _obj: object,
163
+ _finalizer: ((obj: object) => void) | null,
164
164
  ): void {
165
165
  throw new Error(
166
166
  'runtime.SetFinalizer is not supported in goscript TypeScript environment',
@@ -1,5 +1,4 @@
1
1
  import { describe, it, expect } from 'vitest'
2
- import * as $ from '@goscript/builtin/builtin.js'
3
2
  import { Builder } from './builder.js'
4
3
 
5
4
  describe('strings/Builder', () => {
@@ -4,7 +4,7 @@ export class Builder {
4
4
  private _content: string = ''
5
5
  private _addr: Builder | null = null
6
6
 
7
- constructor(init?: Partial<{}>) {
7
+ constructor(_init?: Partial<{}>) {
8
8
  // Simple constructor - no complex initialization needed
9
9
  }
10
10
 
@@ -1,5 +1,3 @@
1
- import * as $ from '@goscript/builtin/builtin.js'
2
-
3
1
  // Clone returns a fresh copy of s.
4
2
  // It guarantees to make a copy of s into a new allocation,
5
3
  // which can be important when retaining only a small substring
@@ -1,5 +1,3 @@
1
- import * as $ from '@goscript/builtin/builtin.js'
2
-
3
1
  // Compare returns an integer comparing two strings lexicographically.
4
2
  // The result will be 0 if a == b, -1 if a < b, and +1 if a > b.
5
3
  //
@@ -1,5 +1,4 @@
1
1
  import { describe, it, expect } from 'vitest'
2
- import * as $ from '@goscript/builtin/builtin.js'
3
2
  import {
4
3
  Lines,
5
4
  SplitSeq,
@@ -1,7 +1,6 @@
1
1
  import { describe, it, expect } from 'vitest'
2
- import * as $ from '@goscript/builtin/builtin.js'
3
- import { Replacer, NewReplacer } from './replace.js'
4
- import * as io from '@goscript/io/index.js'
2
+ import { NewReplacer } from './replace.js'
3
+ import * as io from '../io/index.js'
5
4
 
6
5
  describe('strings/Replacer', () => {
7
6
  describe('NewReplacer', () => {
@@ -99,7 +98,7 @@ describe('strings/Replacer', () => {
99
98
  const r = NewReplacer('hello', 'hi')
100
99
  if (r) {
101
100
  const errorWriter: io.Writer = {
102
- Write: (p: Uint8Array) => {
101
+ Write: (_p: Uint8Array) => {
103
102
  return [0, new Error('write error')]
104
103
  },
105
104
  }
@@ -761,8 +761,6 @@ export function makeGenericReplacer(
761
761
  return r
762
762
  }
763
763
 
764
- type appendSliceWriter = Uint8Array
765
-
766
764
  class stringWriter {
767
765
  public get w(): io.Writer {
768
766
  return this._fields.w.value
@@ -777,7 +775,7 @@ class stringWriter {
777
775
 
778
776
  constructor(init?: Partial<{ w?: io.Writer }>) {
779
777
  this._fields = {
780
- w: $.varRef(init?.w!),
778
+ w: $.varRef(init!.w!),
781
779
  }
782
780
  }
783
781
 
@@ -982,8 +980,6 @@ export function makeSingleStringReplacer(
982
980
  })
983
981
  }
984
982
 
985
- type byteReplacer = number[]
986
-
987
983
  class byteStringReplacer {
988
984
  // replacements contains replacement byte slices indexed by old byte.
989
985
  // A nil []byte means that the old byte should not be replaced.
@@ -1240,6 +1236,9 @@ class byteStringReplacer {
1240
1236
  if (last != $.len(s)) {
1241
1237
  let [nw, err] = sw!.WriteString($.sliceString(s, last, undefined))
1242
1238
  n += nw
1239
+ if (err != null) {
1240
+ return [n, err]
1241
+ }
1243
1242
  }
1244
1243
  return [n, err]
1245
1244
  }
@@ -1298,8 +1297,6 @@ class byteStringReplacer {
1298
1297
  )
1299
1298
  }
1300
1299
 
1301
- let countCutOff: number = 8
1302
-
1303
1300
  // Helper function to copy bytes
1304
1301
  function copy(dst: Uint8Array, src: Uint8Array): number {
1305
1302
  const n = Math.min(dst.length, src.length)