devalue icon indicating copy to clipboard operation
devalue copied to clipboard

Add support for async revivers

Open cernymatej opened this issue 1 year ago • 1 comments

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!

cernymatej avatar Jan 17 '24 09:01 cernymatej

This is lovely, I need exactly this!

Vanilagy avatar Jul 04 '24 15:07 Vanilagy