Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-mixer

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-mixer - npm Package Compare versions

Comparing version 6.0.2 to 6.0.3

dist/esm/decorator.d.ts

9

CHANGELOG.md

@@ -5,2 +5,11 @@ # Changelog

### [6.0.3](https://github.com/tannerntannern/ts-mixer/compare/v6.0.2...v6.0.3) (2023-02-09)
### Bug Fixes
* allow abstract constructor signature for hasMixin ([f82e27b](https://github.com/tannerntannern/ts-mixer/commit/f82e27b96d142cfdec6446930a1db354167e88d2)), closes [tannerntannern/ts-mixer#56](https://github.com/tannerntannern/ts-mixer/issues/56)
* allow abstract constructor signatures for hasMixin ([8964b59](https://github.com/tannerntannern/ts-mixer/commit/8964b59e062854fde52424497930ca3e8bb98e87)), closes [#57](https://github.com/tannerntannern/ts-mixer/issues/57)
* simplify signature ([8a79197](https://github.com/tannerntannern/ts-mixer/commit/8a79197cc6bca5757d7c06560d7b26e73491b11f))
### [6.0.2](https://github.com/tannerntannern/ts-mixer/compare/v6.0.1...v6.0.2) (2022-11-10)

@@ -7,0 +16,0 @@

39

dist/cjs/decorator.js

@@ -8,6 +8,6 @@ "use strict";

var _a, _b;
const allKeys = util_1.unique([...Object.getOwnPropertyNames(o1), ...Object.getOwnPropertyNames(o2)]);
const allKeys = (0, util_1.unique)([...Object.getOwnPropertyNames(o1), ...Object.getOwnPropertyNames(o2)]);
const mergedObject = {};
for (let key of allKeys)
mergedObject[key] = util_1.unique([...((_a = o1 === null || o1 === void 0 ? void 0 : o1[key]) !== null && _a !== void 0 ? _a : []), ...((_b = o2 === null || o2 === void 0 ? void 0 : o2[key]) !== null && _b !== void 0 ? _b : [])]);
mergedObject[key] = (0, util_1.unique)([...((_a = o1 === null || o1 === void 0 ? void 0 : o1[key]) !== null && _a !== void 0 ? _a : []), ...((_b = o2 === null || o2 === void 0 ? void 0 : o2[key]) !== null && _b !== void 0 ? _b : [])]);
return mergedObject;

@@ -25,3 +25,3 @@ };

return ({
class: util_1.unique([...(_a = d1 === null || d1 === void 0 ? void 0 : d1.class) !== null && _a !== void 0 ? _a : [], ...(_b = d2 === null || d2 === void 0 ? void 0 : d2.class) !== null && _b !== void 0 ? _b : []]),
class: (0, util_1.unique)([...(_a = d1 === null || d1 === void 0 ? void 0 : d1.class) !== null && _a !== void 0 ? _a : [], ...(_b = d2 === null || d2 === void 0 ? void 0 : d2.class) !== null && _b !== void 0 ? _b : []]),
static: mergePropertyAndMethodDecorators((_c = d1 === null || d1 === void 0 ? void 0 : d1.static) !== null && _c !== void 0 ? _c : {}, (_d = d2 === null || d2 === void 0 ? void 0 : d2.static) !== null && _d !== void 0 ? _d : {}),

@@ -38,4 +38,4 @@ instance: mergePropertyAndMethodDecorators((_e = d1 === null || d1 === void 0 ? void 0 : d1.instance) !== null && _e !== void 0 ? _e : {}, (_f = d2 === null || d2 === void 0 ? void 0 : d2.instance) !== null && _f !== void 0 ? _f : {}),

for (let clazz of frontier) {
const protoChainClasses = util_1.protoChain(clazz.prototype).map(proto => proto.constructor);
const mixinClasses = (_a = mixin_tracking_1.getMixinsForClass(clazz)) !== null && _a !== void 0 ? _a : [];
const protoChainClasses = (0, util_1.protoChain)(clazz.prototype).map(proto => proto.constructor);
const mixinClasses = (_a = (0, mixin_tracking_1.getMixinsForClass)(clazz)) !== null && _a !== void 0 ? _a : [];
const potentiallyNewClasses = [...protoChainClasses, ...mixinClasses];

@@ -63,3 +63,3 @@ const newClasses = potentiallyNewClasses.filter(c => !allClasses.has(c));

const directDecoratorSearch = (...classes) => {
const classDecorators = classes.map(clazz => exports.getDecoratorsForClass(clazz));
const classDecorators = classes.map(clazz => (0, exports.getDecoratorsForClass)(clazz));
if (classDecorators.length === 0)

@@ -82,3 +82,3 @@ return {};

const decorateClass = (decorator) => ((clazz) => {
const decoratorsForClass = exports.getDecoratorsForClass(clazz);
const decoratorsForClass = (0, exports.getDecoratorsForClass)(clazz);
let classDecorators = decoratorsForClass.class;

@@ -93,21 +93,14 @@ if (!classDecorators) {

const decorateMember = (decorator) => ((object, key, ...otherArgs) => {
var _a, _b, _c;
const decoratorTargetType = typeof object === 'function' ? 'static' : 'instance';
const decoratorType = typeof object[key] === 'function' ? 'method' : 'property';
const clazz = decoratorTargetType === 'static' ? object : object.constructor;
const decoratorsForClass = exports.getDecoratorsForClass(clazz);
let decoratorsForTargetType = decoratorsForClass === null || decoratorsForClass === void 0 ? void 0 : decoratorsForClass[decoratorTargetType];
if (!decoratorsForTargetType) {
decoratorsForTargetType = {};
decoratorsForClass[decoratorTargetType] = decoratorsForTargetType;
}
let decoratorsForType = decoratorsForTargetType === null || decoratorsForTargetType === void 0 ? void 0 : decoratorsForTargetType[decoratorType];
if (!decoratorsForType) {
decoratorsForType = {};
decoratorsForTargetType[decoratorType] = decoratorsForType;
}
let decoratorsForKey = decoratorsForType === null || decoratorsForType === void 0 ? void 0 : decoratorsForType[key];
if (!decoratorsForKey) {
decoratorsForKey = [];
decoratorsForType[key] = decoratorsForKey;
}
const decoratorsForClass = (0, exports.getDecoratorsForClass)(clazz);
const decoratorsForTargetType = (_a = decoratorsForClass === null || decoratorsForClass === void 0 ? void 0 : decoratorsForClass[decoratorTargetType]) !== null && _a !== void 0 ? _a : {};
decoratorsForClass[decoratorTargetType] = decoratorsForTargetType;
let decoratorsForType = (_b = decoratorsForTargetType === null || decoratorsForTargetType === void 0 ? void 0 : decoratorsForTargetType[decoratorType]) !== null && _b !== void 0 ? _b : {};
decoratorsForTargetType[decoratorType] = decoratorsForType;
let decoratorsForKey = (_c = decoratorsForType === null || decoratorsForType === void 0 ? void 0 : decoratorsForType[key]) !== null && _c !== void 0 ? _c : [];
decoratorsForType[key] = decoratorsForKey;
// @ts-ignore: array is type `A[] | B[]` and item is type `A | B`, so technically a type error, but it's fine
decoratorsForKey.push(decorator);

@@ -114,0 +107,0 @@ // @ts-ignore

@@ -27,3 +27,3 @@ "use strict";

var _a;
const itemConstituents = (_a = mixins.get(item)) !== null && _a !== void 0 ? _a : util_1.protoChain(item.prototype).map(proto => proto.constructor).filter(item => item !== null);
const itemConstituents = (_a = mixins.get(item)) !== null && _a !== void 0 ? _a : (0, util_1.protoChain)(item.prototype).map(proto => proto.constructor).filter(item => item !== null);
if (itemConstituents)

@@ -30,0 +30,0 @@ itemConstituents.forEach(constituent => {

@@ -30,3 +30,3 @@ "use strict";

// @ts-ignore: potentially abstract class
util_1.copyProps(this, new constructor(...args));
(0, util_1.copyProps)(this, new constructor(...args));
if (initFunctionName !== null && typeof this[initFunctionName] === 'function')

@@ -36,12 +36,12 @@ this[initFunctionName].apply(this, args);

MixedClass.prototype = settings_1.settings.prototypeStrategy === 'copy'
? util_1.hardMixProtos(prototypes, MixedClass)
: proxy_1.softMixProtos(prototypes, MixedClass);
? (0, util_1.hardMixProtos)(prototypes, MixedClass)
: (0, proxy_1.softMixProtos)(prototypes, MixedClass);
Object.setPrototypeOf(MixedClass, settings_1.settings.staticsStrategy === 'copy'
? util_1.hardMixProtos(constructors, null, ['prototype'])
: proxy_1.proxyMix(constructors, Function.prototype));
? (0, util_1.hardMixProtos)(constructors, null, ['prototype'])
: (0, proxy_1.proxyMix)(constructors, Function.prototype));
let DecoratedMixedClass = MixedClass;
if (settings_1.settings.decoratorInheritance !== 'none') {
const classDecorators = settings_1.settings.decoratorInheritance === 'deep'
? decorator_1.deepDecoratorSearch(...constructors)
: decorator_1.directDecoratorSearch(...constructors);
? (0, decorator_1.deepDecoratorSearch)(...constructors)
: (0, decorator_1.directDecoratorSearch)(...constructors);
for (let decorator of (_a = classDecorators === null || classDecorators === void 0 ? void 0 : classDecorators.class) !== null && _a !== void 0 ? _a : []) {

@@ -56,3 +56,3 @@ const result = decorator(DecoratedMixedClass);

}
mixin_tracking_1.registerMixins(DecoratedMixedClass, constructors);
(0, mixin_tracking_1.registerMixins)(DecoratedMixedClass, constructors);
return DecoratedMixedClass;

@@ -59,0 +59,0 @@ }

@@ -10,3 +10,3 @@ "use strict";

const getIngredientWithProp = (prop, ingredients) => {
const protoChains = ingredients.map(ingredient => util_1.protoChain(ingredient));
const protoChains = ingredients.map(ingredient => (0, util_1.protoChain)(ingredient));
// since we search breadth-first, we need to keep track of our depth in the prototype chains

@@ -49,3 +49,3 @@ let protoDepth = 0;

getOwnPropertyDescriptor(_, prop) {
return Object.getOwnPropertyDescriptor(exports.getIngredientWithProp(prop, ingredients) || {}, prop);
return Object.getOwnPropertyDescriptor((0, exports.getIngredientWithProp)(prop, ingredients) || {}, prop);
},

@@ -56,9 +56,9 @@ defineProperty() {

has(_, prop) {
return exports.getIngredientWithProp(prop, ingredients) !== undefined || prototype[prop] !== undefined;
return (0, exports.getIngredientWithProp)(prop, ingredients) !== undefined || prototype[prop] !== undefined;
},
get(_, prop) {
return (exports.getIngredientWithProp(prop, ingredients) || prototype)[prop];
return ((0, exports.getIngredientWithProp)(prop, ingredients) || prototype)[prop];
},
set(_, prop, val) {
const ingredientWithProp = exports.getIngredientWithProp(prop, ingredients);
const ingredientWithProp = (0, exports.getIngredientWithProp)(prop, ingredients);
if (ingredientWithProp === undefined)

@@ -84,3 +84,3 @@ throw new Error('Cannot set new properties on Proxies created by ts-mixer');

*/
const softMixProtos = (ingredients, constructor) => exports.proxyMix([...ingredients, { constructor }]);
const softMixProtos = (ingredients, constructor) => (0, exports.proxyMix)([...ingredients, { constructor }]);
exports.softMixProtos = softMixProtos;

@@ -23,3 +23,3 @@ "use strict";

return currentChain;
return exports.protoChain(proto, [...currentChain, proto]);
return (0, exports.protoChain)(proto, [...currentChain, proto]);
};

@@ -35,3 +35,3 @@ exports.protoChain = protoChain;

let commonProto = undefined;
const protoChains = objs.map(obj => exports.protoChain(obj));
const protoChains = objs.map(obj => (0, exports.protoChain)(obj));
while (protoChains.every(protoChain => protoChain.length > 0)) {

@@ -59,3 +59,3 @@ const protos = protoChains.map(protoChain => protoChain.pop());

var _a;
const base = (_a = exports.nearestCommonProto(...ingredients)) !== null && _a !== void 0 ? _a : Object.prototype;
const base = (_a = (0, exports.nearestCommonProto)(...ingredients)) !== null && _a !== void 0 ? _a : Object.prototype;
const mixedProto = Object.create(base);

@@ -65,5 +65,5 @@ // Keeps track of prototypes we've already visited to avoid copying the same properties multiple times. We init the

// when they will already be accessible via prototype access.
const visitedProtos = exports.protoChain(base);
const visitedProtos = (0, exports.protoChain)(base);
for (let prototype of ingredients) {
let protos = exports.protoChain(prototype);
let protos = (0, exports.protoChain)(prototype);
// Apply the prototype chain in reverse order so that old methods don't override newer ones.

@@ -73,3 +73,3 @@ for (let i = protos.length - 1; i >= 0; i--) {

if (visitedProtos.indexOf(newProto) === -1) {
exports.copyProps(mixedProto, newProto, ['constructor', ...exclude]);
(0, exports.copyProps)(mixedProto, newProto, ['constructor', ...exclude]);
visitedProtos.push(newProto);

@@ -76,0 +76,0 @@ }

@@ -269,2 +269,3 @@ /**

const decorateMember = (decorator) => ((object, key, ...otherArgs) => {
var _a, _b, _c;
const decoratorTargetType = typeof object === 'function' ? 'static' : 'instance';

@@ -274,17 +275,9 @@ const decoratorType = typeof object[key] === 'function' ? 'method' : 'property';

const decoratorsForClass = getDecoratorsForClass(clazz);
let decoratorsForTargetType = decoratorsForClass === null || decoratorsForClass === void 0 ? void 0 : decoratorsForClass[decoratorTargetType];
if (!decoratorsForTargetType) {
decoratorsForTargetType = {};
decoratorsForClass[decoratorTargetType] = decoratorsForTargetType;
}
let decoratorsForType = decoratorsForTargetType === null || decoratorsForTargetType === void 0 ? void 0 : decoratorsForTargetType[decoratorType];
if (!decoratorsForType) {
decoratorsForType = {};
decoratorsForTargetType[decoratorType] = decoratorsForType;
}
let decoratorsForKey = decoratorsForType === null || decoratorsForType === void 0 ? void 0 : decoratorsForType[key];
if (!decoratorsForKey) {
decoratorsForKey = [];
decoratorsForType[key] = decoratorsForKey;
}
const decoratorsForTargetType = (_a = decoratorsForClass === null || decoratorsForClass === void 0 ? void 0 : decoratorsForClass[decoratorTargetType]) !== null && _a !== void 0 ? _a : {};
decoratorsForClass[decoratorTargetType] = decoratorsForTargetType;
let decoratorsForType = (_b = decoratorsForTargetType === null || decoratorsForTargetType === void 0 ? void 0 : decoratorsForTargetType[decoratorType]) !== null && _b !== void 0 ? _b : {};
decoratorsForTargetType[decoratorType] = decoratorsForType;
let decoratorsForKey = (_c = decoratorsForType === null || decoratorsForType === void 0 ? void 0 : decoratorsForType[key]) !== null && _c !== void 0 ? _c : [];
decoratorsForType[key] = decoratorsForKey;
// @ts-ignore: array is type `A[] | B[]` and item is type `A | B`, so technically a type error, but it's fine
decoratorsForKey.push(decorator);

@@ -291,0 +284,0 @@ // @ts-ignore

@@ -1,1 +0,1 @@

const t=(t,e,o=[])=>{const r=Object.getOwnPropertyDescriptors(e);for(let t of o)delete r[t];Object.defineProperties(t,r)},e=(t,o=[t])=>{const r=Object.getPrototypeOf(t);return null===r?o:e(r,[...o,r])},o=(o,r,n=[])=>{var l;const i=null!==(l=((...t)=>{if(0===t.length)return;let o;const r=t.map((t=>e(t)));for(;r.every((t=>t.length>0));){const t=r.map((t=>t.pop())),e=t[0];if(!t.every((t=>t===e)))break;o=e}return o})(...o))&&void 0!==l?l:Object.prototype,c=Object.create(i),s=e(i);for(let r of o){let o=e(r);for(let e=o.length-1;e>=0;e--){let r=o[e];-1===s.indexOf(r)&&(t(c,r,["constructor",...n]),s.push(r))}}return c.constructor=r,c},r=t=>t.filter(((e,o)=>t.indexOf(e)==o)),n=(t,o)=>{const r=o.map((t=>e(t)));let n=0,l=!0;for(;l;){l=!1;for(let e=o.length-1;e>=0;e--){const o=r[e][n];if(null!=o&&(l=!0,null!=Object.getOwnPropertyDescriptor(o,t)))return r[e][0]}n++}},l=(t,e=Object.prototype)=>new Proxy({},{getPrototypeOf:()=>e,setPrototypeOf(){throw Error("Cannot set prototype of Proxies created by ts-mixer")},getOwnPropertyDescriptor:(e,o)=>Object.getOwnPropertyDescriptor(n(o,t)||{},o),defineProperty(){throw new Error("Cannot define new properties on Proxies created by ts-mixer")},has:(o,r)=>void 0!==n(r,t)||void 0!==e[r],get:(o,r)=>(n(r,t)||e)[r],set(e,o,r){const l=n(o,t);if(void 0===l)throw new Error("Cannot set new properties on Proxies created by ts-mixer");return l[o]=r,!0},deleteProperty(){throw new Error("Cannot delete properties on Proxies created by ts-mixer")},ownKeys:()=>t.map(Object.getOwnPropertyNames).reduce(((t,e)=>e.concat(t.filter((t=>e.indexOf(t)<0)))))}),i={initFunction:null,staticsStrategy:"copy",prototypeStrategy:"copy",decoratorInheritance:"deep"},c=new Map,s=t=>c.get(t),p=(t,o)=>{if(t instanceof o)return!0;const r=t.constructor,n=new Set;let l=new Set;for(l.add(r);l.size>0;){if(l.has(o))return!0;l.forEach((t=>n.add(t)));const t=new Set;l.forEach((o=>{var r;const i=null!==(r=c.get(o))&&void 0!==r?r:e(o.prototype).map((t=>t.constructor)).filter((t=>null!==t));i&&i.forEach((e=>{n.has(e)||l.has(e)||t.add(e)}))})),l=t}return!1},u=(t,e)=>{var o,n;const l=r([...Object.getOwnPropertyNames(t),...Object.getOwnPropertyNames(e)]),i={};for(let c of l)i[c]=r([...null!==(o=null==t?void 0:t[c])&&void 0!==o?o:[],...null!==(n=null==e?void 0:e[c])&&void 0!==n?n:[]]);return i},a=(t,e)=>{var o,r,n,l;return{property:u(null!==(o=null==t?void 0:t.property)&&void 0!==o?o:{},null!==(r=null==e?void 0:e.property)&&void 0!==r?r:{}),method:u(null!==(n=null==t?void 0:t.method)&&void 0!==n?n:{},null!==(l=null==e?void 0:e.method)&&void 0!==l?l:{})}},d=(t,e)=>{var o,n,l,i,c,s;return{class:r([...null!==(o=null==t?void 0:t.class)&&void 0!==o?o:[],...null!==(n=null==e?void 0:e.class)&&void 0!==n?n:[]]),static:a(null!==(l=null==t?void 0:t.static)&&void 0!==l?l:{},null!==(i=null==e?void 0:e.static)&&void 0!==i?i:{}),instance:a(null!==(c=null==t?void 0:t.instance)&&void 0!==c?c:{},null!==(s=null==e?void 0:e.instance)&&void 0!==s?s:{})}},f=new Map,y=(...t)=>{const o=((...t)=>{var o;const r=new Set,n=new Set([...t]);for(;n.size>0;)for(let t of n){const l=[...e(t.prototype).map((t=>t.constructor)),...null!==(o=s(t))&&void 0!==o?o:[]].filter((t=>!r.has(t)));for(let t of l)n.add(t);r.add(t),n.delete(t)}return[...r]})(...t).map((t=>f.get(t))).filter((t=>!!t));return 0==o.length?{}:1==o.length?o[0]:o.reduce(((t,e)=>d(t,e)))},v=t=>{let e=f.get(t);return e||(e={},f.set(t,e)),e},h=t=>(...e)=>1===e.length?(t=>e=>{const o=v(e);let r=o.class;return r||(r=[],o.class=r),r.push(t),t(e)})(t)(e[0]):(t=>(e,o,...r)=>{const n="function"==typeof e?"static":"instance",l="function"==typeof e[o]?"method":"property",i="static"===n?e:e.constructor,c=v(i);let s=null==c?void 0:c[n];s||(s={},c[n]=s);let p=null==s?void 0:s[l];p||(p={},s[l]=p);let u=null==p?void 0:p[o];return u||(u=[],p[o]=u),u.push(t),t(e,o,...r)})(t)(...e);function O(...e){var r,n,s;const p=e.map((t=>t.prototype)),u=i.initFunction;if(null!==u){const t=p.map((t=>t[u])).filter((t=>"function"==typeof t)),e={[u]:function(...e){for(let o of t)o.apply(this,e)}};p.push(e)}function a(...o){for(const r of e)t(this,new r(...o));null!==u&&"function"==typeof this[u]&&this[u].apply(this,o)}var f,h;a.prototype="copy"===i.prototypeStrategy?o(p,a):(f=p,h=a,l([...f,{constructor:h}])),Object.setPrototypeOf(a,"copy"===i.staticsStrategy?o(e,null,["prototype"]):l(e,Function.prototype));let O=a;if("none"!==i.decoratorInheritance){const t="deep"===i.decoratorInheritance?y(...e):((...t)=>{const e=t.map((t=>v(t)));return 0===e.length?{}:1===e.length?e[0]:e.reduce(((t,e)=>d(t,e)))})(...e);for(let e of null!==(r=null==t?void 0:t.class)&&void 0!==r?r:[]){const t=e(O);t&&(O=t)}g(null!==(n=null==t?void 0:t.static)&&void 0!==n?n:{},O),g(null!==(s=null==t?void 0:t.instance)&&void 0!==s?s:{},O.prototype)}var w,m;return w=O,m=e,c.set(w,m),O}const g=(t,e)=>{const o=t.property,r=t.method;if(o)for(let t in o)for(let r of o[t])r(e,t);if(r)for(let t in r)for(let o of r[t])o(e,t,Object.getOwnPropertyDescriptor(e,t))},w=(...t)=>e=>{const o=O(...t.concat([e]));return Object.defineProperty(o,"name",{value:e.name,writable:!1}),o};export{O as Mixin,h as decorate,p as hasMixin,w as mix,i as settings};
const t=(t,e,o=[])=>{const r=Object.getOwnPropertyDescriptors(e);for(let t of o)delete r[t];Object.defineProperties(t,r)},e=(t,o=[t])=>{const r=Object.getPrototypeOf(t);return null===r?o:e(r,[...o,r])},o=(o,r,n=[])=>{var l;const i=null!==(l=((...t)=>{if(0===t.length)return;let o;const r=t.map((t=>e(t)));for(;r.every((t=>t.length>0));){const t=r.map((t=>t.pop())),e=t[0];if(!t.every((t=>t===e)))break;o=e}return o})(...o))&&void 0!==l?l:Object.prototype,c=Object.create(i),s=e(i);for(let r of o){let o=e(r);for(let e=o.length-1;e>=0;e--){let r=o[e];-1===s.indexOf(r)&&(t(c,r,["constructor",...n]),s.push(r))}}return c.constructor=r,c},r=t=>t.filter(((e,o)=>t.indexOf(e)==o)),n=(t,o)=>{const r=o.map((t=>e(t)));let n=0,l=!0;for(;l;){l=!1;for(let e=o.length-1;e>=0;e--){const o=r[e][n];if(null!=o&&(l=!0,null!=Object.getOwnPropertyDescriptor(o,t)))return r[e][0]}n++}},l=(t,e=Object.prototype)=>new Proxy({},{getPrototypeOf:()=>e,setPrototypeOf(){throw Error("Cannot set prototype of Proxies created by ts-mixer")},getOwnPropertyDescriptor:(e,o)=>Object.getOwnPropertyDescriptor(n(o,t)||{},o),defineProperty(){throw new Error("Cannot define new properties on Proxies created by ts-mixer")},has:(o,r)=>void 0!==n(r,t)||void 0!==e[r],get:(o,r)=>(n(r,t)||e)[r],set(e,o,r){const l=n(o,t);if(void 0===l)throw new Error("Cannot set new properties on Proxies created by ts-mixer");return l[o]=r,!0},deleteProperty(){throw new Error("Cannot delete properties on Proxies created by ts-mixer")},ownKeys:()=>t.map(Object.getOwnPropertyNames).reduce(((t,e)=>e.concat(t.filter((t=>e.indexOf(t)<0)))))}),i={initFunction:null,staticsStrategy:"copy",prototypeStrategy:"copy",decoratorInheritance:"deep"},c=new Map,s=t=>c.get(t),p=(t,o)=>{if(t instanceof o)return!0;const r=t.constructor,n=new Set;let l=new Set;for(l.add(r);l.size>0;){if(l.has(o))return!0;l.forEach((t=>n.add(t)));const t=new Set;l.forEach((o=>{var r;const i=null!==(r=c.get(o))&&void 0!==r?r:e(o.prototype).map((t=>t.constructor)).filter((t=>null!==t));i&&i.forEach((e=>{n.has(e)||l.has(e)||t.add(e)}))})),l=t}return!1},u=(t,e)=>{var o,n;const l=r([...Object.getOwnPropertyNames(t),...Object.getOwnPropertyNames(e)]),i={};for(let c of l)i[c]=r([...null!==(o=null==t?void 0:t[c])&&void 0!==o?o:[],...null!==(n=null==e?void 0:e[c])&&void 0!==n?n:[]]);return i},a=(t,e)=>{var o,r,n,l;return{property:u(null!==(o=null==t?void 0:t.property)&&void 0!==o?o:{},null!==(r=null==e?void 0:e.property)&&void 0!==r?r:{}),method:u(null!==(n=null==t?void 0:t.method)&&void 0!==n?n:{},null!==(l=null==e?void 0:e.method)&&void 0!==l?l:{})}},d=(t,e)=>{var o,n,l,i,c,s;return{class:r([...null!==(o=null==t?void 0:t.class)&&void 0!==o?o:[],...null!==(n=null==e?void 0:e.class)&&void 0!==n?n:[]]),static:a(null!==(l=null==t?void 0:t.static)&&void 0!==l?l:{},null!==(i=null==e?void 0:e.static)&&void 0!==i?i:{}),instance:a(null!==(c=null==t?void 0:t.instance)&&void 0!==c?c:{},null!==(s=null==e?void 0:e.instance)&&void 0!==s?s:{})}},f=new Map,v=(...t)=>{const o=((...t)=>{var o;const r=new Set,n=new Set([...t]);for(;n.size>0;)for(let t of n){const l=[...e(t.prototype).map((t=>t.constructor)),...null!==(o=s(t))&&void 0!==o?o:[]].filter((t=>!r.has(t)));for(let t of l)n.add(t);r.add(t),n.delete(t)}return[...r]})(...t).map((t=>f.get(t))).filter((t=>!!t));return 0==o.length?{}:1==o.length?o[0]:o.reduce(((t,e)=>d(t,e)))},y=t=>{let e=f.get(t);return e||(e={},f.set(t,e)),e},h=t=>(...e)=>1===e.length?(t=>e=>{const o=y(e);let r=o.class;return r||(r=[],o.class=r),r.push(t),t(e)})(t)(e[0]):(t=>(e,o,...r)=>{var n,l,i;const c="function"==typeof e?"static":"instance",s="function"==typeof e[o]?"method":"property",p="static"===c?e:e.constructor,u=y(p),a=null!==(n=null==u?void 0:u[c])&&void 0!==n?n:{};u[c]=a;let d=null!==(l=null==a?void 0:a[s])&&void 0!==l?l:{};a[s]=d;let f=null!==(i=null==d?void 0:d[o])&&void 0!==i?i:[];return d[o]=f,f.push(t),t(e,o,...r)})(t)(...e);function O(...e){var r,n,s;const p=e.map((t=>t.prototype)),u=i.initFunction;if(null!==u){const t=p.map((t=>t[u])).filter((t=>"function"==typeof t)),e={[u]:function(...e){for(let o of t)o.apply(this,e)}};p.push(e)}function a(...o){for(const r of e)t(this,new r(...o));null!==u&&"function"==typeof this[u]&&this[u].apply(this,o)}var f,h;a.prototype="copy"===i.prototypeStrategy?o(p,a):(f=p,h=a,l([...f,{constructor:h}])),Object.setPrototypeOf(a,"copy"===i.staticsStrategy?o(e,null,["prototype"]):l(e,Function.prototype));let O=a;if("none"!==i.decoratorInheritance){const t="deep"===i.decoratorInheritance?v(...e):((...t)=>{const e=t.map((t=>y(t)));return 0===e.length?{}:1===e.length?e[0]:e.reduce(((t,e)=>d(t,e)))})(...e);for(let e of null!==(r=null==t?void 0:t.class)&&void 0!==r?r:[]){const t=e(O);t&&(O=t)}g(null!==(n=null==t?void 0:t.static)&&void 0!==n?n:{},O),g(null!==(s=null==t?void 0:t.instance)&&void 0!==s?s:{},O.prototype)}var w,m;return w=O,m=e,c.set(w,m),O}const g=(t,e)=>{const o=t.property,r=t.method;if(o)for(let t in o)for(let r of o[t])r(e,t);if(r)for(let t in r)for(let o of r[t])o(e,t,Object.getOwnPropertyDescriptor(e,t))},w=(...t)=>e=>{const o=O(...t.concat([e]));return Object.defineProperty(o,"name",{value:e.name,writable:!1}),o};export{O as Mixin,h as decorate,p as hasMixin,w as mix,i as settings};
import { Class } from './types';
declare type ObjectOfDecorators<T extends PropertyDecorator | MethodDecorator> = {
type ObjectOfDecorators<T extends PropertyDecorator | MethodDecorator> = {
[key: string]: T[];
};
export declare type PropertyAndMethodDecorators = {
export type PropertyAndMethodDecorators = {
property?: ObjectOfDecorators<PropertyDecorator>;
method?: ObjectOfDecorators<MethodDecorator>;
};
declare type Decorators = {
type Decorators = {
class?: ClassDecorator[];

@@ -11,0 +11,0 @@ static?: PropertyAndMethodDecorators;

import { Class } from './types';
export declare const getMixinsForClass: (clazz: Class) => Function[] | undefined;
export declare const registerMixins: (mixedClass: any, constituents: Function[]) => Map<any, Function[]>;
export declare const hasMixin: <M>(instance: any, mixin: new (...args: any[]) => M) => instance is M;
export declare const hasMixin: <M>(instance: any, mixin: abstract new (...args: any[]) => M) => instance is M;

@@ -1,2 +0,2 @@

export declare type Settings = {
export type Settings = {
initFunction: string | null;

@@ -3,0 +3,0 @@ staticsStrategy: 'copy' | 'proxy';

/**
* Returns the longer of the two tuples. Indefinite tuples will always be considered longest.
*/
declare type _Longest<T1 extends any[], T2 extends any[]> = any[] extends T1 ? T1 : any[] extends T2 ? T2 : Exclude<keyof T1, keyof T2> extends never ? T2 : T1;
type _Longest<T1 extends any[], T2 extends any[]> = any[] extends T1 ? T1 : any[] extends T2 ? T2 : Exclude<keyof T1, keyof T2> extends never ? T2 : T1;
/**
* Returns the longest of up to 10 different tuples.
*/
export declare type Longest<T1 extends any[], T2 extends any[] = [], T3 extends any[] = [], T4 extends any[] = [], T5 extends any[] = [], T6 extends any[] = [], T7 extends any[] = [], T8 extends any[] = [], T9 extends any[] = [], T10 extends any[] = []> = _Longest<_Longest<_Longest<_Longest<T1, T2>, _Longest<T3, T4>>, _Longest<_Longest<T5, T6>, _Longest<T7, T8>>>, _Longest<T9, T10>>;
export type Longest<T1 extends any[], T2 extends any[] = [], T3 extends any[] = [], T4 extends any[] = [], T5 extends any[] = [], T6 extends any[] = [], T7 extends any[] = [], T8 extends any[] = [], T9 extends any[] = [], T10 extends any[] = []> = _Longest<_Longest<_Longest<_Longest<T1, T2>, _Longest<T3, T4>>, _Longest<_Longest<T5, T6>, _Longest<T7, T8>>>, _Longest<T9, T10>>;
/**
* A rigorous type alias for a class.
*/
export declare type Class<CtorArgs extends any[] = any[], InstanceType = {}, StaticType = {}, IsAbstract = false> = (abstract new (...args: any[]) => InstanceType) & StaticType;
export type Class<CtorArgs extends any[] = any[], InstanceType = {}, StaticType = {}, IsAbstract = false> = (abstract new (...args: any[]) => InstanceType) & StaticType;
export {};
{
"name": "ts-mixer",
"version": "6.0.2",
"version": "6.0.3",
"description": "A very small TypeScript library that provides tolerable Mixin functionality.",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

# ts-mixer
[version-badge]: https://badgen.net/npm/v/ts-mixer
[version-link]: https://npmjs.com/package/ts-mixer
[build-badge]: https://img.shields.io/github/workflow/status/tannerntannern/ts-mixer/ts-mixer%20CI
[build-link]: https://github.com/tannerntannern/ts-mixer/actions
[ts-versions]: https://badgen.net/badge/icon/4.2,4.3?icon=typescript&label&list=|
[node-versions]: https://badgen.net/badge/node/10%2C12%2C14/blue/?list=|
[ts-versions]: https://badgen.net/badge/icon/4.2,4.4,4.6,4.8?icon=typescript&label&list=|
[node-versions]: https://badgen.net/badge/node/12%2C14%2C16%2C18/blue/?list=|
[![npm version][version-badge]][version-link]
[![github actions][build-badge]][build-link]
[![TS Versions][ts-versions]][build-link]

@@ -11,0 +9,0 @@ [![Node.js Versions][node-versions]][build-link]

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc