Skip to content

Commit

Permalink
fix: circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimio committed Apr 19, 2021
1 parent 0010c82 commit 66f7e2d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/mixins.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
7 changes: 7 additions & 0 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}]);
11 changes: 0 additions & 11 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 = <T>(arr: T[]): T[] =>
arr.filter((e, i) => arr.indexOf(e) == i);

Expand Down

0 comments on commit 66f7e2d

Please sign in to comment.