Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JavaScript library that converts functions to an extended functions. Allows prioritized preprocessor/postprocessor functions to be attached to a function in order to increase its abilities.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
MIT-LICENSE.txt
README.md
xfn.js

README.md

Extended Function Factory

About

  • JavaScript library that converts functions to an extended functions.
  • Allows preprocessor/postprocessor functions to be attached to a function in order to increase its abilities.

Information

Usage

Extending a function

var someFunction = function() { ... };
$xfn(someFunction);

Extending all functions in an object

var someClass = function() { ... };
someClass.prototype = { ... };
$xfn.extend(someClass.prototype);

Adding a preprocessor

someFunction.pre.add(function(result) {
    // Do something.
    arguments[0] = result + '';

    // Always return the resulting arguments object to continue normally.
    return arguments;
});

Adding a postprocessor

someFunction.post.add(function(result) {
    // Process the arguments.
    result = result * 10;

    // Always return the resulting arguments object to continue normally.
    return arguments;
});
Something went wrong with that request. Please try again.