You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if I run that query multiple times, there are a bunch of initialization steps that it will repeat that it does not need to (class instantiation). I understand that the generated path is cached, but that feels like an internal cache that doesnt need to be managed and guessed at. Why not just change the api like so:
constquery='<some query>'constoptions={}// all the initialization steps are done hereconstrunQuery=JSONPath(query,options)constobject={...}constresult=runQuery(object)
if the api worked like described, theres a lot of steps we can push onto to the initialization. Here are a few:
new JSONPath
all path parsing (though the JSONPath.toPathArray(expr) step is already cached)
vm.createScript(code) instead of vm.runInContext({ code })
I havent dug too deep into the code, so it may require redesign if the JSONPath class stores some state related to the json input. Is this an interesting idea to anyone?
The text was updated successfully, but these errors were encountered:
Sounds like a great idea to me. If we're making a breaking change anyways, I think we can just make JSONPath into an ES6 class (in source), thereby requiring new, avoiding an extra step for this and getting rid of our NewError. runQuery would then be an instance method.
So currently, running the library works like this:
if I run that query multiple times, there are a bunch of initialization steps that it will repeat that it does not need to (class instantiation). I understand that the generated path is cached, but that feels like an internal cache that doesnt need to be managed and guessed at. Why not just change the api like so:
if the api worked like described, theres a lot of steps we can push onto to the initialization. Here are a few:
new JSONPath
JSONPath.toPathArray(expr)
step is already cached)vm.createScript(code)
instead ofvm.runInContext({ code })
I havent dug too deep into the code, so it may require redesign if the JSONPath class stores some state related to the
json
input. Is this an interesting idea to anyone?The text was updated successfully, but these errors were encountered: