• after( Map pointcut, Function advice ) returns Array<Function>
    Creates an advice after the defined point-cut. The advice will be executed after the point-cut method has completed execution successfully, and will receive one parameter with the result of the execution. This function returns an array of weaved aspects (Function).

    Options

    • target (Object): Target object to be weaved.
    • method (String): Name of the function to be weaved. Regex are supported, but not on built-in objects.

    Example:

    jQuery.aop.after( {target: window, method: 'MyGlobalMethod'}, function(result) { alert('Returned: ' + result); } );

    Result:

    Array<Function>

    Example:

    jQuery.aop.after( {target: String, method: 'indexOf'}, function(index) { alert('Result found at: ' + index + ' on:' + this); } );

    Result:

    Array<Function>
  • around( Map pointcut, Function advice ) returns Array<Function>
    Creates an advice 'around' the defined point-cut. This type of advice can control the point-cut method execution by calling the functions '.proceed()' on the 'invocation' object, and also, can modify the arguments collection before sending them to the function call. This function returns an array of weaved aspects (Function).

    Options

    • target (Object): Target object to be weaved.
    • method (String): Name of the function to be weaved. Regex are supported, but not on built-in objects.

    Example:

    jQuery.aop.around( {target: window, method: 'MyGlobalMethod'}, function(invocation) {
                   alert('# of Arguments: ' + invocation.arguments.length); 
                   return invocation.proceed(); 
             } );

    Result:

    Array<Function>

    Example:

    jQuery.aop.around( {target: String, method: 'indexOf'}, function(invocation) { 
                   alert('Searching: ' + invocation.arguments[0] + ' on: ' + this); 
                   return invocation.proceed(); 
             } );

    Result:

    Array<Function>

    Example:

    Matches all global methods starting with 'Get' and followed by a number.

    jQuery.aop.around( {target: window, method: /Get(\d+)/}, function(invocation) {
                   alert('Executing ' + invocation.method); 
                   return invocation.proceed(); 
             } );

    Result:

    Array<Function>
  • before( Map pointcut, Function advice ) returns Array<Function>
    Creates an advice before the defined point-cut. The advice will be executed before the point-cut method but cannot modify the behavior of the method, or prevent its execution. This function returns an array of weaved aspects (Function).

    Options

    • target (Object): Target object to be weaved.
    • method (String): Name of the function to be weaved. Regex are supported, but not on built-in objects.

    Example:

    jQuery.aop.before( {target: window, method: 'MyGlobalMethod'}, function() { alert('About to execute MyGlobalMethod'); } );

    Result:

    Array<Function>

    Example:

    jQuery.aop.before( {target: String, method: 'indexOf'}, function(index) { alert('About to execute String.indexOf on: ' + this); } );

    Result:

    Array<Function>
  • introduction( Map pointcut, Function advice ) returns Array<Function>
    Creates an introduction on the defined point-cut. This type of advice replaces any existing methods with the same name. To restore them, just unweave it. This function returns an array with only one weaved aspect (Function).

    Options

    • target (Object): Target object to be weaved.
    • method (String): Name of the function to be weaved.

    Example:

    jQuery.aop.introduction( {target: window, method: 'MyGlobalMethod'}, function(result) { alert('Returned: ' + result); } );

    Result:

    Array<Function>

    Example:

    jQuery.aop.introduction( {target: String, method: 'log'}, function() { alert('Console: ' + this); } );

    Result:

    Array<Function>
  • setup( Map settings ) returns Void
    Configures global options.

    Options

    • regexMatch (Boolean): Enables/disables regex matching of method names.

    Example:

    Disable regex matching.

    jQuery.aop.setup( { regexMatch: false } );