Skip to content

Commit

Permalink
chore: expose complete typings for lib
Browse files Browse the repository at this point in the history
  • Loading branch information
bchrobot committed Jan 26, 2021
1 parent b28d1b4 commit 21a850b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
18 changes: 17 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 5 additions & 5 deletions src/lib/memoizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ export interface Logger {
error(primaryMessage: string, ...supportingData: any[]): void;
}

interface MemoizerOpts {
export interface MemoizerOpts {
prefix?: string;
client?: RedisClient;
clientOpts?: ClientOpts;
emptyMode?: boolean;
logger?: Logger;
}

interface MemoizeOpts {
export interface MemoizeOpts {
key: string;
lockTimeout?: number;
ttl?: number;
}

interface MemoizedFunctionArgs {
export interface MemoizedFunctionArgs {
[key: string]: any;
}

type MemoizableFunction<T, U> = (args: T) => Promise<U>;
export type MemoizableFunction<T, U> = (args: T) => Promise<U>;

interface Memoizer {
export interface Memoizer {
invalidate(key: string, args: MemoizedFunctionArgs): Promise<void>;
memoize<T, U>(
fn: MemoizableFunction<T, U>,
Expand Down

0 comments on commit 21a850b

Please sign in to comment.