@luvio/service-store
Advanced tools
Comparing version 5.8.0 to 5.9.0
import { type Key } from './key'; | ||
import { type KeySet } from './key-set'; | ||
import { type StoreService } from './store'; | ||
import type { StoreServiceDescriptor } from './store'; | ||
import type { RecordableStore, StoreServiceDescriptor } from './store'; | ||
/** | ||
@@ -19,2 +19,3 @@ * A simple in-memory implementation of the Store interface. | ||
toKeySet(keys: Key[]): KeySet; | ||
record(): RecordableStore; | ||
} | ||
@@ -21,0 +22,0 @@ /** |
@@ -5,2 +5,1 @@ export { type Key } from './key'; | ||
export { buildServiceDescriptor } from './in-memory'; | ||
export { RecordableStore } from './recordable'; |
@@ -8,3 +8,3 @@ import { type Key } from './key'; | ||
*/ | ||
export declare class RecordableStore implements StoreService { | ||
export declare class DefaultRecordableStore implements StoreService { | ||
private baseStore; | ||
@@ -21,2 +21,3 @@ keysRead: KeySetImpl; | ||
toKeySet(keys: Key[]): KeySet; | ||
record(): import("./store").RecordableStore; | ||
} |
@@ -48,4 +48,13 @@ import { type Key } from './key'; | ||
toKeySet(keys: Key[]): KeySet; | ||
/** | ||
* Returns a wrapper for this store that records access. | ||
*/ | ||
record(): RecordableStore; | ||
}; | ||
export type RecordableStore = StoreService & { | ||
keysRead: KeySet; | ||
missingKeysRead: KeySet; | ||
keysUpdated: KeySet; | ||
}; | ||
export type NamedStoreService<Name extends string = 'store'> = NamedService<Name, StoreService>; | ||
export type StoreServiceDescriptor = ServiceDescriptor<StoreService, 'store', '1.0'>; |
@@ -65,2 +65,43 @@ /** | ||
/** | ||
* A RecordableStore wraps another Store and is used to record which keys in the | ||
* other Store are read/written. | ||
*/ | ||
class DefaultRecordableStore { | ||
constructor(baseStore) { | ||
this.baseStore = baseStore; | ||
this.keysRead = new KeySetImpl(); | ||
this.missingKeysRead = new KeySetImpl(); | ||
this.keysUpdated = new KeySetImpl(); | ||
} | ||
delete(key, options) { | ||
this.keysUpdated.add(key); | ||
this.baseStore.delete(key, options); | ||
} | ||
get(key, options) { | ||
this.keysRead.add(key); | ||
const value = this.baseStore.get(key, options); | ||
if (value === undefined) { | ||
this.missingKeysRead.add(key); | ||
} | ||
return value; | ||
} | ||
set(key, value, options) { | ||
this.keysUpdated.add(key); | ||
this.baseStore.set(key, value, options); | ||
} | ||
length() { | ||
return this.baseStore.length(); | ||
} | ||
keys() { | ||
return this.baseStore.keys(); | ||
} | ||
toKeySet(keys) { | ||
return this.baseStore.toKeySet(keys); | ||
} | ||
record() { | ||
return this.baseStore.record(); | ||
} | ||
} | ||
/** | ||
* A simple in-memory implementation of the Store interface. | ||
@@ -97,2 +138,5 @@ * | ||
} | ||
record() { | ||
return new DefaultRecordableStore(this); | ||
} | ||
} | ||
@@ -112,40 +156,2 @@ /** | ||
/** | ||
* A RecordableStore wraps another Store and is used to record which keys in the | ||
* other Store are read/written. | ||
*/ | ||
class RecordableStore { | ||
constructor(baseStore) { | ||
this.baseStore = baseStore; | ||
this.keysRead = new KeySetImpl(); | ||
this.missingKeysRead = new KeySetImpl(); | ||
this.keysUpdated = new KeySetImpl(); | ||
} | ||
delete(key, options) { | ||
this.keysUpdated.add(key); | ||
this.baseStore.delete(key, options); | ||
} | ||
get(key, options) { | ||
this.keysRead.add(key); | ||
const value = this.baseStore.get(key, options); | ||
if (value === undefined) { | ||
this.missingKeysRead.add(key); | ||
} | ||
return value; | ||
} | ||
set(key, value, options) { | ||
this.keysUpdated.add(key); | ||
this.baseStore.set(key, value, options); | ||
} | ||
length() { | ||
return this.baseStore.length(); | ||
} | ||
keys() { | ||
return this.baseStore.keys(); | ||
} | ||
toKeySet(keys) { | ||
return this.baseStore.toKeySet(keys); | ||
} | ||
} | ||
export { KeySetImpl, RecordableStore, buildServiceDescriptor }; | ||
export { KeySetImpl, buildServiceDescriptor }; |
import { type Key } from './key'; | ||
import { type KeySet } from './key-set'; | ||
import { type StoreService } from './store'; | ||
import type { StoreServiceDescriptor } from './store'; | ||
import type { RecordableStore, StoreServiceDescriptor } from './store'; | ||
/** | ||
@@ -19,2 +19,3 @@ * A simple in-memory implementation of the Store interface. | ||
toKeySet(keys: Key[]): KeySet; | ||
record(): RecordableStore; | ||
} | ||
@@ -21,0 +22,0 @@ /** |
@@ -5,2 +5,1 @@ export { type Key } from './key'; | ||
export { buildServiceDescriptor } from './in-memory'; | ||
export { RecordableStore } from './recordable'; |
@@ -8,3 +8,3 @@ import { type Key } from './key'; | ||
*/ | ||
export declare class RecordableStore implements StoreService { | ||
export declare class DefaultRecordableStore implements StoreService { | ||
private baseStore; | ||
@@ -21,2 +21,3 @@ keysRead: KeySetImpl; | ||
toKeySet(keys: Key[]): KeySet; | ||
record(): import("./store").RecordableStore; | ||
} |
@@ -48,4 +48,13 @@ import { type Key } from './key'; | ||
toKeySet(keys: Key[]): KeySet; | ||
/** | ||
* Returns a wrapper for this store that records access. | ||
*/ | ||
record(): RecordableStore; | ||
}; | ||
export type RecordableStore = StoreService & { | ||
keysRead: KeySet; | ||
missingKeysRead: KeySet; | ||
keysUpdated: KeySet; | ||
}; | ||
export type NamedStoreService<Name extends string = 'store'> = NamedService<Name, StoreService>; | ||
export type StoreServiceDescriptor = ServiceDescriptor<StoreService, 'store', '1.0'>; |
{ | ||
"name": "@luvio/service-store", | ||
"version": "5.8.0", | ||
"version": "5.9.0", | ||
"private": false, | ||
@@ -33,5 +33,8 @@ "description": "Luvio request deduplication service", | ||
"dependencies": { | ||
"@luvio/generator-ts": "^5.8.0", | ||
"@luvio/utils": "^5.8.0" | ||
"@luvio/generator-ts": "^5.9.0", | ||
"@luvio/utils": "^5.9.0" | ||
}, | ||
"volta": { | ||
"extends": "../../../../package.json" | ||
}, | ||
"bundlesize": [ | ||
@@ -38,0 +41,0 @@ { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20068
441
Updated@luvio/generator-ts@^5.9.0
Updated@luvio/utils@^5.9.0