import { _ } from './constants' ; param func export function memoize < T extends Function > ( func ) { const cache = [ ] ; return ( function ( ) { const args = arguments ; for ( var h = 0 , hlen = cache . length ; h < hlen ; h ++ ) { var keys = cache [ h ] . args ; var ilen = args . length ; if ( keys . length !== ilen ) { continue ; } var matches = 0 ; for ( var i = 0 ; i < ilen ; i ++ ) { if ( keys [ i ] !== args [ i ] ) { break ; } ++ matches ; } if ( matches === ilen ) { return cache [ h ] . value ; } } var value = func . apply ( _ , args ) ; cache . push ( { args , value } ) ; return value ; } as any ) as T ; }