Skip to content

Instantly share code, notes, and snippets.

View akhoury's full-sized avatar
🏠
Working from home

Aziz Khoury akhoury

🏠
Working from home
View GitHub Profile
@akhoury
akhoury / augment.coffee
Created August 23, 2013 17:29
augment.coffee
augment = (base, extra, context) ->
(->
->
base.apply context or this, arguments_
extra.apply context or this, arguments_
)()
@akhoury
akhoury / augment.js
Last active December 21, 2015 14:48
augment a function
var augment = function (base, extra, context) {
return (function () {
return function () {
base.apply(context || this, arguments);
extra.apply(context || this, arguments);
};
})();
};
// usage
/*
example:
// [1,2,3,4,5,6,7,8] (must be a power of 2 length)
var arr = new Foldable([1, 2, 3, 4, 5, 6, 7, 8]);
arr.fold( [ "l", "r", "l" ] ); // left, right, left
// left