Closed ttttmr closed 1 year ago
I often edit ast, modify some data, and then convert ast back to js code, ast.JS() is too slow and takes up a lot of memory
Using buffers can greatly improve efficiency
BenchmarkJsAstJSWriteTo-2 10 194873291 ns/op 36253063 B/op 1031732 allocs/op BenchmarkJsAstJS-2 10 1559868949 ns/op 2160659760 B/op 1057158 allocs/op
// JSWriteTo ast, _ := js.Parse(parse.NewInputBytes(body), js.Options{}) ... var buf bytes.Buffer ast.JSWriteTo(&buf) // JS ast, _ := js.Parse(parse.NewInputBytes(body), js.Options{}) ... ast.JS()
If this is useful, consider this pr
The implementation of some JS() methods may need to wait for #103 to be resolved
Excellent addition, I've incorporated the code, thanks!
I often edit ast, modify some data, and then convert ast back to js code, ast.JS() is too slow and takes up a lot of memory
Using buffers can greatly improve efficiency
If this is useful, consider this pr