devalue
devalue copied to clipboard
Add support for async revivers
I wanted to use dynamic imports in revivers to make them more generic. However, the current implementation doesn't allow this because the parsed value would be a promise.
This PR introduces asynchronous versions of unflatten
and parse
, enabling this functionality. I updated the tests accordingly.
Initially, I considered extracting parts of the hydrate function into separate functions for reuse in the async version, however, after some thinking I decided against it due to potential performance issues. I think it's best if we call as few functions as possible here - since it's a recursive call chain.
Feedback welcome!
This is lovely, I need exactly this!