Skip to content

Commit

Permalink
Use Keyv type for KeyvMulti.Options stores (#211)
Browse files Browse the repository at this point in the history
The "remote" and "local" types were incorrectly set to a JS Map (which
Keyv uses under the hood). With these changes consuming apps can pass
any Keyv store to the Multi class constructor
  • Loading branch information
lucasadrianof authored Jul 30, 2024
1 parent 2f8310d commit ff20ce7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions packages/multi/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Store } from '@keyvhq/core'
import Keyv, { Store } from '@keyvhq/core'

declare class KeyvMulti<TValue> implements Store<TValue> {
constructor (options: KeyvMulti.Options)
constructor (options: KeyvMulti.Options<TValue>)

get (key: string): Promise<TValue>
has (key: string): Promise<boolean>
Expand All @@ -12,9 +12,9 @@ declare class KeyvMulti<TValue> implements Store<TValue> {
}

declare namespace KeyvMulti {
interface Options {
local?: Map<string, any>
remote?: Map<string, any>
interface Options<TValue> {
local?: Keyv<TValue>
remote?: Keyv<TValue>
validator?: () => boolean
}
interface ClearOptions {
Expand Down
4 changes: 2 additions & 2 deletions packages/multi/test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Keyv from '@keyvhq/core'
import KeyvMulti from '../src'

const store = new KeyvMulti({
local: new Map(),
remote: new Map()
local: new Keyv(),
remote: new Keyv()
})

new Keyv({ store }).clear({ localOnly: true })

0 comments on commit ff20ce7

Please sign in to comment.