Skip to content

Commit

Permalink
Merge pull request #30 from ivstiv/adding-typescript-declaration
Browse files Browse the repository at this point in the history
Adding typescript declaration
  • Loading branch information
bradvogel authored Jul 12, 2023
2 parents 8e185c0 + 7caafd7 commit b3f21d3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
declare module "redfour" {

interface LockOptions {
redis: any // the parameters of createClient from redis are untyped?
namespace?: string
}

interface LockObject {
id: string
success: boolean
index: string
result: any
}

interface AcquiredLockObject {
id: string
success: boolean
index: string
ttl: number
}

class Lock {
constructor(options: LockOptions);
acquireLock(id: string, ttl: number): Promise<AcquiredLockObject>
releaseLock(lock: Lock): Promise<LockObject>
waitAcquireLock(id: string, lockTtl: number, waitTtl: number): Promise<AcquiredLockObject & { immediate: boolean }>
renewLock(lock: {id: string, index: string}, ttl: number): Promise<LockObject>
}

export = Lock
}

0 comments on commit b3f21d3

Please sign in to comment.