specialize `ArrayBuffer#to_s` and return ASCII-8BIT data
To fix #342 , specialize ArrayBuffer#to_s and return ASCII-8BIT data.
Usage:
require "js"
response = JS.global.fetch("<dumped buffer's url>").await
puts response[:status]
arraybuffer = response.arrayBuffer.await
Marshal.load(arraybuffer.to_s) # we can Marshal.load now!
Of course this is destructive, but no one will spare the old behavior since the current to_s always returns [object ArrayBuffer] and is useless.
Hey why doesn't linter give me an error message? I mean, there's nothing I can do about it.
Sorry for my lack of learning, but in my experiments, this worked fine.
What is the file from which rb-js-abi-host.js was generated?
I will edit that one, but I cannot find the corresponding *.wit file.
@krmbn0576 This one https://github.com/ruby/ruby.wasm/blob/main/packages/gems/js/ext/witapi/bindgen/rb-abi-guest.wit
I recently moved the file and I might forget to update docs that pointing that old path. In that case, I'm sorry :bow:
Thanks! But it is unexpected. In that file, there are only definitions and no implementation. More to the point, there is not even a definition for the js-value-to-string function, so I cannot edit implementation.
It seems I am overloaded to properly edit bindgen to bring a complete solution to this issue. But no worries. I have confirmed that the patch works properly and faster in my product. My issue has been resolved 😇