around

0.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i around

Weekly Downloads

1

Version

0.0.1

License

none

Last publish

Collaborators

  • evanmoran