Comparing version 1.0.1 to 1.0.2
@@ -0,1 +1,5 @@ | ||
## 1.0.2 (2016-11-17) | ||
- Optimize function calls by avoiding passing the `arguments` object around. | ||
## 1.0.1 (2015-01-28) | ||
@@ -2,0 +6,0 @@ |
@@ -6,2 +6,2 @@ /*! | ||
*/ | ||
!function(n){var t=n(require("underscore"));module.exports=t}(function(n){function t(){this.mixins=n.initial(arguments),this.properties=n.last(arguments)}function e(n,t){this.applyTo=function(e){n.applyTo(e,t)}}function r(n,t){return null==n?t.slice():i(s(n),t)}function i(t,e){return t.concat(n.difference(e,t))}function o(n,t){return null==n?t:r(a(n),a(t)).join(" ")}function u(t,e){return n.extend({},e,t)}function a(t){return n.compact(t.split(p))}function s(t){return n.isArray(t)?t:[t]}var f=["before","after","around","requires","override","defaults","applyTo","requirePrototype","merge"],p=/\s+/;return n.extend(t.prototype,{applyTo:function(t,e){var r=this.properties;this.defaults(t,r.defaults),this.extend(t,r),this.merge(t,r.merge),n.invoke(this.mixins,"applyTo",t),["requires","requirePrototype","override","before","after","around"].forEach(function(n){this[n](t,r[n])},this),r.applyTo&&r.applyTo.call(this,t,e)},withOptions:function(n){return new e(this,n)},before:function(t,e){n.each(e,function(n,e){var r=t[e];t[e]=function(){return n.apply(this,arguments),r.apply(this,arguments)}})},after:function(t,e){n.each(e,function(n,e){var r=t[e];t[e]=function(){var t=r.apply(this,arguments);return n.apply(this,arguments),t}})},around:function(t,e){n.each(e,function(n,e){var r=t[e];t[e]=function(){var t=0,e=arguments.length,i=Array(e+1);for(i[0]=r.bind(this);e>t;++t)i[t+1]=arguments[t];return n.apply(this,i)}})},override:function(t,e){n.extend(t,e)},defaults:function(t,e){n.each(e,function(n,e){t.hasOwnProperty(e)||(t[e]=n)})},merge:function(t,e){n.each(e,function(e,i){if(null!=e){var a=t[i];t[i]=n.isArray(e)?r(a,e):n.isString(e)?o(a,e):u(a,e)}})},extend:function(t,e){var r=n.omit(e,f);n.extend(t,r)},requires:n.noop,requirePrototype:n.noop}),e.prototype=t.prototype,t}); | ||
!function(t){var n=t(require("underscore"));module.exports=n}(function(t){function n(){this.mixins=t.initial(arguments),this.properties=t.last(arguments)}function r(t,n){this.applyTo=function(r){t.applyTo(r,n)}}function e(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2]);case 4:return t.call(n,r[0],r[1],r[2],r[3]);default:return t.apply(n,r)}}function i(t,n){return null==t?n.slice():o(c(t),n)}function o(n,r){return n.concat(t.difference(r,n))}function u(t,n){return null==t?n:i(s(t),s(n)).join(" ")}function a(n,r){return t.extend({},r,n)}function s(n){return t.compact(n.split(l))}function c(n){return t.isArray(n)?n:[n]}var f=["before","after","around","requires","override","defaults","applyTo","requirePrototype","merge"],l=/\s+/;return t.extend(n.prototype,{applyTo:function(n,r){var e=this.properties;this.defaults(n,e.defaults),this.extend(n,e),this.merge(n,e.merge),t.invoke(this.mixins,"applyTo",n),["requires","requirePrototype","override","before","after","around"].forEach(function(t){this[t](n,e[t])},this),e.applyTo&&e.applyTo.call(this,n,r)},withOptions:function(t){return new r(this,t)},before:function(n,r){t.each(r,function(t,r){var i=n[r];n[r]=function(){for(var n=Array(arguments.length),r=0;r<arguments.length;++r)n[r]=arguments[r];return e(t,this,n),e(i,this,n)}})},after:function(n,r){t.each(r,function(t,r){var i=n[r];n[r]=function(){for(var n=Array(arguments.length),r=0;r<arguments.length;++r)n[r]=arguments[r];var o=e(i,this,n);return e(t,this,n),o}})},around:function(n,r){t.each(r,function(t,r){var i=n[r];n[r]=function(){var n=0,r=arguments.length,o=Array(r+1);for(o[0]=i.bind(this);r>n;++n)o[n+1]=arguments[n];return e(t,this,o)}})},override:function(n,r){t.extend(n,r)},defaults:function(n,r){t.each(r,function(t,r){n.hasOwnProperty(r)||(n[r]=t)})},merge:function(n,r){t.each(r,function(r,e){if(null!=r){var o=n[e];n[e]=t.isArray(r)?i(o,r):t.isString(r)?u(o,r):a(o,r)}})},extend:function(n,r){var e=t.omit(r,f);t.extend(n,e)},requires:t.noop,requirePrototype:t.noop}),r.prototype=n.prototype,n}); |
@@ -19,2 +19,23 @@ /*! | ||
} | ||
function exec(fn, context, args) { | ||
switch (args.length) { | ||
case 0: | ||
return fn.call(context); | ||
case 1: | ||
return fn.call(context, args[0]); | ||
case 2: | ||
return fn.call(context, args[0], args[1]); | ||
case 3: | ||
return fn.call(context, args[0], args[1], args[2]); | ||
case 4: | ||
return fn.call(context, args[0], args[1], args[2], args[3]); | ||
default: | ||
return fn.apply(context, args); | ||
} | ||
} | ||
/** | ||
@@ -111,4 +132,7 @@ * Combine two arrays, ensuring uniqueness of the new values being added. | ||
obj[prop] = function() { | ||
modifierFn.apply(this, arguments); | ||
return origFn.apply(this, arguments); | ||
for (var args = new Array(arguments.length), i = 0; i < arguments.length; ++i) { | ||
args[i] = arguments[i]; | ||
} | ||
exec(modifierFn, this, args); | ||
return exec(origFn, this, args); | ||
}; | ||
@@ -123,4 +147,7 @@ }); | ||
obj[prop] = function() { | ||
var ret = origFn.apply(this, arguments); | ||
modifierFn.apply(this, arguments); | ||
for (var args = new Array(arguments.length), i = 0; i < arguments.length; ++i) { | ||
args[i] = arguments[i]; | ||
} | ||
var ret = exec(origFn, this, args); | ||
exec(modifierFn, this, args); | ||
return ret; | ||
@@ -141,3 +168,3 @@ }; | ||
} | ||
return modifierFn.apply(this, args); | ||
return exec(modifierFn, this, args); | ||
}; | ||
@@ -144,0 +171,0 @@ }); |
@@ -24,2 +24,23 @@ /*! | ||
} | ||
function exec(fn, context, args) { | ||
switch (args.length) { | ||
case 0: | ||
return fn.call(context); | ||
case 1: | ||
return fn.call(context, args[0]); | ||
case 2: | ||
return fn.call(context, args[0], args[1]); | ||
case 3: | ||
return fn.call(context, args[0], args[1], args[2]); | ||
case 4: | ||
return fn.call(context, args[0], args[1], args[2], args[3]); | ||
default: | ||
return fn.apply(context, args); | ||
} | ||
} | ||
/** | ||
@@ -116,4 +137,7 @@ * Combine two arrays, ensuring uniqueness of the new values being added. | ||
obj[prop] = function() { | ||
modifierFn.apply(this, arguments); | ||
return origFn.apply(this, arguments); | ||
for (var args = new Array(arguments.length), i = 0; i < arguments.length; ++i) { | ||
args[i] = arguments[i]; | ||
} | ||
exec(modifierFn, this, args); | ||
return exec(origFn, this, args); | ||
}; | ||
@@ -128,4 +152,7 @@ }); | ||
obj[prop] = function() { | ||
var ret = origFn.apply(this, arguments); | ||
modifierFn.apply(this, arguments); | ||
for (var args = new Array(arguments.length), i = 0; i < arguments.length; ++i) { | ||
args[i] = arguments[i]; | ||
} | ||
var ret = exec(origFn, this, args); | ||
exec(modifierFn, this, args); | ||
return ret; | ||
@@ -146,3 +173,3 @@ }; | ||
} | ||
return modifierFn.apply(this, args); | ||
return exec(modifierFn, this, args); | ||
}; | ||
@@ -149,0 +176,0 @@ }); |
@@ -6,2 +6,2 @@ /*! | ||
*/ | ||
!function(n){var t,e=this,r=n;t=e.Remixin,e.Remixin=r,r.noConflict=function(){return e.Remixin=t,r}}(function(n){function t(){this.mixins=n.initial(arguments),this.properties=n.last(arguments)}function e(n,t){this.applyTo=function(e){n.applyTo(e,t)}}function r(n,t){return null==n?t.slice():i(s(n),t)}function i(t,e){return t.concat(n.difference(e,t))}function o(n,t){return null==n?t:r(a(n),a(t)).join(" ")}function u(t,e){return n.extend({},e,t)}function a(t){return n.compact(t.split(c))}function s(t){return n.isArray(t)?t:[t]}var f=["before","after","around","requires","override","defaults","applyTo","requirePrototype","merge"],c=/\s+/;return n.extend(t.prototype,{applyTo:function(t,e){var r=this.properties;this.defaults(t,r.defaults),this.extend(t,r),this.merge(t,r.merge),n.invoke(this.mixins,"applyTo",t),["requires","requirePrototype","override","before","after","around"].forEach(function(n){this[n](t,r[n])},this),r.applyTo&&r.applyTo.call(this,t,e)},withOptions:function(n){return new e(this,n)},before:function(t,e){n.each(e,function(n,e){var r=t[e];t[e]=function(){return n.apply(this,arguments),r.apply(this,arguments)}})},after:function(t,e){n.each(e,function(n,e){var r=t[e];t[e]=function(){var t=r.apply(this,arguments);return n.apply(this,arguments),t}})},around:function(t,e){n.each(e,function(n,e){var r=t[e];t[e]=function(){var t=0,e=arguments.length,i=Array(e+1);for(i[0]=r.bind(this);e>t;++t)i[t+1]=arguments[t];return n.apply(this,i)}})},override:function(t,e){n.extend(t,e)},defaults:function(t,e){n.each(e,function(n,e){t.hasOwnProperty(e)||(t[e]=n)})},merge:function(t,e){n.each(e,function(e,i){if(null!=e){var a=t[i];t[i]=n.isArray(e)?r(a,e):n.isString(e)?o(a,e):u(a,e)}})},extend:function(t,e){var r=n.omit(e,f);n.extend(t,r)},requires:n.noop,requirePrototype:n.noop}),e.prototype=t.prototype,t}); | ||
!function(n){var t,r=this,e=n;t=r.Remixin,r.Remixin=e,e.noConflict=function(){return r.Remixin=t,e}}(function(n){function t(){this.mixins=n.initial(arguments),this.properties=n.last(arguments)}function r(n,t){this.applyTo=function(r){n.applyTo(r,t)}}function e(n,t,r){switch(r.length){case 0:return n.call(t);case 1:return n.call(t,r[0]);case 2:return n.call(t,r[0],r[1]);case 3:return n.call(t,r[0],r[1],r[2]);case 4:return n.call(t,r[0],r[1],r[2],r[3]);default:return n.apply(t,r)}}function i(n,t){return null==n?t.slice():o(s(n),t)}function o(t,r){return t.concat(n.difference(r,t))}function u(n,t){return null==n?t:i(c(n),c(t)).join(" ")}function a(t,r){return n.extend({},r,t)}function c(t){return n.compact(t.split(l))}function s(t){return n.isArray(t)?t:[t]}var f=["before","after","around","requires","override","defaults","applyTo","requirePrototype","merge"],l=/\s+/;return n.extend(t.prototype,{applyTo:function(t,r){var e=this.properties;this.defaults(t,e.defaults),this.extend(t,e),this.merge(t,e.merge),n.invoke(this.mixins,"applyTo",t),["requires","requirePrototype","override","before","after","around"].forEach(function(n){this[n](t,e[n])},this),e.applyTo&&e.applyTo.call(this,t,r)},withOptions:function(n){return new r(this,n)},before:function(t,r){n.each(r,function(n,r){var i=t[r];t[r]=function(){for(var t=Array(arguments.length),r=0;r<arguments.length;++r)t[r]=arguments[r];return e(n,this,t),e(i,this,t)}})},after:function(t,r){n.each(r,function(n,r){var i=t[r];t[r]=function(){for(var t=Array(arguments.length),r=0;r<arguments.length;++r)t[r]=arguments[r];var o=e(i,this,t);return e(n,this,t),o}})},around:function(t,r){n.each(r,function(n,r){var i=t[r];t[r]=function(){var t=0,r=arguments.length,o=Array(r+1);for(o[0]=i.bind(this);r>t;++t)o[t+1]=arguments[t];return e(n,this,o)}})},override:function(t,r){n.extend(t,r)},defaults:function(t,r){n.each(r,function(n,r){t.hasOwnProperty(r)||(t[r]=n)})},merge:function(t,r){n.each(r,function(r,e){if(null!=r){var o=t[e];t[e]=n.isArray(r)?i(o,r):n.isString(r)?u(o,r):a(o,r)}})},extend:function(t,r){var e=n.omit(r,f);n.extend(t,e)},requires:n.noop,requirePrototype:n.noop}),r.prototype=t.prototype,t}); |
{ | ||
"name": "remixin", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Aspect-oriented, mixin library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,2 +7,8 @@ ## Remixin | ||
## Installation | ||
npm install remixin | ||
...or clone this repository and use the files in `/dist` as described below. | ||
## Setup | ||
@@ -9,0 +15,0 @@ |
@@ -66,4 +66,6 @@ /*! | ||
obj[prop] = function () { | ||
modifierFn.apply(this, arguments); | ||
return origFn.apply(this, arguments); | ||
var args = new Array(arguments.length); | ||
for (var i = 0; i < arguments.length; ++i) args[i] = arguments[i]; | ||
exec(modifierFn, this, args); | ||
return exec(origFn, this, args); | ||
}; | ||
@@ -81,4 +83,6 @@ }); | ||
obj[prop] = function () { | ||
var ret = origFn.apply(this, arguments); | ||
modifierFn.apply(this, arguments); | ||
var args = new Array(arguments.length); | ||
for (var i = 0; i < arguments.length; ++i) args[i] = arguments[i]; | ||
var ret = exec(origFn, this, args); | ||
exec(modifierFn, this, args); | ||
return ret; | ||
@@ -98,12 +102,11 @@ }; | ||
obj[prop] = function () { | ||
var i = 0, | ||
l = arguments.length, | ||
args = new Array(l + 1); | ||
var l = arguments.length; | ||
var args = new Array(l + 1); | ||
args[0] = origFn.bind(this); | ||
for (; i < l; ++i) { | ||
for (var i = 0; i < l; ++i) { | ||
args[i + 1] = arguments[i]; | ||
} | ||
return modifierFn.apply(this, args); | ||
return exec(modifierFn, this, args); | ||
}; | ||
@@ -192,2 +195,13 @@ }); | ||
function exec(fn, context, args) { | ||
switch (args.length) { | ||
case 0: return fn.call(context); | ||
case 1: return fn.call(context, args[0]); | ||
case 2: return fn.call(context, args[0], args[1]); | ||
case 3: return fn.call(context, args[0], args[1], args[2]); | ||
case 4: return fn.call(context, args[0], args[1], args[2], args[3]); | ||
default: return fn.apply(context, args); | ||
} | ||
} | ||
/** | ||
@@ -194,0 +208,0 @@ * Combine two arrays, ensuring uniqueness of the new values being added. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65896
1470
207