balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

redux-hook.js (532B)


      1 /* jshint unused:false */
      2 
      3 function redux_hook( object, functionName, callback, before ) {
      4 	'use strict';
      5 
      6 	(function( originalFunction ) {
      7 		object[functionName] = function() {
      8 			var returnValue;
      9 
     10 			if ( true === before ) {
     11 				callback.apply( this, [returnValue, originalFunction, arguments] );
     12 			}
     13 
     14 			returnValue = originalFunction.apply( this, arguments );
     15 
     16 			if ( true !== before ) {
     17 				callback.apply( this, [returnValue, originalFunction, arguments] );
     18 			}
     19 
     20 			return returnValue;
     21 		};
     22 	}( object[functionName] ) );
     23 }