Skip to content

Commit

Permalink
get rid of the two versions, the larger version is barely slower than…
Browse files Browse the repository at this point in the history
  • Loading branch information
Dayjo committed Oct 22, 2013
1 parent b6dbbd2 commit 9c85505
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 33 deletions.
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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=1<a.length?joint(a):a[0];return function(){b.apply(new a)}}
function joint(a){var b;return b=a[a.length-1],a.pop(),a=a.length>1?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
<script src="//raw.github.com/Dayjo/joint/master/joint.min.js"></script>
```

Then use it like this;
Expand All @@ -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
14 changes: 1 addition & 13 deletions joint.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]() );
};
};
}
11 changes: 2 additions & 9 deletions joint.min.js
Original file line number Diff line number Diff line change
@@ -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=1<a.length?joint(a):a[0];return function(){b.apply(new a)}}

// Minified-joint(for only 2 functions)
function joint(a){return function(){a[1].apply(new a[0]}}
/* https://github.com/Dayjo/joint */
function joint(a){var b;return b=a[a.length-1],a.pop(),a=a.length>1?joint(a):a[0],function(){b.apply(new a)}}

0 comments on commit 9c85505

Please sign in to comment.