Memo with Dependencies. Inspired from React.useMemo. This can be used outside of React components without hooks.
import { memo } from 'memo-deps';
function expensive(arg1, arg2) {
//
}
const memoized = memo(expensive);
const dep1 = { a: 1 };
const dep2 = [ 4 ];
let result1 = memoized([arg1, arg2], [dep1, dep2]);
let result2 = memoized([arg3, arg4], [dep1, dep2]); // `expensive` is not called again, result2 === result1.
let result3 = memoized([arg3, arg4], [dep3, dep4]); // `expensive` is called again.