Currently, we need to be able to handle serializing non-JSON-compatible
objects without catastrophically failing to save the storage file. Ideally, we
would ensure this in the ordinary toJSON method. However, that would require
a unnecessary extra calls to JSON.stringify for each object that needs to be
sanitized before returning a JSON-safe value, which is more expensive than we
can afford.
The fallback toJSONSafe method allows us to do this only when necessary, due
to an initial failed JSON serialization.
MozReview-Commit-ID: JXQ001dOGtW
--HG--
extra : rebase_source : ae52bdab81b03bb4c31edbe4b78584fd15c982a3
extra : source : 9c4bf59ab966a8ec17181d85cc1fc4be7450cca3
Currently, we need to be able to handle serializing non-JSON-compatible
objects without catastrophically failing to save the storage file. Ideally, we
would ensure this in the ordinary toJSON method. However, that would require
a unnecessary extra calls to JSON.stringify for each object that needs to be
sanitized before returning a JSON-safe value, which is more expensive than we
can afford.
The fallback toJSONSafe method allows us to do this only when necessary, due
to an initial failed JSON serialization.
MozReview-Commit-ID: JXQ001dOGtW
--HG--
extra : rebase_source : 0b7b388316fdc464b47cdd4f7d8c70bc906a9c27
* The `data` setter sets the backing data object to a new value, and
flips `dataReady` so that `ensureDataReady` and `load` don't read
stale data from disk. This can be used to clear existing data.
* The `beforeSave` hook is called from `_save`, as part of the deferred
task. This can be used to create intermediate directories containing
the file, or run other pre-save tasks that shouldn't be interrupted
by shutdown.
MozReview-Commit-ID: AzOx7u2Rali
--HG--
extra : rebase_source : 42c0235774ca34e097e858b6ef796c4d1bd4f122