Skip to content

Commit

Permalink
fix(memoize): return type memoize1()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 7, 2019
1 parent be15162 commit c0dafb9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/memoize/src/memoize1.ts
Expand Up @@ -13,10 +13,10 @@ import { Fn1, MapLike } from "./api";
*/
export function memoize1<A, B>(fn: Fn1<A, B>, cache?: MapLike<A, B>) {
!cache && (cache = new Map());
return (x: A) => {
return (x: A): B => {
let res;
return cache!.has(x)
? cache!.get(x)
? cache!.get(x)!
: (cache!.set(x, (res = fn(x))), res);
};
}

0 comments on commit c0dafb9

Please sign in to comment.