ruby / ruby/ruby.wasm

Port `arraybuffer` to ruby

Open
#342 6 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.