Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: raw data support (experimental) #141

Merged
merged 2 commits into from
Feb 6, 2023
Merged

feat: raw data support (experimental) #141

merged 2 commits into from
Feb 6, 2023

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Feb 6, 2023

Resolves #21
Resolves #121

This PR supports the storing and retrieval of raw values using the new getItemRaw/setItemRaw interface.

Drivers can opt-in to implement getItemRaw/setItemRaw as well. When they do, unstorage directly uses this interface instead of getItem/setItem.

For drivers not supporting raw format, unstorage uses a compatibility layer to serialize and deserialize raw values with base64: protocol. Raw input can be any value supported by [Buffer.from(https://nodejs.org/api/buffer.html). This support is now added for fs (node) and memory (universal)

Followup #142

@codecov
Copy link

codecov bot commented Feb 6, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@ec7c7c2). Click here to learn what that means.
The diff coverage is 84.09%.

@@           Coverage Diff           @@
##             main     #141   +/-   ##
=======================================
  Coverage        ?   89.80%           
=======================================
  Files           ?       15           
  Lines           ?     1324           
  Branches        ?      299           
=======================================
  Hits            ?     1189           
  Misses          ?      135           
  Partials        ?        0           
Impacted Files Coverage Δ
src/_utils.ts 85.71% <66.66%> (ø)
src/storage.ts 90.43% <85.71%> (ø)
src/drivers/fs.ts 94.33% <100.00%> (ø)
src/drivers/memory.ts 100.00% <100.00%> (ø)
src/drivers/utils/node-fs.ts 89.53% <100.00%> (ø)
src/types.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@pi0 pi0 merged commit b379e71 into main Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow option for a driver to control value serialization/deserialization Support raw data
1 participant