async-json
async-json copied to clipboard
about polyfill
I feel that polyfills are dangerous: you are wrapping a sync method as async method. With the callback / promise you are simulating a async method, but the implementation is synchronously and will block the main thread.
Two solutions: implement a native JSON.parse async or move the sync JSON.parse work at the end of the event loop. I was working in the last option in this repository: https://github.com/Kikobeats/json-parse-async
#7 is addressing event loop related issues.
Also in browsers with workers it is possible to do some operations in a worker and transfer the data via structured clone algorithm.