File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 833833
834834 var CACHE = R . CACHE = { } ;
835835
836- function cacher ( name , f , scope , postprocessor ) {
836+ function cacher ( f , scope , postprocessor ) {
837837
838838 function newf ( ) {
839839 var arg = Array . prototype . slice . call ( arguments , 0 ) ,
840840 args = arg . join ( "\u2400" ) ;
841841
842842 if ( cache [ has ] ( args ) ) {
843-
844843 if ( count [ count . length - 1 ] !== args ) {
845844 repush ( count , args ) ;
846845 }
847-
846+
848847 return postprocessor ? postprocessor ( cache [ args ] ) : cache [ args ] ;
849848 }
850-
849+
851850 count . length >= 1e3 && delete cache [ count . shift ( ) ] ;
852851 count . push ( args ) ;
853852 var cached = cache [ args ] = f [ apply ] ( scope , arg ) ;
857856 var cache = newf . cache = { } ,
858857 count = newf . count = [ ] ;
859858
859+ newf . clear = function ( ) {
860+ cache = newf . cache = { } ;
861+ count = newf . count = [ ] ;
862+ } ;
863+
860864 CACHE [ name ] = newf ;
861865
862866 return newf ;
863867 }
864868
869+ R . clearCaches = function ( ) {
870+ for ( var key in CACHE ) {
871+ if ( ! CACHE . hasOwnProperty ( key ) ) continue ;
872+
873+ CACHE [ key ] . clear ( ) ;
874+ }
875+ } ;
876+
865877 var preload = R . _preload = function ( src , f ) {
866878 var img = g . doc . createElement ( "img" ) ;
867879 img . style . cssText = "position:absolute;left:-9999em;top:-9999em" ;
You can’t perform that action at this time.
0 commit comments