diff options
author | Aurélio A. Heckert <aurium@gmail.com> | 2020-03-22 20:38:42 -0300 |
---|---|---|
committer | Richard Musiol <neelance@gmail.com> | 2020-03-24 10:31:12 +0000 |
commit | f0e8b81aa34120e21642c569912bde00ccd33393 (patch) | |
tree | 84f8030fba8d3e1a74e5c777bae59123b6d754a7 /src/syscall/js | |
parent | 6a9d850b82172225b55bd65e830b1e325b17a724 (diff) | |
download | go-git-f0e8b81aa34120e21642c569912bde00ccd33393.tar.gz |
syscall/js: allow copyBytesTo(Go|JS) to use Uint8ClampedArray
closes #38011
Change-Id: Ic50f2f27456dccdc3fca1bda076871af1eb81705
Reviewed-on: https://go-review.googlesource.com/c/go/+/224638
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Richard Musiol <neelance@gmail.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/syscall/js')
-rw-r--r-- | src/syscall/js/js.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/syscall/js/js.go b/src/syscall/js/js.go index 8a04399171..a48bbd4dd7 100644 --- a/src/syscall/js/js.go +++ b/src/syscall/js/js.go @@ -565,28 +565,28 @@ func (e *ValueError) Error() string { return "syscall/js: call of " + e.Method + " on " + e.Type.String() } -// CopyBytesToGo copies bytes from the Uint8Array src to dst. +// CopyBytesToGo copies bytes from src to dst. +// It panics if src is not an Uint8Array or Uint8ClampedArray. // It returns the number of bytes copied, which will be the minimum of the lengths of src and dst. -// CopyBytesToGo panics if src is not an Uint8Array. func CopyBytesToGo(dst []byte, src Value) int { n, ok := copyBytesToGo(dst, src.ref) runtime.KeepAlive(src) if !ok { - panic("syscall/js: CopyBytesToGo: expected src to be an Uint8Array") + panic("syscall/js: CopyBytesToGo: expected src to be an Uint8Array or Uint8ClampedArray") } return n } func copyBytesToGo(dst []byte, src ref) (int, bool) -// CopyBytesToJS copies bytes from src to the Uint8Array dst. +// CopyBytesToJS copies bytes from src to dst. +// It panics if dst is not an Uint8Array or Uint8ClampedArray. // It returns the number of bytes copied, which will be the minimum of the lengths of src and dst. -// CopyBytesToJS panics if dst is not an Uint8Array. func CopyBytesToJS(dst Value, src []byte) int { n, ok := copyBytesToJS(dst.ref, src) runtime.KeepAlive(dst) if !ok { - panic("syscall/js: CopyBytesToJS: expected dst to be an Uint8Array") + panic("syscall/js: CopyBytesToJS: expected dst to be an Uint8Array or Uint8ClampedArray") } return n } |