Skip to content

Commit

Permalink
chore(types): storageHelper params
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 12, 2023
1 parent bc4a41c commit 81c1cee
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/SwingSet/src/kernel/state/storageHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export function* enumeratePrefixedKeys(kvStore, prefix, exclusiveEnd) {
}
}

// NOTE: awkward naming: the thing that returns a stream of keys is named
/**
* @param {KVStore} kvStore
* @param {string} prefix
*/ // NOTE: awkward naming: the thing that returns a stream of keys is named
// "enumerate..." while the thing that returns a stream of values is named
// "get..."
function* enumerateNumericPrefixedKeys(kvStore, prefix) {
Expand All @@ -43,12 +46,20 @@ function* enumerateNumericPrefixedKeys(kvStore, prefix) {
}
}

/**
* @param {KVStore} kvStore
* @param {string} prefix
*/
export function* getPrefixedValues(kvStore, prefix) {
for (const key of enumerateNumericPrefixedKeys(kvStore, prefix)) {
yield kvStore.get(key) || Fail`enumerate ensures get`;
}
}

/**
* @param {KVStore} kvStore
* @param {string} prefix
*/
export function deletePrefixedKeys(kvStore, prefix) {
// this is kind of like a deleteRange() would be, but can be implemented
// efficiently without backend DB support because it only looks at numeric
Expand Down

0 comments on commit 81c1cee

Please sign in to comment.