Add a getItem function.
This commit is contained in:
parent
e53bea8fe4
commit
e3ca7f9494
|
@ -119,6 +119,23 @@ export async function createItem(
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the item for a given key and {@link ItemKeyPrefix}. Note that this
|
||||||
|
* function assumes that the item definitely exists.
|
||||||
|
*/
|
||||||
|
export async function getItem(
|
||||||
|
key: string,
|
||||||
|
itemKeyPrefix: ItemKeyPrefix,
|
||||||
|
): Promise<Value<Item>> {
|
||||||
|
return createValue<Item>({
|
||||||
|
deserialize: deserializeItem,
|
||||||
|
serialize: serializeItem,
|
||||||
|
storage: storageForPrefix(itemKeyPrefix),
|
||||||
|
key,
|
||||||
|
value: undefined!,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all keys from storage that start with the {@link ItemKeyPrefix}.
|
* Get all keys from storage that start with the {@link ItemKeyPrefix}.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue