mirror of
https://github.com/renovatebot/renovate.git
synced 2024-12-22 05:28:35 +00:00
608d0f6a40
* feat: Create utility for function memoization * Simplify
18 lines
338 B
TypeScript
18 lines
338 B
TypeScript
import { memoize } from './memoize';
|
|
|
|
describe('util/memoize', () => {
|
|
let calledTimes = 0;
|
|
|
|
it('works', () => {
|
|
const fn = (): number => {
|
|
calledTimes += 1;
|
|
return calledTimes;
|
|
};
|
|
const memFn = memoize(fn);
|
|
|
|
expect(memFn()).toBe(1);
|
|
expect(memFn()).toBe(1);
|
|
expect(calledTimes).toBe(1);
|
|
});
|
|
});
|