-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map is empty #368
Comments
Here's a simpler code without type casting: vm := goja.New() |
Currently The problem here is similar to what I described in #336, however I gave it a little bit of thought and I think something like this could work:
Note that What do you (or anyone else interested) think? |
Hello Dmitry, I admire your work and appreciate that you took time to offer your insightful advice.
We wish there were a way to get the keys so that we could at least utilize 'get' that you advised in order to access the values. We would appreciate your expertise on this matter. Best regards, |
First of all I highly recommend you to read the README and the reference documentation. It's not the best in the world, but it's there and at least it has all public methods mentioned. What I mentioned in the previous comment was a proposal, none of it it implemented right now, and I have doubts about what would be the best approach, especially for the Another possibility would be that Another option could be returning a list of entries in the form of [[key, value], ...] as [][]interface{}. This would make it somewhat more useful than the current version. As for your question about map keys, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys. I might add a method to simplify using ES iterators from Go (i.e. Another advice would be to consider whether you really need to use |
Hello Dmitry, Thank you for recommending the README and the reference documentation which have been very helpful. [][]interface{} is a fantastic idea. We hope it can be implemented soon. Unfortunately our requirement is to use Map instead of a simple Object. We appreciate your help and your wonderful work. Best regards, |
Hello,
We are getting an empty map in Go from "new Map([['a',1], ['b', 2]]);" in the following one liner script. We've also tried keys() to see what's going on but that also turns out to be an empty map. We would appreciate your expertise on this matter. Thanks.
package main
import (
"fmt"
"github.com/dop251/goja"
)
func main() {
vm := goja.New()
r, _ := vm.RunString(
m = new Map([['a',1], ['b', 2]]);
)v, _ := r.Export().(map[string]interface{})
fmt.Printf("Map is empty: %#v\n", v)
}
Map is empty: map[string]interface {}{}
The text was updated successfully, but these errors were encountered: