From 21a850b4a9c8c1acfc380f1f76d4180267193943 Mon Sep 17 00:00:00 2001 From: Benjamin Chrobot Date: Tue, 26 Jan 2021 16:00:39 -0500 Subject: [PATCH] chore: expose complete typings for lib --- src/index.ts | 18 +++++++++++++++++- src/lib/memoizer.ts | 10 +++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 24c4387..0f2e9e0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,19 @@ -import { createMemoizer } from './lib/memoizer'; +import { + createMemoizer, + MemoizerOpts, + Memoizer, + MemoizeOpts, + MemoizedFunctionArgs, + MemoizableFunction +} from './lib/memoizer'; + +export { + MemoizerOpts, + Memoizer, + MemoizeOpts, + MemoizedFunctionArgs, + MemoizableFunction, + createMemoizer +}; export default createMemoizer; diff --git a/src/lib/memoizer.ts b/src/lib/memoizer.ts index 1096c02..638177b 100644 --- a/src/lib/memoizer.ts +++ b/src/lib/memoizer.ts @@ -18,7 +18,7 @@ export interface Logger { error(primaryMessage: string, ...supportingData: any[]): void; } -interface MemoizerOpts { +export interface MemoizerOpts { prefix?: string; client?: RedisClient; clientOpts?: ClientOpts; @@ -26,19 +26,19 @@ interface MemoizerOpts { logger?: Logger; } -interface MemoizeOpts { +export interface MemoizeOpts { key: string; lockTimeout?: number; ttl?: number; } -interface MemoizedFunctionArgs { +export interface MemoizedFunctionArgs { [key: string]: any; } -type MemoizableFunction = (args: T) => Promise; +export type MemoizableFunction = (args: T) => Promise; -interface Memoizer { +export interface Memoizer { invalidate(key: string, args: MemoizedFunctionArgs): Promise; memoize( fn: MemoizableFunction,