Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 1.18 KB

README.md

File metadata and controls

43 lines (35 loc) · 1.18 KB

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;
});