Skip to content

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.

License

Notifications You must be signed in to change notification settings

andykant/extended-function-factory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

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

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published