diff --git a/src/mixins.ts b/src/mixins.ts index 3314d94..7f754b5 100644 --- a/src/mixins.ts +++ b/src/mixins.ts @@ -1,7 +1,7 @@ -import { proxyMix } from './proxy'; +import { proxyMix, softMixProtos } from './proxy'; import { Class, Longest } from './types'; // TODO: need something more than just Longest: also forces all to be subset of longest import { settings } from './settings'; -import { copyProps, hardMixProtos, softMixProtos } from './util'; +import { copyProps, hardMixProtos } from './util'; import { directDecoratorSearch, deepDecoratorSearch, PropertyAndMethodDecorators } from './decorator'; import { registerMixins } from './mixin-tracking'; diff --git a/src/proxy.ts b/src/proxy.ts index 5a820bc..817e4e9 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -80,3 +80,10 @@ export const proxyMix = (ingredients: any[], prototype = Object.prototype) => ne ); }, }); + +/** + * Creates a new proxy-prototype object that is a "soft" mixture of the given prototypes. The mixing is achieved by + * proxying all property access to the ingredients. This is not ES5 compatible and less performant. However, any + * changes made to the source prototypes will be reflected in the proxy-prototype, which may be desirable. + */ +export const softMixProtos = (ingredients: any[], constructor: Function): object => proxyMix([...ingredients, {constructor}]); diff --git a/src/util.ts b/src/util.ts index 265ddff..5dca296 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,5 +1,3 @@ -import { proxyMix } from './proxy'; - /** * Utility function that works like `Object.apply`, but copies getters and setters properly as well. Additionally gives * the option to exclude properties by name. @@ -82,15 +80,6 @@ export const hardMixProtos = (ingredients: any[], constructor: Function | null, return mixedProto; }; -/** - * Creates a new proxy-prototype object that is a "soft" mixture of the given prototypes. The mixing is achieved by - * proxying all property access to the ingredients. This is not ES5 compatible and less performant. However, any - * changes made to the source prototypes will be reflected in the proxy-prototype, which may be desirable. - */ -export const softMixProtos = (ingredients: any[], constructor: Function): object => { - return proxyMix([...ingredients, { constructor }]); -}; - export const unique = (arr: T[]): T[] => arr.filter((e, i) => arr.indexOf(e) == i);