-
<inner> after(base, after) → {function}
-
Fires function after the base on
Parameters:
Name |
Type |
Description |
base |
function
|
Base function to be advised |
after |
function
|
Function to be called after |
- Source:
Returns:
Function body with your function before
-
Type
-
function
-
<inner> around(base, wrapped) → {function}
-
Wrapes function around
Parameters:
Name |
Type |
Description |
base |
function
|
Function to wrap on |
wrapped |
function
|
Wrapping function |
- Source:
Returns:
Wrapped function body
-
Type
-
function
-
<inner> before(base, before) → {function}
-
Fires function before the base one
Parameters:
Name |
Type |
Description |
base |
function
|
Base function to be advised |
before |
function
|
Function to be called before |
- Source:
Returns:
Function body with your function before
-
Type
-
function
-
<inner> withAdvice()
-
Binds advice for given object
- Source:
Example
var myObj = {
sample : function () {
console.log('World!');
}
};
Carpet.advice.withAdvice.call(myObj);
myObj.before('sample', function () {
console.log('Hello ');
});
myObj.sample();
// => 'Hello '
// => 'World!'