Comparing version 2.0.0 to 2.1.0
@@ -83,3 +83,6 @@ (function (global, factory) { | ||
defineProperties(MixedClass, sourceClass, BASE_CLASS_PROPERTIES); | ||
defineProperties(MixedClass.prototype, sourceClass.prototype, BASE_CLASS_PROTOTYPE_PROPERTIES); | ||
// can happen if mixing instances | ||
if (sourceClass.prototype) { | ||
defineProperties(MixedClass.prototype, sourceClass.prototype, BASE_CLASS_PROTOTYPE_PROPERTIES); | ||
} | ||
} | ||
@@ -86,0 +89,0 @@ return MixedClass; |
@@ -1,2 +0,2 @@ | ||
!function(t,r){if("function"==typeof define&&define.amd)define(["exports"],r);else if("undefined"!=typeof exports)r(exports);else{var e={exports:{}};r(e.exports),t.unknown=e.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t){function r(t,o,i){return(r=e()?Reflect.construct:function(t,r,e){var o=[null];o.push.apply(o,r);var i=new(Function.bind.apply(t,o));return e&&n(i,e.prototype),i}).apply(null,arguments)}function e(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function n(t,r){return(n=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function o(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,r){if(!t)return;if("string"==typeof t)return i(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return i(t,r)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function c(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function u(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?c(Object(e),!0).forEach((function(r){a(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):c(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function a(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function f(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=Object.getOwnPropertyNames(function(){return function t(){f(this,t)}}()).concat("name"),l=["constructor"],p={constructorIndex:null,isUsingSameParamsIntoConstructors:null};function y(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e,c=y.options,a=c.isUsingSameParamsIntoConstructors,b=c.constructorIndex;null!=b&&(i=[e[b]]);var v=function t(){var e;f(this,t);for(var n=i.map((function(t){return null==t?void 0:t.name})),c=!!a||null!=b,u=arguments.length,s=new Array(u),l=0;l<u;l++)s[l]=arguments[l];for(var p=c?n:Object.keys(null!==(e=s[0])&&void 0!==e?e:{}),y=0,d=p.length;y<d;++y){var v,O=p[y],m=c?y:n.indexOf(O);-1!==m&&Object.defineProperties(this,Object.getOwnPropertyDescriptors(r(i[m],o(c?null!=s?s:[]:null!==(v=s[0][O])&&void 0!==v?v:[]))))}};y.options=u({},p);var O=e.map((function(t){return t.name})).join("");Object.defineProperty(v,"name",{value:O});for(var m=0,g=e.length;m<g;++m){var h=e[m];d(v,h,s),d(v.prototype,h.prototype,l)}return v}function d(t,r,e){for(var n=Object.getOwnPropertyDescriptors(r),o=Object.keys(n),i=0,c=o.length;i<c;++i){var u=o[i];-1===e.indexOf(u)&&Object.defineProperty(t,u,n[u])}}y.constructorIndex=null,y.options=u({},p),y.withConstructorAt=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;y.options.constructorIndex=t;for(var r=arguments.length,e=new Array(r>1?r-1:0),n=1;n<r;n++)e[n-1]=arguments[n];return y.apply(void 0,e)},y.withSameParamsIntoConstructors=function(){return y.options.isUsingSameParamsIntoConstructors=!0,y.apply(void 0,arguments)},y.withOptions=function(t){y.options=t;for(var r=arguments.length,e=new Array(r>1?r-1:0),n=1;n<r;n++)e[n-1]=arguments[n];return y.apply(void 0,e)};var b=y;t.default=b})); | ||
!function(t,r){if("function"==typeof define&&define.amd)define(["exports"],r);else if("undefined"!=typeof exports)r(exports);else{var e={exports:{}};r(e.exports),t.unknown=e.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t){function r(t,o,i){return(r=e()?Reflect.construct:function(t,r,e){var o=[null];o.push.apply(o,r);var i=new(Function.bind.apply(t,o));return e&&n(i,e.prototype),i}).apply(null,arguments)}function e(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function n(t,r){return(n=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function o(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,r){if(!t)return;if("string"==typeof t)return i(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return i(t,r)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function c(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function u(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?c(Object(e),!0).forEach((function(r){a(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):c(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function a(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function f(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=Object.getOwnPropertyNames(function(){return function t(){f(this,t)}}()).concat("name"),l=["constructor"],p={constructorIndex:null,isUsingSameParamsIntoConstructors:null};function y(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e,c=y.options,a=c.isUsingSameParamsIntoConstructors,b=c.constructorIndex;null!=b&&(i=[e[b]]);var v=function t(){var e;f(this,t);for(var n=i.map((function(t){return null==t?void 0:t.name})),c=!!a||null!=b,u=arguments.length,s=new Array(u),l=0;l<u;l++)s[l]=arguments[l];for(var p=c?n:Object.keys(null!==(e=s[0])&&void 0!==e?e:{}),y=0,d=p.length;y<d;++y){var v,O=p[y],m=c?y:n.indexOf(O);-1!==m&&Object.defineProperties(this,Object.getOwnPropertyDescriptors(r(i[m],o(c?null!=s?s:[]:null!==(v=s[0][O])&&void 0!==v?v:[]))))}};y.options=u({},p);var O=e.map((function(t){return t.name})).join("");Object.defineProperty(v,"name",{value:O});for(var m=0,g=e.length;m<g;++m){var h=e[m];d(v,h,s),h.prototype&&d(v.prototype,h.prototype,l)}return v}function d(t,r,e){for(var n=Object.getOwnPropertyDescriptors(r),o=Object.keys(n),i=0,c=o.length;i<c;++i){var u=o[i];-1===e.indexOf(u)&&Object.defineProperty(t,u,n[u])}}y.constructorIndex=null,y.options=u({},p),y.withConstructorAt=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;y.options.constructorIndex=t;for(var r=arguments.length,e=new Array(r>1?r-1:0),n=1;n<r;n++)e[n-1]=arguments[n];return y.apply(void 0,e)},y.withSameParamsIntoConstructors=function(){return y.options.isUsingSameParamsIntoConstructors=!0,y.apply(void 0,arguments)},y.withOptions=function(t){y.options=t;for(var r=arguments.length,e=new Array(r>1?r-1:0),n=1;n<r;n++)e[n-1]=arguments[n];return y.apply(void 0,e)};var b=y;t.default=b})); | ||
//# sourceMappingURL=mixmix.min.es5.js.map |
@@ -1,2 +0,2 @@ | ||
const t=Object.getOwnPropertyNames(class{}).concat("name"),o=["constructor"],n={constructorIndex:null,isUsingSameParamsIntoConstructors:null};function e(...r){let c=r;const{isUsingSameParamsIntoConstructors:i,constructorIndex:a}=e.options;null!=a&&(c=[r[a]]);class p{constructor(...t){const o=c.map((t=>t?.name)),n=!!i||null!=a,e=n?o:Object.keys(t[0]??{});for(let s=0,r=e.length;s<r;++s){const r=e[s],i=n?s:o.indexOf(r);-1!==i&&Object.defineProperties(this,Object.getOwnPropertyDescriptors(new c[i](...n?t??[]:t[0][r]??[])))}}}e.options={...n};const l=r.map((t=>t.name)).join("");Object.defineProperty(p,"name",{value:l});for(let n=0,e=r.length;n<e;++n){const e=r[n];s(p,e,t),s(p.prototype,e.prototype,o)}return p}function s(t,o,n){const e=Object.getOwnPropertyDescriptors(o),s=Object.keys(e);for(let o=0,r=s.length;o<r;++o){const r=s[o];-1===n.indexOf(r)&&Object.defineProperty(t,r,e[r])}}e.constructorIndex=null,e.options={...n},e.withConstructorAt=(t=0,...o)=>(e.options.constructorIndex=t,e(...o)),e.withSameParamsIntoConstructors=(...t)=>(e.options.isUsingSameParamsIntoConstructors=!0,e(...t)),e.withOptions=(t,...o)=>(e.options=t,e(...o));export default e; | ||
const t=Object.getOwnPropertyNames(class{}).concat("name"),o=["constructor"],n={constructorIndex:null,isUsingSameParamsIntoConstructors:null};function e(...r){let c=r;const{isUsingSameParamsIntoConstructors:i,constructorIndex:a}=e.options;null!=a&&(c=[r[a]]);class p{constructor(...t){const o=c.map((t=>t?.name)),n=!!i||null!=a,e=n?o:Object.keys(t[0]??{});for(let s=0,r=e.length;s<r;++s){const r=e[s],i=n?s:o.indexOf(r);-1!==i&&Object.defineProperties(this,Object.getOwnPropertyDescriptors(new c[i](...n?t??[]:t[0][r]??[])))}}}e.options={...n};const l=r.map((t=>t.name)).join("");Object.defineProperty(p,"name",{value:l});for(let n=0,e=r.length;n<e;++n){const e=r[n];s(p,e,t),e.prototype&&s(p.prototype,e.prototype,o)}return p}function s(t,o,n){const e=Object.getOwnPropertyDescriptors(o),s=Object.keys(e);for(let o=0,r=s.length;o<r;++o){const r=s[o];-1===n.indexOf(r)&&Object.defineProperty(t,r,e[r])}}e.constructorIndex=null,e.options={...n},e.withConstructorAt=(t=0,...o)=>(e.options.constructorIndex=t,e(...o)),e.withSameParamsIntoConstructors=(...t)=>(e.options.isUsingSameParamsIntoConstructors=!0,e(...t)),e.withOptions=(t,...o)=>(e.options=t,e(...o));export default e; | ||
//# sourceMappingURL=mixmix.min.esm.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(t="undefined"!=typeof globalThis?globalThis:t||self).mixmix=o()}(this,(function(){"use strict";const t=Object.getOwnPropertyNames(class{}).concat("name"),o=["constructor"],n={constructorIndex:null,isUsingSameParamsIntoConstructors:null};function e(...r){let c=r;const{isUsingSameParamsIntoConstructors:i,constructorIndex:u}=e.options;null!=u&&(c=[r[u]]);class l{constructor(...t){const o=c.map((t=>t?.name)),n=!!i||null!=u,e=n?o:Object.keys(t[0]??{});for(let s=0,r=e.length;s<r;++s){const r=e[s],i=n?s:o.indexOf(r);-1!==i&&Object.defineProperties(this,Object.getOwnPropertyDescriptors(new c[i](...n?t??[]:t[0][r]??[])))}}}e.options={...n};const p=r.map((t=>t.name)).join("");Object.defineProperty(l,"name",{value:p});for(let n=0,e=r.length;n<e;++n){const e=r[n];s(l,e,t),s(l.prototype,e.prototype,o)}return l}function s(t,o,n){const e=Object.getOwnPropertyDescriptors(o),s=Object.keys(e);for(let o=0,r=s.length;o<r;++o){const r=s[o];-1===n.indexOf(r)&&Object.defineProperty(t,r,e[r])}}return e.constructorIndex=null,e.options={...n},e.withConstructorAt=(t=0,...o)=>(e.options.constructorIndex=t,e(...o)),e.withSameParamsIntoConstructors=(...t)=>(e.options.isUsingSameParamsIntoConstructors=!0,e(...t)),e.withOptions=(t,...o)=>(e.options=t,e(...o)),e})); | ||
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(t="undefined"!=typeof globalThis?globalThis:t||self).mixmix=o()}(this,(function(){"use strict";const t=Object.getOwnPropertyNames(class{}).concat("name"),o=["constructor"],n={constructorIndex:null,isUsingSameParamsIntoConstructors:null};function e(...r){let c=r;const{isUsingSameParamsIntoConstructors:i,constructorIndex:p}=e.options;null!=p&&(c=[r[p]]);class u{constructor(...t){const o=c.map((t=>t?.name)),n=!!i||null!=p,e=n?o:Object.keys(t[0]??{});for(let s=0,r=e.length;s<r;++s){const r=e[s],i=n?s:o.indexOf(r);-1!==i&&Object.defineProperties(this,Object.getOwnPropertyDescriptors(new c[i](...n?t??[]:t[0][r]??[])))}}}e.options={...n};const l=r.map((t=>t.name)).join("");Object.defineProperty(u,"name",{value:l});for(let n=0,e=r.length;n<e;++n){const e=r[n];s(u,e,t),e.prototype&&s(u.prototype,e.prototype,o)}return u}function s(t,o,n){const e=Object.getOwnPropertyDescriptors(o),s=Object.keys(e);for(let o=0,r=s.length;o<r;++o){const r=s[o];-1===n.indexOf(r)&&Object.defineProperty(t,r,e[r])}}return e.constructorIndex=null,e.options={...n},e.withConstructorAt=(t=0,...o)=>(e.options.constructorIndex=t,e(...o)),e.withSameParamsIntoConstructors=(...t)=>(e.options.isUsingSameParamsIntoConstructors=!0,e(...t)),e.withOptions=(t,...o)=>(e.options=t,e(...o)),e})); | ||
//# sourceMappingURL=mixmix.min.js.map |
{ | ||
"name": "mixmix", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "mixin and mingles, for multiple classes", | ||
@@ -5,0 +5,0 @@ "main": "dist/mixmix.js", |
@@ -6,3 +6,3 @@ | ||
> (**0.4kb**, ESM version, minified & gzipped). | ||
> (**~0.5kb**, ESM version, minified & gzipped). | ||
@@ -9,0 +9,0 @@ |
@@ -95,3 +95,3 @@ const mixmix = require('../dist/mixmix.js'); | ||
.toBe(10); | ||
}) | ||
}); | ||
@@ -104,2 +104,11 @@ test('With constructor at index', () => { | ||
.toBe('007'); | ||
}) | ||
}); | ||
test('Mix instance', () => { | ||
const mixMixed = mixmix(new Sand(2, 2), new Witch('a', 'b')); | ||
expect(mixMixed.particleAmount) | ||
.toBe(4); | ||
expect(mixMixed.id) | ||
.toBe('69'); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
35106
430