Skip to content
git-on-cloudflare
Git hosting on Cloudflare
Sign in
rachel
/
dab
main
Loading...
Browse
Commits
Admin
File
Blob: tests/worker/helpers/bytes.ts
..
/
main
/
tests
/
worker
/
helpers
/
bytes.ts
typescript
7 lines
Copy
View
Raw
Download
Copy raw
View raw
Download
1
export
function
utf8ArrayBuffer
(
value
:
string
):
ArrayBuffer
{
2
const
encoded =
new
TextEncoder
().
encode
(value);
3
const
copy =
new
Uint8Array
(encoded.
byteLength
);
4
copy.
set
(encoded);
5
return
copy.
buffer
;
6
}