@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.
@@ -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(`${fd} 已存在于基础类中, 混入可能导致类型问题, 如需覆盖, 请使用 ${key}=val`);
214
- Object.defineProperty(compObj, fd, {
215
- get: () => compObj[key][fd],
216
- set: (value) => { compObj[key][fd] = value; },
217
- enumerable: true,
218
- //writable: true ,
219
- configurable: true
220
- });
221
- //if(typeof mixin[fd] === 'function') {
222
- // compObj[fd] = (...args: any[]) => compObj[key][fd](...args);
223
- // //(compObj as any)[fd] = (...args: any[]) => (mixin[fd] as any).apply(mixin, args);
224
- // //(compObj as any)[fd] = (mixin[fd] as any).bind(mixin);
225
- //} else {
226
- // Object.defineProperty(compObj, fd, {
227
- // get: ()=>compObj[key][fd],
228
- // set: (value)=>{compObj[key][fd] = value},
229
- // enumerable:true ,
230
- // //writable: true ,
231
- // configurable: true
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.72",
3
+ "version": "1.0.74",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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(`${fd as string} 已存在于基础类中, 混入可能导致类型问题, 如需覆盖, 请使用 ${key}=val`);
232
- Object.defineProperty(compObj, fd, {
233
- get: ()=>compObj[key][fd],
234
- set: (value)=>{compObj[key][fd] = value},
235
- enumerable:true ,
236
- //writable: true ,
237
- configurable: true
238
- });
239
- //if(typeof mixin[fd] === 'function') {
240
- // compObj[fd] = (...args: any[]) => compObj[key][fd](...args);
241
- // //(compObj as any)[fd] = (...args: any[]) => (mixin[fd] as any).apply(mixin, args);
242
- // //(compObj as any)[fd] = (mixin[fd] as any).bind(mixin);
243
- //} else {
244
- // Object.defineProperty(compObj, fd, {
245
- // get: ()=>compObj[key][fd],
246
- // set: (value)=>{compObj[key][fd] = value},
247
- // enumerable:true ,
248
- // //writable: true ,
249
- // configurable: true
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
  }