ruby / ruby/ruby.wasm

Add `to_b` and `to_h` to `JS::Object`

Open
#346 3 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

I would like to suggest adding to_b and to_h to JS::Object, to convert into a ruby boolean respective hash.

to_b → boolean
Converts self to true or false:

JS.eval("return true").to_b        # => true
JS.eval("return false").to_b       # => false

to_h → hash
Converts self to a Hash:

JS.eval("return {foo: 'bar'}").to_h         # => { "foo" => "bar" }

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

Use the requested JS::Object methods and the Ruby examples as the acceptance criteria. Start by locating the JS::Object implementation and its existing conversion behavior; then verify that JavaScript booleans become Ruby booleans and JavaScript objects become Ruby Hashes, including the example values.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, ruby, wasm
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.