Skip to content

Commit

Permalink
refactor(memoize): use arrow fns
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jan 5, 2019
1 parent 5d53028 commit 48670f5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/memoize/src/defonce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const cache: any = {};
* @param id
* @param factory
*/
export function defonce<T>(id: string, factory: Fn0<T>): T {
return cache.hasOwnProperty(id) ?
cache[id] :
(cache[id] = factory());
}
export const defonce =
<T>(id: string, factory: Fn0<T>): T =>
cache.hasOwnProperty(id) ?
cache[id] :
(cache[id] = factory());

0 comments on commit 48670f5

Please sign in to comment.