@zwa73/utils 1.0.72 → 1.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/UtilFunctions.js +24 -21
- package/package.json +1 -1
- package/src/UtilFunctions.ts +23 -21
package/dist/UtilFunctions.js
CHANGED
|
@@ -207,30 +207,33 @@ var UtilFunc;
|
|
|
207
207
|
*/
|
|
208
208
|
function composeClassPart(base, mixin, key, ...fields) {
|
|
209
209
|
const compObj = base;
|
|
210
|
+
if (compObj[key] !== undefined)
|
|
211
|
+
UtilLogger_1.SLogger.warn(`key: ${key} 已存在于基础类中, 混入可能导致类型问题`);
|
|
210
212
|
compObj[key] = mixin;
|
|
211
213
|
for (const fd of fields) {
|
|
212
214
|
if (compObj[fd] !== undefined)
|
|
213
|
-
UtilLogger_1.SLogger.warn(
|
|
214
|
-
Object.defineProperty(compObj, fd, {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
215
|
+
UtilLogger_1.SLogger.warn(`field: ${fd} 已存在于基础类中, 混入可能导致类型问题, 如需覆盖, 请使用 ${key}=val`);
|
|
216
|
+
//Object.defineProperty(compObj, fd, {
|
|
217
|
+
// get: ()=>compObj[key][fd],
|
|
218
|
+
// set: (value)=>{compObj[key][fd] = value},
|
|
219
|
+
// enumerable:true ,
|
|
220
|
+
// //writable: true ,
|
|
221
|
+
// configurable: true
|
|
222
|
+
//});
|
|
223
|
+
if (typeof mixin[fd] === 'function') {
|
|
224
|
+
compObj[fd] = (...args) => compObj[key][fd](...args);
|
|
225
|
+
//(compObj as any)[fd] = (...args: any[]) => (mixin[fd] as any).apply(mixin, args);
|
|
226
|
+
//(compObj as any)[fd] = (mixin[fd] as any).bind(mixin);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
Object.defineProperty(compObj, fd, {
|
|
230
|
+
get: () => compObj[key][fd],
|
|
231
|
+
set: (value) => { compObj[key][fd] = value; },
|
|
232
|
+
enumerable: true,
|
|
233
|
+
//writable: true ,
|
|
234
|
+
configurable: true
|
|
235
|
+
});
|
|
236
|
+
}
|
|
234
237
|
}
|
|
235
238
|
return compObj;
|
|
236
239
|
}
|
package/package.json
CHANGED
package/src/UtilFunctions.ts
CHANGED
|
@@ -225,30 +225,32 @@ export function composeClassPart
|
|
|
225
225
|
<Base extends object,Mixin extends object,Field extends keyof Mixin>
|
|
226
226
|
(base:Base,mixin:Mixin,key:string,...fields:Field[]):ComposedClass<Base,Mixin,typeof key,Field>{
|
|
227
227
|
const compObj = base as any;
|
|
228
|
+
if(compObj[key]!==undefined)
|
|
229
|
+
SLogger.warn(`key: ${key as string} 已存在于基础类中, 混入可能导致类型问题`);
|
|
228
230
|
compObj[key] = mixin;
|
|
229
231
|
for(const fd of fields){
|
|
230
232
|
if(compObj[fd]!==undefined)
|
|
231
|
-
SLogger.warn(
|
|
232
|
-
Object.defineProperty(compObj, fd, {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
233
|
+
SLogger.warn(`field: ${fd as string} 已存在于基础类中, 混入可能导致类型问题, 如需覆盖, 请使用 ${key}=val`);
|
|
234
|
+
//Object.defineProperty(compObj, fd, {
|
|
235
|
+
// get: ()=>compObj[key][fd],
|
|
236
|
+
// set: (value)=>{compObj[key][fd] = value},
|
|
237
|
+
// enumerable:true ,
|
|
238
|
+
// //writable: true ,
|
|
239
|
+
// configurable: true
|
|
240
|
+
//});
|
|
241
|
+
if(typeof mixin[fd] === 'function') {
|
|
242
|
+
compObj[fd] = (...args: any[]) => compObj[key][fd](...args);
|
|
243
|
+
//(compObj as any)[fd] = (...args: any[]) => (mixin[fd] as any).apply(mixin, args);
|
|
244
|
+
//(compObj as any)[fd] = (mixin[fd] as any).bind(mixin);
|
|
245
|
+
} else {
|
|
246
|
+
Object.defineProperty(compObj, fd, {
|
|
247
|
+
get: ()=>compObj[key][fd],
|
|
248
|
+
set: (value)=>{compObj[key][fd] = value},
|
|
249
|
+
enumerable:true ,
|
|
250
|
+
//writable: true ,
|
|
251
|
+
configurable: true
|
|
252
|
+
});
|
|
253
|
+
}
|
|
252
254
|
}
|
|
253
255
|
return compObj;
|
|
254
256
|
}
|