You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, unstorage has two ways to access items:
getItem(key): Returns a json parsed value if parsable or fallback to text
`getItemRaw(key): Returns raw storage value (Typically arrayBuffer but unpredictable)
This is an unpredictable behavior and also introduced two sets of methods.
We could support storage.get(key, { type: "text" | "json" | "bytes" | "stream" | "blob" }) API to unify this and also make behavior more predictable.
awaitstorage.get("key")// Defaults to json > text as before using destrawaitstorage.get("key",{type: "text")// Avoid serializationawaitstorage.get("key",{type: "json")// Strictly use JSON.parseawaitstorage.get("key",{type: "bytes")// Return Buffer or Unit8Arrayawaitstorage.get("key",{type: "bytes")// Return a readable stream
undio can potentially be integrated or we might end-up directly adding small utils in unstorage core to convert
Additional information
Would you be willing to help implement this feature?
The text was updated successfully, but these errors were encountered:
This looks like a nice improvement to me. I suppose the typing would also be improved by looking at the type option? Does it make sense to also include blob as a type?
Describe the feature
Currently, unstorage has two ways to access items:
getItem(key)
: Returns a json parsed value if parsable or fallback to textThis is an unpredictable behavior and also introduced two sets of methods.
We could support
storage.get(key, { type: "text" | "json" | "bytes" | "stream" | "blob" })
API to unify this and also make behavior more predictable.undio can potentially be integrated or we might end-up directly adding small utils in unstorage core to convert
Additional information
The text was updated successfully, but these errors were encountered: