tdewolff / parse

Go parsers for web formats
MIT License
408 stars 64 forks source link

Document usage of JS parsers #77

Open RayLuxembourg opened 3 years ago

RayLuxembourg commented 3 years ago

please provide an example so I could PR to add into readme.

discovered

func pareJSFile(path string) {
    jsStr, err := ioutil.ReadFile(path)
    if err != nil {
        fmt.Println(err)
        return
    }
    jsAst,err:= js.Parse(parse.NewInputBytes(jsStr))
    if err != nil {
        log.Fatal(err)
    }
    v:= Visitor{}
    js.Walk(v,jsAst)
}