From 9c8550556651045dbfc921f575117e6bb2a430bc Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 22 Oct 2013 15:52:35 +0100 Subject: [PATCH] get rid of the two versions, the larger version is barely slower than the other one, see http://jsperf.com/joint-js-testing-2-arrays --- README.md | 18 +++++++----------- joint.js | 14 +------------- joint.min.js | 11 ++--------- 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 529cc19..00dd5b1 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,15 @@ ## joint.js -_Allows the ability to add extra functionality to an exisintg function by joining an array of functions together._ - -There are two versions available, depending on whether you will ever need to join more than 2 functions together +_Allows the ability to add extra functionality to an existing function by joining an array of functions together._ ### Example -First include one of the joint functions in your script +First include the joint function in your script ```javascript -// Minified-joint (for more than 2 functions) -function joint(a){var b;b=a[a.length-1];a.pop();a=11?joint(a):a[0],function(){b.apply(new a)}} ``` -or -```javascript -// Minified-joint (for only 2 functions) -function joint(a){return function(){a[1].apply(new a[0])}} +or include the js file +```html + ``` Then use it like this; @@ -40,4 +36,4 @@ my_func(); */ ``` -Here it is on jsbin; http://jsbin.com/akinow/1/edit?js,console +Here it is on jsbin; http://jsbin.com/orIDujE/1/edit?js,console diff --git a/joint.js b/joint.js index 6ff2c4b..b89da7f 100644 --- a/joint.js +++ b/joint.js @@ -1,7 +1,6 @@ //----------------------------------------// // Just pick the most appropriate version // //----------------------------------------// - /** * Joint for joining more than 2 functions. * Joins an array of functions together to return a single function @@ -24,15 +23,4 @@ function joint( a ) { return function() { b.apply( new a() ); }; -} - -/** - * Joint for joining only 2 functions - * @param {array} a Two functions in an array [func1, func2] - * @return {function} The first function with the second's added functionality - */ -function joint(a){ - return function(){ - a[1].apply( new a[0]() ); - }; -}; \ No newline at end of file +} \ No newline at end of file diff --git a/joint.min.js b/joint.min.js index ddb08cf..6cd62cd 100644 --- a/joint.min.js +++ b/joint.min.js @@ -1,9 +1,2 @@ -//----------------------------------------// -// Just pick the most appropriate version // -//----------------------------------------// - -// Minified-joint (for more than 2 functions) -function joint(a){var b;b=a[a.length-1];a.pop();a=11?joint(a):a[0],function(){b.apply(new a)}} \ No newline at end of file