Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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.

tree: e9ea33384f

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 MIT-LICENSE.txt
Octocat-spinner-32 README.md
Octocat-spinner-32 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.