Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A prototype-aware AOP library
CoffeeScript JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
docs Adding documentation
src Updating source
test Updating test
.gitignore Adding node package
Cakefile Adding documentation
README.md Updating readme
package.json Updating package

README.md

around.js

A prototype-aware AOP library

Motivation

Aspect oriented programming (AOP) is a programming methodology that tries to address the common issue of similar code being created in several files. This violates the basic DRY principle, and especially common for operations like logging, profiling, and error handling.

The solution was to create the ability to cut a function before, after, and around it. This allows you to modify the function without changing it making it more modular and reusable.

Read more on wikipedia.

API

around.extend()

Call this method to extend Function.prototype with
`around`, `before`, and `after` methods

fn.around(fnBefore, fnAfter)

Return a function that cuts before and after the function
being extended.

fn            The function being extended
fnBefore      The function called before fn
fnAfter       The function called after fn

fn.before(fnBefore)

Return a function that cuts before the function being extended.

fn            The function being extended
fnBefore      The function called before fn

fn.after(fnAfter)

Return a function that cuts after the function being extended.

fn            The function being extended
fnBefore      The function called before fn
fnAfter       The function called after fn

Examples

Something went wrong with that request. Please try again.