I don’t get how to get Objects from JavaScript. I’ve been successful at binding to JS functions, and even parsing strong types via JSON binding… but… I’m creating a library. The user can pass a “list of headers”. That’ll most likely be an Object like this:
{
"content-type": "application/json",
"authentication": "Bearer cowtokenmoo"
}
Now, I can’t like do an Object.entries/values in ReScript, so… I kind of gave up and just wrote a JavaScript function to run Object.entries
for me, so when ReScript gets it, I can just go Js.Dict.fromArray
… but now I’m stuck on what’s the parameter type. Like… I tried Js.Obj.t, but that doesn’t work.
const headersToEntries = headers => {
if(headers) {
return Object.entries(headers)
}
return []
}
module.exports = {
headersToEntries
}
@module("./headersToEntries") external headersToEntries: Js.t => Js.Array.t<Js.Array.t<string>> = "headersToEntries"
Should I just give up, wrap my ReScript library in JavaScript, and run an Object.entries on the headers Object before it hits ReScript, OR should I yell at my users to do it themselves, OR do y’all have other ideas?