filtrex.js
function layerMethod(k, fun) {
    var pos = k.match(position)[0],
        key = k.replace(position, ''),
        prop = this[key];

    if (pos === 'after') {
        this[key] = function () {
            var ret = prop.apply(this, arguments);
            var args = [].slice.call(arguments);
            args.splice(0, 0, ret);
            fun.apply(this, args);
            return ret;
        };
    } else if (pos === 'before') {
        this[key] = function () {
            fun.apply(this, arguments);
            var ret = prop.apply(this, arguments);
            return ret;
        };
    }
}
function layerMethod(k, fun) {
    var pos = k.match(position)[0],
        key = k.replace(position, ''),
        prop = this[key];

    if (pos === 'after') {
        this[key] = function () {
            var ret = prop.apply(this, arguments);
            var args = [].slice.call(arguments);
            args.splice(0, 0, ret);
            fun.apply(this, args);
            return ret;
        };
    } else if (pos === 'before') {
        this[key] = function () {
            fun.apply(this, arguments);
            var ret = prop.apply(this, arguments);
            return ret;
        };
    }
}
function layerMethod ( k , fun ) { var pos = k . match ( position ) [ 0 ] , key = k . replace ( position , '' ) , prop = this [ key ] ; if ( pos === 'after' ) { this [ key ] = function ( ) { var ret = prop . apply ( this , arguments ) ; var args = [ ] . slice . call ( arguments ) ; args . splice ( 0 , 0 , ret ) ; fun . apply ( this , args ) ; return ret ; } ; } else if ( pos === 'before' ) { this [ key ] = function ( ) { fun . apply ( this , arguments ) ; var ret = prop . apply ( this , arguments ) ; return ret ; } ; } }
basic method layering always returns original method's return value
basic method layering always returns original method s return value