commit
This commit is contained in:
parent
68f4b60012
commit
41ae7ff4bd
1010 changed files with 38622 additions and 17071 deletions
12
node_modules/ts-mixer/dist/cjs/util.js
generated
vendored
12
node_modules/ts-mixer/dist/cjs/util.js
generated
vendored
|
@ -20,7 +20,7 @@ const protoChain = (obj, currentChain = [obj]) => {
|
|||
const proto = Object.getPrototypeOf(obj);
|
||||
if (proto === null)
|
||||
return currentChain;
|
||||
return exports.protoChain(proto, [...currentChain, proto]);
|
||||
return (0, exports.protoChain)(proto, [...currentChain, proto]);
|
||||
};
|
||||
exports.protoChain = protoChain;
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ const nearestCommonProto = (...objs) => {
|
|||
if (objs.length === 0)
|
||||
return undefined;
|
||||
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)) {
|
||||
const protos = protoChains.map(protoChain => protoChain.pop());
|
||||
const potentialCommonProto = protos[0];
|
||||
|
@ -54,19 +54,19 @@ exports.nearestCommonProto = nearestCommonProto;
|
|||
*/
|
||||
const hardMixProtos = (ingredients, constructor, exclude = []) => {
|
||||
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);
|
||||
// Keeps track of prototypes we've already visited to avoid copying the same properties multiple times. We init the
|
||||
// list with the proto chain below the nearest common ancestor because we don't want any of those methods mixed in
|
||||
// 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.
|
||||
for (let i = protos.length - 1; i >= 0; i--) {
|
||||
let newProto = protos[i];
|
||||
if (visitedProtos.indexOf(newProto) === -1) {
|
||||
exports.copyProps(mixedProto, newProto, ['constructor', ...exclude]);
|
||||
(0, exports.copyProps)(mixedProto, newProto, ['constructor', ...exclude]);
|
||||
visitedProtos.push(newProto);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue