feat: custom serialize and unserialize functions

This is something my team for my day job needs to perform a certain upgrade. I'm going to publish it to NPM under a different name so we can get this done, but I'm also submitting it here in case the project is still maintained and someone might find it useful.

It adds custom hooks for serializing and deserializing functions. If specified, they will be used instead of `JSON.parse`/`JSON.stringify` or the default behavior already in the library. This will allow us to perform an upgrade where we will need to support deserializing from strings and from objects for a window of time.