import { areShallowEqualWithArray } from './isEqual' ; export function defaultMemoize ( func ) { const lastArgs = new Map ( ) ; const lastResult = new Map ( ) ; return function ( this ) { if ( ! areShallowEqualWithArray ( lastArgs . get ( this ) ?? [ ] , arguments ) ) { lastResult . set ( this , func . apply ( this , arguments ) ) ; } lastArgs . set ( this , arguments ) ; return lastResult . get ( this ) ; } ; } const createSelectorCreatorWithArray = ( memoize = defaultMemoize ) => { return ( dependenciesFunc , resultFunc ) => { const memoizedResultFunc = memoize ( function ( this ) { return resultFunc . apply ( this , arguments ) ; } ) ; return function ( this ) { return memoizedResultFunc . apply ( this , dependenciesFunc . apply ( null , [ this ] ) ) ; } ; } ; } ; export const createSelectorWithArray = createSelectorCreatorWithArray ( ) ;