add buffer and byte objects, making socket read and write faster

This commit is contained in:
2023-06-24 10:30:34 +01:00
parent f63229c6f8
commit 4ca158cc96
8 changed files with 354 additions and 50 deletions

View File

@@ -63,6 +63,12 @@ func makeGlobal() ArObject {
}
return nil, ArErr{TYPE: "TypeError", message: "Cannot convert '" + typeof(a[0]) + "' to hex", EXISTS: true}
}}
vars["buffer"] = builtinFunc{"buffer", func(a ...any) (any, ArErr) {
if len(a) != 0 {
return nil, ArErr{TYPE: "TypeError", message: "expected 0 arguments, got " + fmt.Sprint(len(a)), EXISTS: true}
}
return ArBuffer([]byte{}), ArErr{}
}}
vars["throwError"] = builtinFunc{"throwError", ArThrowError}
vars["array"] = builtinFunc{"array", func(a ...any) (any, ArErr) {
if len(a) == 0 {