goscript 0.0.39 → 0.0.41
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.
- package/compiler/analysis.go +15 -6
- package/compiler/compiler.go +185 -35
- package/compiler/expr-call.go +7 -9
- package/compiler/expr-type.go +25 -0
- package/compiler/field.go +21 -7
- package/compiler/gs_dependencies_test.go +80 -0
- package/compiler/lit.go +1 -6
- package/compiler/output.go +10 -4
- package/compiler/spec.go +16 -3
- package/compiler/type-assert.go +111 -21
- package/compiler/type.go +56 -12
- package/dist/gs/builtin/builtin.d.ts +20 -8
- package/dist/gs/builtin/builtin.js +30 -53
- package/dist/gs/builtin/builtin.js.map +1 -1
- package/dist/gs/builtin/errors.d.ts +8 -0
- package/dist/gs/builtin/errors.js +18 -0
- package/dist/gs/builtin/errors.js.map +1 -0
- package/dist/gs/builtin/index.d.ts +7 -0
- package/dist/gs/builtin/index.js +7 -0
- package/dist/gs/builtin/index.js.map +1 -1
- package/dist/gs/builtin/slice.d.ts +5 -2
- package/dist/gs/builtin/slice.js +123 -77
- package/dist/gs/builtin/slice.js.map +1 -1
- package/dist/gs/bytes/buffer.gs.d.ts +1 -1
- package/dist/gs/bytes/buffer.gs.js +1 -1
- package/dist/gs/bytes/buffer.gs.js.map +1 -1
- package/dist/gs/bytes/bytes.gs.d.ts +1 -1
- package/dist/gs/bytes/bytes.gs.js +111 -15
- package/dist/gs/bytes/bytes.gs.js.map +1 -1
- package/dist/gs/bytes/iter.gs.d.ts +1 -1
- package/dist/gs/bytes/iter.gs.js +1 -1
- package/dist/gs/bytes/iter.gs.js.map +1 -1
- package/dist/gs/bytes/reader.gs.d.ts +1 -1
- package/dist/gs/bytes/reader.gs.js +1 -1
- package/dist/gs/bytes/reader.gs.js.map +1 -1
- package/dist/gs/context/context.d.ts +1 -1
- package/dist/gs/context/context.js +1 -1
- package/dist/gs/context/context.js.map +1 -1
- package/dist/gs/errors/errors.d.ts +1 -1
- package/dist/gs/errors/errors.js +3 -15
- package/dist/gs/errors/errors.js.map +1 -1
- package/dist/gs/fmt/fmt.d.ts +49 -0
- package/dist/gs/fmt/fmt.js +322 -0
- package/dist/gs/fmt/fmt.js.map +1 -0
- package/dist/gs/fmt/index.d.ts +1 -0
- package/dist/gs/fmt/index.js +2 -0
- package/dist/gs/fmt/index.js.map +1 -0
- package/dist/gs/github.com/pkg/errors/errors.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/errors.js +1 -1
- package/dist/gs/github.com/pkg/errors/errors.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/go113.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/go113.js +1 -1
- package/dist/gs/github.com/pkg/errors/go113.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/stack.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/stack.js +1 -1
- package/dist/gs/github.com/pkg/errors/stack.js.map +1 -1
- package/dist/gs/internal/byteorder/index.d.ts +1 -1
- package/dist/gs/internal/byteorder/index.js +1 -1
- package/dist/gs/internal/byteorder/index.js.map +1 -1
- package/dist/gs/internal/oserror/errors.d.ts +1 -1
- package/dist/gs/io/fs/format.js +1 -1
- package/dist/gs/io/fs/format.js.map +1 -1
- package/dist/gs/io/fs/fs.d.ts +1 -1
- package/dist/gs/io/fs/fs.js +1 -1
- package/dist/gs/io/fs/fs.js.map +1 -1
- package/dist/gs/io/fs/glob.d.ts +1 -1
- package/dist/gs/io/fs/glob.js +1 -1
- package/dist/gs/io/fs/glob.js.map +1 -1
- package/dist/gs/io/fs/readdir.d.ts +1 -1
- package/dist/gs/io/fs/readdir.js +1 -1
- package/dist/gs/io/fs/readdir.js.map +1 -1
- package/dist/gs/io/fs/readfile.d.ts +1 -1
- package/dist/gs/io/fs/readfile.js +1 -1
- package/dist/gs/io/fs/readfile.js.map +1 -1
- package/dist/gs/io/fs/stat.d.ts +1 -1
- package/dist/gs/io/fs/stat.js +1 -1
- package/dist/gs/io/fs/stat.js.map +1 -1
- package/dist/gs/io/fs/sub.d.ts +1 -1
- package/dist/gs/io/fs/sub.js +1 -1
- package/dist/gs/io/fs/sub.js.map +1 -1
- package/dist/gs/io/fs/walk.d.ts +1 -1
- package/dist/gs/io/fs/walk.js +1 -1
- package/dist/gs/io/fs/walk.js.map +1 -1
- package/dist/gs/io/io.d.ts +1 -1
- package/dist/gs/maps/iter.d.ts +1 -1
- package/dist/gs/maps/iter.js +1 -1
- package/dist/gs/maps/iter.js.map +1 -1
- package/dist/gs/maps/maps.d.ts +1 -1
- package/dist/gs/maps/maps.js +1 -1
- package/dist/gs/maps/maps.js.map +1 -1
- package/dist/gs/math/erfinv.gs.js +1 -1
- package/dist/gs/math/erfinv.gs.js.map +1 -1
- package/dist/gs/math/gamma.gs.js +1 -1
- package/dist/gs/math/gamma.gs.js.map +1 -1
- package/dist/gs/math/j0.gs.js +1 -1
- package/dist/gs/math/j0.gs.js.map +1 -1
- package/dist/gs/math/j1.gs.js +1 -1
- package/dist/gs/math/j1.gs.js.map +1 -1
- package/dist/gs/math/lgamma.gs.js +1 -1
- package/dist/gs/math/lgamma.gs.js.map +1 -1
- package/dist/gs/math/pow10.gs.js +1 -1
- package/dist/gs/math/pow10.gs.js.map +1 -1
- package/dist/gs/math/sin.gs.js +1 -1
- package/dist/gs/math/sin.gs.js.map +1 -1
- package/dist/gs/math/tan.gs.js +1 -1
- package/dist/gs/math/tan.gs.js.map +1 -1
- package/dist/gs/math/tanh.gs.js +1 -1
- package/dist/gs/math/tanh.gs.js.map +1 -1
- package/dist/gs/math/trig_reduce.gs.js +1 -1
- package/dist/gs/math/trig_reduce.gs.js.map +1 -1
- package/dist/gs/os/dir.gs.d.ts +1 -1
- package/dist/gs/os/dir_unix.gs.d.ts +1 -1
- package/dist/gs/os/dir_unix.gs.js +1 -1
- package/dist/gs/os/dir_unix.gs.js.map +1 -1
- package/dist/gs/os/dirent_js.gs.d.ts +1 -1
- package/dist/gs/os/env.gs.d.ts +1 -1
- package/dist/gs/os/env.gs.js +1 -1
- package/dist/gs/os/env.gs.js.map +1 -1
- package/dist/gs/os/error.gs.d.ts +1 -1
- package/dist/gs/os/error.gs.js +1 -1
- package/dist/gs/os/error.gs.js.map +1 -1
- package/dist/gs/os/exec.gs.d.ts +1 -1
- package/dist/gs/os/exec.gs.js +1 -1
- package/dist/gs/os/exec.gs.js.map +1 -1
- package/dist/gs/os/exec_posix.gs.d.ts +1 -1
- package/dist/gs/os/exec_posix.gs.js +1 -1
- package/dist/gs/os/exec_posix.gs.js.map +1 -1
- package/dist/gs/os/exec_unix.gs.d.ts +1 -1
- package/dist/gs/os/executable.gs.d.ts +1 -1
- package/dist/gs/os/executable_js.gs.d.ts +1 -1
- package/dist/gs/os/executable_wasm.gs.d.ts +1 -1
- package/dist/gs/os/file_constants_js.gs.d.ts +1 -1
- package/dist/gs/os/file_constants_js.gs.js +1 -1
- package/dist/gs/os/file_constants_js.gs.js.map +1 -1
- package/dist/gs/os/file_js.gs.d.ts +1 -1
- package/dist/gs/os/file_open_unix.gs.d.ts +1 -1
- package/dist/gs/os/file_posix_js.gs.d.ts +1 -1
- package/dist/gs/os/file_unix_js.gs.d.ts +1 -1
- package/dist/gs/os/getwd_js.gs.d.ts +1 -1
- package/dist/gs/os/path.gs.d.ts +1 -1
- package/dist/gs/os/path.gs.js +1 -1
- package/dist/gs/os/path.gs.js.map +1 -1
- package/dist/gs/os/path_unix.gs.js +1 -1
- package/dist/gs/os/path_unix.gs.js.map +1 -1
- package/dist/gs/os/pidfd_js.gs.d.ts +1 -1
- package/dist/gs/os/pipe_wasm.gs.d.ts +1 -1
- package/dist/gs/os/proc.gs.d.ts +1 -1
- package/dist/gs/os/proc.gs.js +1 -1
- package/dist/gs/os/proc.gs.js.map +1 -1
- package/dist/gs/os/proc_js.gs.d.ts +1 -1
- package/dist/gs/os/proc_js.gs.js +1 -1
- package/dist/gs/os/proc_js.gs.js.map +1 -1
- package/dist/gs/os/rawconn_js.gs.d.ts +1 -1
- package/dist/gs/os/removeall_js.gs.d.ts +1 -1
- package/dist/gs/os/root_js.gs.d.ts +1 -1
- package/dist/gs/os/root_js.gs.js +1 -1
- package/dist/gs/os/root_js.gs.js.map +1 -1
- package/dist/gs/os/root_nonwindows.gs.d.ts +1 -1
- package/dist/gs/os/root_noopenat.gs.d.ts +1 -1
- package/dist/gs/os/stat.gs.d.ts +1 -1
- package/dist/gs/os/stat_js.gs.d.ts +1 -1
- package/dist/gs/os/stat_unix_js.gs.d.ts +1 -1
- package/dist/gs/os/sys.gs.d.ts +1 -1
- package/dist/gs/os/sys_bsd.gs.d.ts +1 -1
- package/dist/gs/os/sys_js.gs.d.ts +1 -1
- package/dist/gs/os/tempfile.gs.d.ts +1 -1
- package/dist/gs/os/types.gs.d.ts +1 -1
- package/dist/gs/os/types.gs.js +1 -1
- package/dist/gs/os/types.gs.js.map +1 -1
- package/dist/gs/os/types_js.gs.d.ts +1 -1
- package/dist/gs/os/types_js.gs.js +1 -1
- package/dist/gs/os/types_js.gs.js.map +1 -1
- package/dist/gs/os/types_unix.gs.d.ts +1 -1
- package/dist/gs/os/types_unix.gs.js +1 -1
- package/dist/gs/os/types_unix.gs.js.map +1 -1
- package/dist/gs/os/zero_copy_posix.gs.d.ts +1 -1
- package/dist/gs/os/zero_copy_posix.gs.js +1 -1
- package/dist/gs/os/zero_copy_posix.gs.js.map +1 -1
- package/dist/gs/path/filepath/index.d.ts +3 -0
- package/dist/gs/path/filepath/index.js +3 -0
- package/dist/gs/path/filepath/index.js.map +1 -0
- package/dist/gs/path/filepath/match.d.ts +3 -0
- package/dist/gs/path/filepath/match.js +212 -0
- package/dist/gs/path/filepath/match.js.map +1 -0
- package/dist/gs/path/filepath/path.d.ts +26 -0
- package/dist/gs/path/filepath/path.js +266 -0
- package/dist/gs/path/filepath/path.js.map +1 -0
- package/dist/gs/path/match.d.ts +1 -1
- package/dist/gs/path/match.js +1 -1
- package/dist/gs/path/match.js.map +1 -1
- package/dist/gs/path/path.js +1 -1
- package/dist/gs/path/path.js.map +1 -1
- package/dist/gs/reflect/value.d.ts +1 -1
- package/dist/gs/reflect/value.js +14 -6
- package/dist/gs/reflect/value.js.map +1 -1
- package/dist/gs/reflect/visiblefields.d.ts +1 -1
- package/dist/gs/reflect/visiblefields.js +1 -1
- package/dist/gs/reflect/visiblefields.js.map +1 -1
- package/dist/gs/slices/slices.d.ts +1 -1
- package/dist/gs/slices/slices.js +1 -1
- package/dist/gs/slices/slices.js.map +1 -1
- package/dist/gs/sort/index.d.ts +4 -0
- package/dist/gs/sort/index.js +4 -0
- package/dist/gs/sort/index.js.map +1 -0
- package/dist/gs/sort/search.gs.d.ts +6 -0
- package/dist/gs/sort/search.gs.js +125 -0
- package/dist/gs/sort/search.gs.js.map +1 -0
- package/dist/gs/sort/slice.gs.d.ts +4 -0
- package/dist/gs/sort/slice.gs.js +49 -0
- package/dist/gs/sort/slice.gs.js.map +1 -0
- package/dist/gs/sort/sort.gs.d.ts +37 -0
- package/dist/gs/sort/sort.gs.js +203 -0
- package/dist/gs/sort/sort.gs.js.map +1 -0
- package/dist/gs/strconv/atob.gs.d.ts +1 -1
- package/dist/gs/strconv/atob.gs.js +1 -1
- package/dist/gs/strconv/atob.gs.js.map +1 -1
- package/dist/gs/strconv/atof.gs.d.ts +1 -1
- package/dist/gs/strconv/atoi.gs.d.ts +1 -1
- package/dist/gs/strconv/atoi.gs.js +5 -6
- package/dist/gs/strconv/atoi.gs.js.map +1 -1
- package/dist/gs/strconv/ftoa.gs.d.ts +1 -1
- package/dist/gs/strconv/ftoa.gs.js +1 -1
- package/dist/gs/strconv/ftoa.gs.js.map +1 -1
- package/dist/gs/strconv/itoa.gs.d.ts +1 -1
- package/dist/gs/strconv/itoa.gs.js +1 -1
- package/dist/gs/strconv/itoa.gs.js.map +1 -1
- package/dist/gs/strconv/quote.gs.d.ts +1 -1
- package/dist/gs/strconv/quote.gs.js +1 -1
- package/dist/gs/strconv/quote.gs.js.map +1 -1
- package/dist/gs/strings/builder.d.ts +1 -1
- package/dist/gs/strings/builder.js +1 -1
- package/dist/gs/strings/builder.js.map +1 -1
- package/dist/gs/strings/iter.js +1 -1
- package/dist/gs/strings/iter.js.map +1 -1
- package/dist/gs/strings/reader.d.ts +1 -1
- package/dist/gs/strings/reader.js +7 -8
- package/dist/gs/strings/reader.js.map +1 -1
- package/dist/gs/strings/replace.d.ts +1 -1
- package/dist/gs/strings/replace.js +1 -1
- package/dist/gs/strings/replace.js.map +1 -1
- package/dist/gs/strings/strings.d.ts +1 -1
- package/dist/gs/strings/strings.js +1 -1
- package/dist/gs/strings/strings.js.map +1 -1
- package/dist/gs/sync/atomic/doc.gs.d.ts +1 -1
- package/dist/gs/sync/atomic/doc_64.gs.d.ts +1 -1
- package/dist/gs/sync/atomic/type.gs.d.ts +1 -1
- package/dist/gs/sync/atomic/type.gs.js +1 -1
- package/dist/gs/sync/atomic/type.gs.js.map +1 -1
- package/dist/gs/sync/atomic/value.gs.d.ts +1 -1
- package/dist/gs/sync/atomic/value.gs.js +1 -1
- package/dist/gs/sync/atomic/value.gs.js.map +1 -1
- package/dist/gs/syscall/index.d.ts +1 -1
- package/dist/gs/syscall/index.js +1 -1
- package/dist/gs/syscall/index.js.map +1 -1
- package/dist/gs/unicode/utf8/utf8.d.ts +1 -1
- package/dist/gs/unicode/utf8/utf8.js +1 -1
- package/dist/gs/unicode/utf8/utf8.js.map +1 -1
- package/gs/builtin/builtin.ts +33 -64
- package/gs/builtin/errors.ts +25 -0
- package/gs/builtin/index.ts +7 -0
- package/gs/builtin/slice.ts +142 -71
- package/gs/bytes/buffer.gs.ts +1 -1
- package/gs/bytes/bytes.gs.ts +123 -15
- package/gs/bytes/iter.gs.ts +1 -1
- package/gs/bytes/metadata.go +12 -0
- package/gs/bytes/reader.gs.ts +1 -1
- package/gs/context/context.ts +1 -1
- package/gs/errors/errors.ts +3 -16
- package/gs/fmt/fmt.ts +407 -0
- package/gs/fmt/godoc.txt +382 -0
- package/gs/fmt/index.ts +31 -0
- package/gs/fmt/metadata.go +7 -0
- package/gs/github.com/pkg/errors/errors.ts +1 -1
- package/gs/github.com/pkg/errors/go113.ts +2 -2
- package/gs/github.com/pkg/errors/stack.ts +1 -1
- package/gs/internal/byteorder/index.ts +1 -1
- package/gs/internal/metadata.go +7 -0
- package/gs/internal/oserror/errors.ts +1 -1
- package/gs/io/fs/format.ts +1 -1
- package/gs/io/fs/fs.ts +1 -1
- package/gs/io/fs/glob.ts +1 -1
- package/gs/io/fs/readdir.ts +1 -1
- package/gs/io/fs/readfile.ts +1 -1
- package/gs/io/fs/stat.ts +1 -1
- package/gs/io/fs/sub.ts +1 -1
- package/gs/io/fs/walk.ts +1 -1
- package/gs/io/io.ts +1 -1
- package/gs/io/metadata.go +11 -0
- package/gs/maps/iter.ts +1 -1
- package/gs/maps/maps.ts +1 -1
- package/gs/maps/metadata.go +8 -0
- package/gs/math/abs.gs.ts +1 -1
- package/gs/math/acosh.gs.ts +1 -1
- package/gs/math/asinh.gs.ts +1 -1
- package/gs/math/atan.gs.ts +1 -1
- package/gs/math/atan2.gs.ts +1 -1
- package/gs/math/atanh.gs.ts +1 -1
- package/gs/math/bits.gs.ts +1 -1
- package/gs/math/cbrt.gs.ts +1 -1
- package/gs/math/const.gs.ts +1 -1
- package/gs/math/copysign.gs.ts +1 -1
- package/gs/math/dim.gs.ts +1 -1
- package/gs/math/erf.gs.ts +1 -1
- package/gs/math/erfinv.gs.ts +1 -1
- package/gs/math/exp.gs.ts +1 -1
- package/gs/math/expm1.gs.ts +1 -1
- package/gs/math/floor.gs.ts +1 -1
- package/gs/math/frexp.gs.ts +1 -1
- package/gs/math/gamma.gs.ts +1 -1
- package/gs/math/hypot.gs.ts +1 -1
- package/gs/math/j0.gs.ts +1 -1
- package/gs/math/j1.gs.ts +1 -1
- package/gs/math/jn.gs.ts +1 -1
- package/gs/math/ldexp.gs.ts +1 -1
- package/gs/math/lgamma.gs.ts +1 -1
- package/gs/math/log.gs.ts +1 -1
- package/gs/math/log10.gs.ts +1 -1
- package/gs/math/log1p.gs.ts +1 -1
- package/gs/math/logb.gs.ts +1 -1
- package/gs/math/metadata.go +7 -0
- package/gs/math/mod.gs.ts +1 -1
- package/gs/math/modf.gs.ts +1 -1
- package/gs/math/nextafter.gs.ts +1 -1
- package/gs/math/pow.gs.ts +1 -1
- package/gs/math/pow10.gs.ts +1 -1
- package/gs/math/remainder.gs.ts +1 -1
- package/gs/math/signbit.gs.ts +1 -1
- package/gs/math/sin.gs.ts +1 -1
- package/gs/math/sincos.gs.ts +1 -1
- package/gs/math/sinh.gs.ts +1 -1
- package/gs/math/sqrt.gs.ts +1 -1
- package/gs/math/tan.gs.ts +1 -1
- package/gs/math/tanh.gs.ts +1 -1
- package/gs/math/trig_reduce.gs.ts +1 -1
- package/gs/math/unsafe.gs.ts +1 -1
- package/gs/os/dir.gs.ts +1 -1
- package/gs/os/dir_unix.gs.ts +1 -1
- package/gs/os/dirent_js.gs.ts +1 -1
- package/gs/os/env.gs.ts +1 -1
- package/gs/os/error.gs.ts +1 -1
- package/gs/os/error_errno.gs.ts +1 -1
- package/gs/os/exec.gs.ts +1 -1
- package/gs/os/exec_nohandle.gs.ts +1 -1
- package/gs/os/exec_posix.gs.ts +1 -1
- package/gs/os/exec_unix.gs.ts +1 -1
- package/gs/os/executable.gs.ts +1 -1
- package/gs/os/executable_js.gs.ts +1 -1
- package/gs/os/executable_wasm.gs.ts +1 -1
- package/gs/os/file_constants_js.gs.ts +1 -1
- package/gs/os/file_js.gs.ts +1 -1
- package/gs/os/file_open_unix.gs.ts +1 -1
- package/gs/os/file_posix_js.gs.ts +1 -1
- package/gs/os/file_unix_js.gs.ts +1 -1
- package/gs/os/getwd_js.gs.ts +1 -1
- package/gs/os/metadata.go +17 -0
- package/gs/os/path.gs.ts +1 -1
- package/gs/os/path_unix.gs.ts +1 -1
- package/gs/os/pidfd_js.gs.ts +1 -1
- package/gs/os/pipe_wasm.gs.ts +1 -1
- package/gs/os/proc.gs.ts +1 -1
- package/gs/os/proc_js.gs.ts +1 -1
- package/gs/os/rawconn_js.gs.ts +1 -1
- package/gs/os/removeall_js.gs.ts +1 -1
- package/gs/os/root_js.gs.ts +1 -1
- package/gs/os/root_nonwindows.gs.ts +1 -1
- package/gs/os/root_noopenat.gs.ts +1 -1
- package/gs/os/stat.gs.ts +1 -1
- package/gs/os/stat_js.gs.ts +1 -1
- package/gs/os/stat_unix_js.gs.ts +1 -1
- package/gs/os/sticky_bsd.gs.ts +1 -1
- package/gs/os/sys.gs.ts +1 -1
- package/gs/os/sys_bsd.gs.ts +1 -1
- package/gs/os/sys_js.gs.ts +1 -1
- package/gs/os/tempfile.gs.ts +1 -1
- package/gs/os/types.gs.ts +1 -1
- package/gs/os/types_js.gs.ts +1 -1
- package/gs/os/types_unix.gs.ts +1 -1
- package/gs/os/wait_unimp.gs.ts +1 -1
- package/gs/os/zero_copy_posix.gs.ts +1 -1
- package/gs/os/zero_copy_stub.gs.ts +1 -1
- package/gs/path/filepath/godoc.txt +35 -0
- package/gs/path/filepath/index.ts +27 -0
- package/gs/path/filepath/match.test.ts +274 -0
- package/gs/path/filepath/match.ts +249 -0
- package/gs/path/filepath/path.test.ts +246 -0
- package/gs/path/filepath/path.ts +329 -0
- package/gs/path/match.ts +1 -1
- package/gs/path/metadata.go +8 -0
- package/gs/path/path.ts +1 -1
- package/gs/reflect/metadata.go +7 -0
- package/gs/reflect/value.ts +14 -6
- package/gs/reflect/visiblefields.ts +1 -1
- package/gs/slices/slices.ts +1 -1
- package/gs/sort/godoc.txt +27 -0
- package/gs/sort/index.ts +24 -0
- package/gs/sort/search.gs.ts +128 -0
- package/gs/sort/slice.gs.ts +59 -0
- package/gs/sort/sort.gs.ts +227 -0
- package/gs/strconv/atob.gs.ts +1 -1
- package/gs/strconv/atof.gs.ts +1 -1
- package/gs/strconv/atoi.gs.ts +5 -6
- package/gs/strconv/doc.gs.ts +1 -1
- package/gs/strconv/ftoa.gs.ts +1 -1
- package/gs/strconv/itoa.gs.ts +1 -1
- package/gs/strconv/metadata.go +7 -0
- package/gs/strconv/quote.gs.ts +1 -1
- package/gs/strings/builder.ts +1 -1
- package/gs/strings/iter.ts +1 -1
- package/gs/strings/metadata.go +11 -0
- package/gs/strings/reader.ts +7 -9
- package/gs/strings/replace.ts +1 -1
- package/gs/strings/strings.ts +1 -1
- package/gs/sync/atomic/doc.gs.ts +1 -1
- package/gs/sync/atomic/doc_64.gs.ts +1 -1
- package/gs/sync/atomic/type.gs.ts +1 -1
- package/gs/sync/atomic/value.gs.ts +1 -1
- package/gs/sync/metadata.go +7 -0
- package/gs/syscall/index.ts +1 -1
- package/gs/unicode/utf8/utf8.ts +1 -1
- package/package.json +3 -3
- package/gs/builtin/io.ts +0 -22
package/gs/builtin/slice.ts
CHANGED
|
@@ -192,6 +192,11 @@ export const makeSlice = <T>(
|
|
|
192
192
|
// The rest of backingArr (from length to actualCapacity-1) remains uninitialized (undefined),
|
|
193
193
|
// representing available capacity.
|
|
194
194
|
|
|
195
|
+
// OPTIMIZATION: If length equals capacity, return backing array directly
|
|
196
|
+
if (length === actualCapacity) {
|
|
197
|
+
return backingArr as Slice<T>
|
|
198
|
+
}
|
|
199
|
+
|
|
195
200
|
// The proxyTargetArray serves as the shell for the proxy.
|
|
196
201
|
// Its elements up to 'length' should reflect the initialized part of the slice.
|
|
197
202
|
const proxyTargetArray = new Array<T>(length)
|
|
@@ -252,7 +257,7 @@ export const makeSlice = <T>(
|
|
|
252
257
|
},
|
|
253
258
|
}
|
|
254
259
|
|
|
255
|
-
return new Proxy(proxy, handler) as
|
|
260
|
+
return new Proxy(proxy, handler) as unknown as SliceProxy<T>
|
|
256
261
|
}
|
|
257
262
|
|
|
258
263
|
/**
|
|
@@ -454,6 +459,11 @@ export const goSlice = <T>( // T can be number for Uint8Array case
|
|
|
454
459
|
const newLength = high - low
|
|
455
460
|
const newOffset = oldOffset + low
|
|
456
461
|
|
|
462
|
+
// OPTIMIZATION: If the result would have offset=0 and length=capacity, return backing directly
|
|
463
|
+
if (newOffset === 0 && newLength === newCap) {
|
|
464
|
+
return backing as Slice<T>
|
|
465
|
+
}
|
|
466
|
+
|
|
457
467
|
// Create an array-like target with the correct length
|
|
458
468
|
const proxyTargetArray = new Array<T>(newLength)
|
|
459
469
|
// Note: We don't need to initialize the values here since the proxy handler
|
|
@@ -487,6 +497,12 @@ export const arrayToSlice = <T>(
|
|
|
487
497
|
|
|
488
498
|
if (arr.length === 0) return arr
|
|
489
499
|
|
|
500
|
+
// OPTIMIZATION: For arrays where offset=0 and length=capacity, return the array directly
|
|
501
|
+
// if we're not doing deep conversion
|
|
502
|
+
if (depth === 1) {
|
|
503
|
+
return arr as Slice<T>
|
|
504
|
+
}
|
|
505
|
+
|
|
490
506
|
const target = {
|
|
491
507
|
__meta__: {
|
|
492
508
|
backing: arr,
|
|
@@ -800,97 +816,152 @@ export function append<T>(
|
|
|
800
816
|
/**
|
|
801
817
|
* Copies elements from src to dst.
|
|
802
818
|
* @param dst The destination slice.
|
|
803
|
-
* @param src The source slice.
|
|
819
|
+
* @param src The source slice or string.
|
|
804
820
|
* @returns The number of elements copied.
|
|
805
821
|
*/
|
|
806
|
-
export
|
|
807
|
-
|
|
822
|
+
export function copy(dst: Uint8Array, src: Uint8Array | string): number
|
|
823
|
+
export function copy(dst: Uint8Array, src: Slice<number>): number
|
|
824
|
+
export function copy<T>(dst: Slice<T>, src: Slice<T>): number
|
|
825
|
+
export function copy<T>(dst: Slice<T>, src: string): number
|
|
826
|
+
export function copy<T>(dst: Slice<T> | Uint8Array, src: Slice<T> | Uint8Array | string): number {
|
|
827
|
+
if (dst === null) {
|
|
828
|
+
return 0
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
// Handle string source first
|
|
832
|
+
if (typeof src === 'string') {
|
|
833
|
+
return copyFromString(dst, src)
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
if (src === null) {
|
|
808
837
|
return 0
|
|
809
838
|
}
|
|
810
839
|
|
|
811
|
-
|
|
812
|
-
const
|
|
840
|
+
// Now we know src is Slice<T> | Uint8Array
|
|
841
|
+
const dstLen = dst instanceof Uint8Array ? dst.length : len(dst)
|
|
842
|
+
const srcLen = src instanceof Uint8Array ? src.length : len(src)
|
|
813
843
|
const count = Math.min(dstLen, srcLen)
|
|
814
844
|
|
|
815
845
|
if (count === 0) {
|
|
816
846
|
return 0
|
|
817
847
|
}
|
|
818
848
|
|
|
819
|
-
|
|
820
|
-
|
|
849
|
+
// Handle all combinations of dst and src types
|
|
850
|
+
if (dst instanceof Uint8Array && src instanceof Uint8Array) {
|
|
851
|
+
// Uint8Array to Uint8Array
|
|
852
|
+
dst.set(src.subarray(0, count))
|
|
853
|
+
return count
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
if (dst instanceof Uint8Array) {
|
|
857
|
+
// Uint8Array destination, Slice<number> source
|
|
858
|
+
return copyToUint8Array(dst, src as Slice<number>, count)
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
if (src instanceof Uint8Array) {
|
|
862
|
+
// Slice<T> destination, Uint8Array source
|
|
863
|
+
return copyFromUint8Array(dst as Slice<T>, src, count)
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// Both are Slice<T>
|
|
867
|
+
return copyBetweenSlices(dst as Slice<T>, src as Slice<T>, count)
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Helper: Copy from string to any destination type
|
|
872
|
+
*/
|
|
873
|
+
function copyFromString<T>(dst: Slice<T> | Uint8Array, src: string): number {
|
|
874
|
+
const encoder = new TextEncoder()
|
|
875
|
+
const srcBytes = encoder.encode(src)
|
|
876
|
+
const dstLen = dst instanceof Uint8Array ? dst.length : len(dst)
|
|
877
|
+
const count = Math.min(dstLen, srcBytes.length)
|
|
878
|
+
|
|
879
|
+
if (count === 0) {
|
|
880
|
+
return 0
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
if (dst instanceof Uint8Array) {
|
|
884
|
+
for (let i = 0; i < count; i++) {
|
|
885
|
+
dst[i] = srcBytes[i]
|
|
886
|
+
}
|
|
887
|
+
} else if (isComplexSlice(dst)) {
|
|
888
|
+
const dstMeta = dst.__meta__
|
|
889
|
+
for (let i = 0; i < count; i++) {
|
|
890
|
+
dstMeta.backing[dstMeta.offset + i] = srcBytes[i] as unknown as T
|
|
891
|
+
;(dst as any)[i] = srcBytes[i]
|
|
892
|
+
}
|
|
893
|
+
} else if (Array.isArray(dst)) {
|
|
894
|
+
for (let i = 0; i < count; i++) {
|
|
895
|
+
dst[i] = srcBytes[i] as unknown as T
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
return count
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Helper: Copy from Slice<number> to Uint8Array
|
|
904
|
+
*/
|
|
905
|
+
function copyToUint8Array(dst: Uint8Array, src: Slice<number>, count: number): number {
|
|
906
|
+
if (isComplexSlice(src)) {
|
|
907
|
+
const srcMeta = src.__meta__
|
|
908
|
+
for (let i = 0; i < count; i++) {
|
|
909
|
+
dst[i] = srcMeta.backing[srcMeta.offset + i]
|
|
910
|
+
}
|
|
911
|
+
} else if (Array.isArray(src)) {
|
|
912
|
+
for (let i = 0; i < count; i++) {
|
|
913
|
+
dst[i] = src[i]
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return count
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/**
|
|
920
|
+
* Helper: Copy from Uint8Array to Slice<T>
|
|
921
|
+
*/
|
|
922
|
+
function copyFromUint8Array<T>(dst: Slice<T>, src: Uint8Array, count: number): number {
|
|
923
|
+
if (isComplexSlice(dst)) {
|
|
924
|
+
const dstMeta = dst.__meta__
|
|
925
|
+
for (let i = 0; i < count; i++) {
|
|
926
|
+
dstMeta.backing[dstMeta.offset + i] = src[i] as unknown as T
|
|
927
|
+
;(dst as any)[i] = src[i]
|
|
928
|
+
}
|
|
929
|
+
} else if (Array.isArray(dst)) {
|
|
930
|
+
for (let i = 0; i < count; i++) {
|
|
931
|
+
dst[i] = src[i] as unknown as T
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return count
|
|
935
|
+
}
|
|
821
936
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
937
|
+
/**
|
|
938
|
+
* Helper: Copy between two Slice<T> instances
|
|
939
|
+
*/
|
|
940
|
+
function copyBetweenSlices<T>(dst: Slice<T>, src: Slice<T>, count: number): number {
|
|
941
|
+
if (isComplexSlice(dst)) {
|
|
942
|
+
const dstMeta = dst.__meta__
|
|
943
|
+
|
|
827
944
|
if (isComplexSlice(src)) {
|
|
828
|
-
const srcMeta =
|
|
945
|
+
const srcMeta = src.__meta__
|
|
829
946
|
for (let i = 0; i < count; i++) {
|
|
830
|
-
|
|
947
|
+
dstMeta.backing[dstMeta.offset + i] = srcMeta.backing[srcMeta.offset + i]
|
|
948
|
+
;(dst as any)[i] = srcMeta.backing[srcMeta.offset + i]
|
|
831
949
|
}
|
|
832
|
-
} else {
|
|
833
|
-
// src is number[]
|
|
834
|
-
const srcArray = src as number[]
|
|
950
|
+
} else if (Array.isArray(src)) {
|
|
835
951
|
for (let i = 0; i < count; i++) {
|
|
836
|
-
|
|
952
|
+
dstMeta.backing[dstMeta.offset + i] = src[i]
|
|
953
|
+
;(dst as any)[i] = src[i]
|
|
837
954
|
}
|
|
838
955
|
}
|
|
839
|
-
} else if (
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
if (isComplexSlice(dst)) {
|
|
843
|
-
const dstMeta = (dst as SliceProxy<number>).__meta__
|
|
844
|
-
const dstBacking = dstMeta.backing
|
|
845
|
-
const dstOffset = dstMeta.offset
|
|
956
|
+
} else if (Array.isArray(dst)) {
|
|
957
|
+
if (isComplexSlice(src)) {
|
|
958
|
+
const srcMeta = src.__meta__
|
|
846
959
|
for (let i = 0; i < count; i++) {
|
|
847
|
-
|
|
848
|
-
// Also update the proxy view if dst is a proxy
|
|
849
|
-
;(dst as any)[i] = srcUint8[i]
|
|
960
|
+
dst[i] = srcMeta.backing[srcMeta.offset + i]
|
|
850
961
|
}
|
|
851
|
-
} else {
|
|
852
|
-
// dst is number[]
|
|
853
|
-
const dstArray = dst as number[]
|
|
962
|
+
} else if (Array.isArray(src)) {
|
|
854
963
|
for (let i = 0; i < count; i++) {
|
|
855
|
-
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
} else {
|
|
859
|
-
// Both are Slice<T> or T[] (original logic)
|
|
860
|
-
if (isComplexSlice(dst)) {
|
|
861
|
-
const dstOffset = (dst as SliceProxy<T>).__meta__.offset
|
|
862
|
-
const dstBacking = (dst as SliceProxy<T>).__meta__.backing
|
|
863
|
-
|
|
864
|
-
if (isComplexSlice(src)) {
|
|
865
|
-
const srcOffset = (src as SliceProxy<T>).__meta__.offset
|
|
866
|
-
const srcBacking = (src as SliceProxy<T>).__meta__.backing
|
|
867
|
-
for (let i = 0; i < count; i++) {
|
|
868
|
-
dstBacking[dstOffset + i] = srcBacking[srcOffset + i]
|
|
869
|
-
;(dst as any)[i] = srcBacking[srcOffset + i] // Update proxy
|
|
870
|
-
}
|
|
871
|
-
} else {
|
|
872
|
-
// src is T[]
|
|
873
|
-
const srcArray = src as T[]
|
|
874
|
-
for (let i = 0; i < count; i++) {
|
|
875
|
-
dstBacking[dstOffset + i] = srcArray[i]
|
|
876
|
-
;(dst as any)[i] = srcArray[i] // Update proxy
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
} else {
|
|
880
|
-
// dst is T[]
|
|
881
|
-
const dstArray = dst as T[]
|
|
882
|
-
if (isComplexSlice(src)) {
|
|
883
|
-
const srcOffset = (src as SliceProxy<T>).__meta__.offset
|
|
884
|
-
const srcBacking = (src as SliceProxy<T>).__meta__.backing
|
|
885
|
-
for (let i = 0; i < count; i++) {
|
|
886
|
-
dstArray[i] = srcBacking[srcOffset + i]
|
|
887
|
-
}
|
|
888
|
-
} else {
|
|
889
|
-
// src is T[]
|
|
890
|
-
const srcArray = src as T[]
|
|
891
|
-
for (let i = 0; i < count; i++) {
|
|
892
|
-
dstArray[i] = srcArray[i]
|
|
893
|
-
}
|
|
964
|
+
dst[i] = src[i]
|
|
894
965
|
}
|
|
895
966
|
}
|
|
896
967
|
}
|
package/gs/bytes/buffer.gs.ts
CHANGED
package/gs/bytes/bytes.gs.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as $ from "@goscript/builtin/
|
|
1
|
+
import * as $ from "@goscript/builtin/index.js";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import * as unicode from "@goscript/unicode/index.js"
|
|
@@ -488,8 +488,36 @@ export function HasSuffix(s: $.Bytes, suffix: $.Bytes): boolean {
|
|
|
488
488
|
// dropped from the byte slice with no replacement. The characters in s and the
|
|
489
489
|
// output are interpreted as UTF-8-encoded code points.
|
|
490
490
|
export function Map(mapping: ((r: number) => number) | null, s: $.Bytes): $.Bytes {
|
|
491
|
-
|
|
492
|
-
|
|
491
|
+
if (s === null || $.len(s) === 0 || mapping === null) {
|
|
492
|
+
return s === null ? null : new Uint8Array(0)
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const result: number[] = []
|
|
496
|
+
|
|
497
|
+
for (let i = 0; i < $.len(s); ) {
|
|
498
|
+
const [r, size] = utf8.DecodeRune($.goSlice(s, i, undefined))
|
|
499
|
+
if (size <= 0) {
|
|
500
|
+
// Invalid UTF-8, copy the byte as-is
|
|
501
|
+
result.push(s![i])
|
|
502
|
+
i++
|
|
503
|
+
} else {
|
|
504
|
+
const mappedR = mapping(r)
|
|
505
|
+
if (mappedR >= 0) {
|
|
506
|
+
// Encode the mapped rune back to bytes
|
|
507
|
+
const runeBytes = new Uint8Array(utf8.UTFMax)
|
|
508
|
+
const n = utf8.EncodeRune(runeBytes, mappedR)
|
|
509
|
+
|
|
510
|
+
// Add the encoded bytes to result
|
|
511
|
+
for (let j = 0; j < n; j++) {
|
|
512
|
+
result.push(runeBytes[j])
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
i += size
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
return new Uint8Array(result)
|
|
493
521
|
}
|
|
494
522
|
|
|
495
523
|
// Repeat returns a new byte slice consisting of count copies of b.
|
|
@@ -607,29 +635,51 @@ export function ToTitle(s: $.Bytes): $.Bytes {
|
|
|
607
635
|
// ToUpperSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
|
|
608
636
|
// upper case, giving priority to the special casing rules.
|
|
609
637
|
export function ToUpperSpecial(c: unicode.SpecialCase, s: $.Bytes): $.Bytes {
|
|
610
|
-
//
|
|
611
|
-
|
|
638
|
+
// For now, ignore special case and fall back to regular ToUpper
|
|
639
|
+
return ToUpper(s)
|
|
612
640
|
}
|
|
613
641
|
|
|
614
642
|
// ToLowerSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
|
|
615
643
|
// lower case, giving priority to the special casing rules.
|
|
616
644
|
export function ToLowerSpecial(c: unicode.SpecialCase, s: $.Bytes): $.Bytes {
|
|
617
|
-
//
|
|
618
|
-
|
|
645
|
+
// For now, ignore special case and fall back to regular ToLower
|
|
646
|
+
return ToLower(s)
|
|
619
647
|
}
|
|
620
648
|
|
|
621
649
|
// ToTitleSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
|
|
622
650
|
// title case, giving priority to the special casing rules.
|
|
623
651
|
export function ToTitleSpecial(c: unicode.SpecialCase, s: $.Bytes): $.Bytes {
|
|
624
|
-
//
|
|
625
|
-
|
|
652
|
+
// For now, ignore special case and fall back to regular ToTitle
|
|
653
|
+
return ToTitle(s)
|
|
626
654
|
}
|
|
627
655
|
|
|
628
656
|
// ToValidUTF8 treats s as UTF-8-encoded bytes and returns a copy with each run of bytes
|
|
629
657
|
// representing invalid UTF-8 replaced with the bytes in replacement, which may be empty.
|
|
630
658
|
export function ToValidUTF8(s: $.Bytes, replacement: $.Bytes): $.Bytes {
|
|
631
|
-
|
|
632
|
-
|
|
659
|
+
if (s === null || $.len(s) === 0) {
|
|
660
|
+
return s === null ? null : new Uint8Array(0)
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
const result: number[] = []
|
|
664
|
+
const replacementArr = replacement ? $.bytesToArray(replacement) : []
|
|
665
|
+
|
|
666
|
+
for (let i = 0; i < $.len(s); ) {
|
|
667
|
+
const [r, size] = utf8.DecodeRune($.goSlice(s, i, undefined))
|
|
668
|
+
if (size <= 0 || r === utf8.RuneError) {
|
|
669
|
+
// Invalid UTF-8, replace with replacement bytes
|
|
670
|
+
for (const b of replacementArr) {
|
|
671
|
+
result.push(b)
|
|
672
|
+
}
|
|
673
|
+
i++
|
|
674
|
+
} else {
|
|
675
|
+
for (let j = 0; j < size; j++) {
|
|
676
|
+
result.push(s![i + j])
|
|
677
|
+
}
|
|
678
|
+
i += size
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return new Uint8Array(result)
|
|
633
683
|
}
|
|
634
684
|
|
|
635
685
|
// isSeparator reports whether the rune could mark a word boundary.
|
|
@@ -659,8 +709,41 @@ export function isSeparator(r: number): boolean {
|
|
|
659
709
|
// Deprecated: The rule Title uses for word boundaries does not handle Unicode
|
|
660
710
|
// punctuation properly. Use golang.org/x/text/cases instead.
|
|
661
711
|
export function Title(s: $.Bytes): $.Bytes {
|
|
662
|
-
|
|
663
|
-
|
|
712
|
+
if (s === null || $.len(s) === 0) {
|
|
713
|
+
return s === null ? null : new Uint8Array(0)
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
const result: number[] = []
|
|
717
|
+
let prevIsSep = true // Start of string counts as separator
|
|
718
|
+
|
|
719
|
+
for (let i = 0; i < $.len(s); ) {
|
|
720
|
+
const [r, size] = utf8.DecodeRune($.goSlice(s, i, undefined))
|
|
721
|
+
if (size <= 0) {
|
|
722
|
+
// Invalid UTF-8, copy the byte as-is
|
|
723
|
+
result.push(s![i])
|
|
724
|
+
i++
|
|
725
|
+
prevIsSep = true
|
|
726
|
+
} else {
|
|
727
|
+
let transformedR = r
|
|
728
|
+
if (prevIsSep && unicode.IsLetter(r)) {
|
|
729
|
+
transformedR = unicode.ToTitle(r)
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// Encode the (possibly transformed) rune back to bytes
|
|
733
|
+
const runeBytes = new Uint8Array(utf8.UTFMax)
|
|
734
|
+
const n = utf8.EncodeRune(runeBytes, transformedR)
|
|
735
|
+
|
|
736
|
+
// Add the encoded bytes to result
|
|
737
|
+
for (let j = 0; j < n; j++) {
|
|
738
|
+
result.push(runeBytes[j])
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
prevIsSep = isSeparator(r)
|
|
742
|
+
i += size
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
return new Uint8Array(result)
|
|
664
747
|
}
|
|
665
748
|
|
|
666
749
|
// TrimLeftFunc treats s as UTF-8-encoded bytes and returns a subslice of s by slicing off
|
|
@@ -1119,8 +1202,33 @@ export function ReplaceAll(s: $.Bytes, old: $.Bytes, _new: $.Bytes): $.Bytes {
|
|
|
1119
1202
|
// are equal under simple Unicode case-folding, which is a more general
|
|
1120
1203
|
// form of case-insensitivity.
|
|
1121
1204
|
export function EqualFold(s: $.Bytes, t: $.Bytes): boolean {
|
|
1122
|
-
|
|
1123
|
-
|
|
1205
|
+
if (s === null && t === null) return true
|
|
1206
|
+
if (s === null || t === null) return false
|
|
1207
|
+
|
|
1208
|
+
let si = 0, ti = 0
|
|
1209
|
+
|
|
1210
|
+
while (si < $.len(s) && ti < $.len(t)) {
|
|
1211
|
+
const [sr, ssize] = utf8.DecodeRune($.goSlice(s, si, undefined))
|
|
1212
|
+
const [tr, tsize] = utf8.DecodeRune($.goSlice(t, ti, undefined))
|
|
1213
|
+
|
|
1214
|
+
if (ssize <= 0 || tsize <= 0) {
|
|
1215
|
+
// Invalid UTF-8, fall back to byte comparison
|
|
1216
|
+
if (s![si] !== t![ti]) return false
|
|
1217
|
+
si++
|
|
1218
|
+
ti++
|
|
1219
|
+
} else {
|
|
1220
|
+
// Convert both to lowercase for comparison
|
|
1221
|
+
const sLower = unicode.ToLower(sr)
|
|
1222
|
+
const tLower = unicode.ToLower(tr)
|
|
1223
|
+
|
|
1224
|
+
if (sLower !== tLower) return false
|
|
1225
|
+
|
|
1226
|
+
si += ssize
|
|
1227
|
+
ti += tsize
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
return si === $.len(s) && ti === $.len(t)
|
|
1124
1232
|
}
|
|
1125
1233
|
|
|
1126
1234
|
// Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
|
package/gs/bytes/iter.gs.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package bytes
|
|
2
|
+
|
|
3
|
+
// GsDependencies lists the import paths that this gs/ package requires
|
|
4
|
+
// These dependencies will be automatically copied when this package is included
|
|
5
|
+
var GsDependencies = []string{
|
|
6
|
+
"errors",
|
|
7
|
+
"io",
|
|
8
|
+
"iter",
|
|
9
|
+
"unicode",
|
|
10
|
+
"unicode/utf8",
|
|
11
|
+
"unsafe",
|
|
12
|
+
}
|
package/gs/bytes/reader.gs.ts
CHANGED
package/gs/context/context.ts
CHANGED
package/gs/errors/errors.ts
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import * as $ from '@goscript/builtin/
|
|
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
|
-
}
|
|
1
|
+
import * as $ from '@goscript/builtin/index.js'
|
|
15
2
|
|
|
16
3
|
// New returns an error that formats as the given text.
|
|
17
4
|
// Each call to New returns a distinct error value even if the text is identical.
|
|
18
5
|
export function New(text: string): $.GoError {
|
|
19
|
-
return
|
|
6
|
+
return $.newError(text)
|
|
20
7
|
}
|
|
21
8
|
|
|
22
9
|
// ErrUnsupported indicates that a requested operation cannot be performed,
|
|
@@ -212,7 +199,7 @@ export function Join(...errs: $.GoError[]): $.GoError {
|
|
|
212
199
|
}
|
|
213
200
|
|
|
214
201
|
const message = nonNilErrs.map((err) => err!.Error()).join('\n')
|
|
215
|
-
const joinedError =
|
|
202
|
+
const joinedError = $.newError(message)
|
|
216
203
|
|
|
217
204
|
// Add Unwrap method that returns the array of errors
|
|
218
205
|
;(joinedError as any).Unwrap = function (): $.GoError[] {
|