Joining functions in Javascript

I needed a way of adding some extra functionality to some existing functions but without wanting to touch the original functions’ code, essentially joining functions together.

This is what joint.js does.

I ended up making two versions, one for joining more than 2 functions which has more of an overhead, and a simpler one for just joining only two functions.

First include the joint function in your script

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

Then use it like this;

// My original function that I want to extend
function my_func() {
    console.log( "Original functionality." );
}

// Function with the new functionality
function new_func() {
    console.log( "New functionality." );
}

// Add the functionality of new_func to my_func by joining functions
my_func = joint([ my_func, new_func ]);

// Now run the original function with the new functionality
my_func();

/* CONSOLE OUTPUT:
 > Original functionality.
 > New functionality.
*/

You can download the source on my GitHub here: https://github.com/Dayjo/joint/ or take a look at it working on JSBin

Alternatively you can see this post on coderwall.com here; https://coderwall.com/p/j-cega

Busy busy busy bored…

When you work full time Monday – Friday as a web developer, more often than not coming back and doing more web development isn’t the most enticing idea.

However, funnily enough I still enjoy doing it. A lot of the freelance work I’m doing at the moment is pretty varying, from simply putting up content pages to designing content management systems.

Unfortunately for me, I have a few projects of my own that are currently having to be put on the back-burner (Petals for one), but I’m actually able to assign some work on Petals features to a freelance project that I’m doing (which is both handy, and exactly why I’m working on Petals in the first place), subsidising work to save both my client and I time and money.

As for other projects, such as the RPG Music Pack, again this is on the back-burner due to lack of time, inspiration and the fact that I don’t have a keyboard to write with. I did, however just go and buy myself a Double Bass which is ridiculously fun (and strenuous on the wrist and fingers). It’s definitely started giving me some musical inspiration so hopefully soon I’ll pluck up the courage to invest some more money in a keyboard.

It’s not that money is tight, but my financial management skills are seriously lacking *looks at £70 Sainsbury’s shop*.

My lack of free time has left what [free] time I tend to take kind of empty, generally I don’t have enough time to sit down and think about writing music, so I end up wasting an hour watching an episode of 24 (currently on season 5, episode 6), or playing Left 4 Dead (2) .  Luckily this bank holiday has given me that extra weekend-time to partially organise myself and do a few things I’ve been meaning to for a while, so potentially there’ll be less of a lag on my to do list!

Anywho,  I’ve had myself a break, best get back to work.

Petals – Web Application Project

I’ve started development on Petals™ which is  a project by Loose Roots.

Petals is a collection of web applications, purpose built, but with future development and expansion in mind.

The main project currently under the ‘Petals’ label is Filer an online file management and distribution application. The first use of filer will be to completely re-create Zelda Sounds with a proper system for administration, decent statistics, a members system and general performance improvements. Filer will provide all of this and also put forward the possibility to eventually white-label the system and provide other administrators the same application to run their websites on.

Another smaller yet just as flexible and useful application is Petals Img a simple Image Manager, great for photography or art websites that don’t need a full CMS but just some way of indexing, and managing the images on their site.

To keep up to date with the development of Petals, keep an eye out at http://petals.looseroots.com alternatively go ahead and just follow the twitter feed: http://twitter.com/petals_

Regards,

Joel

Need Boarding/Skiing partners to go to France with, first week of Feb.

I’ve booked a week off work to go boarding from the 30th of Jan to the 7th of Feb, but currently I’m going by myself!

Looking for anyone who fancies a week or a long weekend boarding or skiing somewhere in the alps. I’ve yet to quite decide where I’m actually going, as finding accomodation and such for one person is proving harder than I’d thought.

I’m not the greatest snowboarder in the world so any levelled people are welcome to come along and join in the snowy goodness :)

If you fancy it, give me a shout; dayjo@dayjo.org

Cheers!