Sha256: b47188a533c8b489873d24f81f42889877400350d84535eef35eb87543770b2a
Contents?: true
Size: 1.69 KB
Versions: 167
Compression:
Stored size: 1.69 KB
Contents
var $, advice, mixin; $ = require('jquery'); advice = { around: function(base, wrapped) { return function() { var args; args = $.makeArray(arguments); return wrapped.apply(this, [$.proxy(base, this)].concat(args)); }; }, before: function(base, before) { return this.around(base, function() { var args, orig; args = $.makeArray(arguments); orig = args.shift(); before.apply(this, args); return orig.apply(this, args); }); }, after: function(base, after) { return this.around(base, function() { var args, orig, res; args = $.makeArray(arguments); orig = args.shift(); res = orig.apply(this, args); after.apply(this, args); return res; }); } }; mixin = { before: function(method, advicer) { if (typeof this[method] === 'function') { return this[method] = advice.before(this[method], advicer); } throw new TypeError("Can only advice functions, attribute " + method + " of " + this + " is of type " + (typeof this[method])); }, after: function(method, advicer) { if (typeof this[method] === 'function') { return this[method] = advice.after(this[method], advicer); } throw new TypeError("Can only advice functions, attribute " + method + " of " + this + " is of type " + (typeof this[method])); }, around: function(method, advicer) { if (typeof this[method] === 'function') { return this[method] = advice.around(this[method], advicer); } throw new TypeError("Can only advice functions, attribute " + method + " of " + this + " is of type " + (typeof this[method])); } }; exports.mixin = function(object) { return $.extend(object, mixin); };
Version data entries
167 entries across 94 versions & 1 rubygems