Skip to content

Commit 44ecf96

Browse files
committed
doc: add docstring explaining new func
1 parent 2abd861 commit 44ecf96

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/core/src/shared/utilities/functionUtils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ export function memoize<T, U extends any[]>(fn: (...args: U) => T): (...args: U)
7777
return (...args) => (cache[args.map(String).join(':')] ??= fn(...args))
7878
}
7979

80+
/**
81+
* Generalization of the {@link memoize} method that accepts async methods, and allows user to pass mapping from keys to args.
82+
* @param fn
83+
* @param key
84+
* @returns
85+
*/
8086
export function memoizeWith<T, U extends any[]>(
8187
fn: (...args: U) => Promise<T>,
8288
key: (...args: U) => Promise<string> | string = (...args: U) => args.map(String).join(':')

0 commit comments

Comments
 (0)