Skip to content

Commit

Permalink
chore(swing-store): Consolidate keyType assertions (#10471)
Browse files Browse the repository at this point in the history
## Description
Minor cleanup noticed in passing.

### Security Considerations
n/a

### Scaling Considerations
n/a

### Documentation Considerations
n/a

### Testing Considerations
n/a

### Upgrade Considerations
n/a
  • Loading branch information
gibson042 authored Nov 18, 2024
1 parent 98e940d commit d1562a1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 3 deletions.
1 change: 0 additions & 1 deletion packages/swing-store/src/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export function makeSwingStoreExporter(dirPath, options = {}) {
* section
*/
function getHostKV(key) {
typeof key === 'string' || Fail`key must be a string`;
getKeyType(key) === 'host' || Fail`getHostKV requires host keys`;
// @ts-expect-error unknown
return sqlKVGet.get(key);
Expand Down
1 change: 1 addition & 0 deletions packages/swing-store/src/kvStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Fail } from '@endo/errors';
* @param {string} key
*/
export function getKeyType(key) {
typeof key === 'string' || Fail`key must be a string`;
if (key.startsWith('local.')) {
return 'local';
} else if (key.startsWith('host.')) {
Expand Down
2 changes: 0 additions & 2 deletions packages/swing-store/src/swingStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ export function makeSwingStore(dirPath, forceReset, options = {}) {
const kernelKVStore = {
...kvStore,
set(key, value) {
typeof key === 'string' || Fail`key must be a string`;
const keyType = getKeyType(key);
keyType !== 'host' || Fail`kernelKVStore refuses host keys`;
kvStore.set(key, value);
Expand All @@ -352,7 +351,6 @@ export function makeSwingStore(dirPath, forceReset, options = {}) {
}
},
delete(key) {
typeof key === 'string' || Fail`key must be a string`;
const keyType = getKeyType(key);
keyType !== 'host' || Fail`kernelKVStore refuses host keys`;
kvStore.delete(key);
Expand Down

0 comments on commit d1562a1

Please sign in to comment.