Port `arraybuffer` to ruby
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 875
- Forks
- 68
- Avg merge
- 9d 5h
- Merged PRs (30d)
- 1
Description
require "js"
response = JS.global.fetch("<dumped buffer's url>").await
puts response[:status]
arraybuffer = response.arrayBuffer.await
# Expected goal:
# Marshal.load(arraybuffer)
some byte arrays need to port ruby (typically generated by Marshal.dump), but no fast way
# Correct but too slow way:
uint8array = JS.global[:Uint8Array].new(arraybuffer)
Marshal.load(uint8array.to_a.map(&:to_i).pack("C*")) # Especially the slow JS::Object#to_i on each byte.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Ruby WebAssembly JavaScript interop used by JS.global.fetch and response.arrayBuffer, then compare it with the Uint8Array conversion shown in the issue. Done means ArrayBuffer data from response.arrayBuffer can be passed to Marshal.load without converting each byte through JavaScript objects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, ruby, wasm
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100