Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See issue #112. This PR allows you to set the
useRecords
option to a function. IfuseRecords
is a function, Packr will call this function for each object, and only use records when the function returns true.When you have many structured objects combined with many smaller unstructured ones it can make packing smaller and faster, and unpacking substantially faster. For our real-world data we see around 10% size reductions and ~40% faster unpacking!
The only caveat I can think if is that you'll likely want to set
mapsAsObjects: true
if you simply replaceuseRecords: true
with a function. IfuseRecords
istrue
, all plain objects will be unpacked as plain objects since they are packed as records. But when you opt out of record packing for certain objects you need to remember that they will then be unpacked as maps now unless you setmapsAsObjects
totrue
.