@zwa73/utils 1.0.63 → 1.0.65

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,14 +207,27 @@ var UtilFunc;
207
207
  function composeClassPart(base, mixin, ...fields) {
208
208
  const compObj = base;
209
209
  for (const fd of fields) {
210
+ /**
210
211
  Object.defineProperty(compObj, fd, {
211
- get: () => mixin[fd],
212
- set: (value) => { mixin[fd] = value; },
213
- enumerable: true,
212
+ get: ()=>mixin[fd],
213
+ set: (value)=>{mixin[fd] = value},
214
+ enumerable:true ,
214
215
  //writable: true ,
215
216
  configurable: true
216
217
  });
217
- //(compObj as any)[fd] = (mixin[fd] as any).bind(mixin);
218
+ */
219
+ if (typeof mixin[fd] === 'function') {
220
+ compObj[fd] = mixin[fd].bind(mixin);
221
+ }
222
+ else {
223
+ Object.defineProperty(compObj, fd, {
224
+ get: () => mixin[fd],
225
+ set: (value) => { mixin[fd] = value; },
226
+ enumerable: true,
227
+ //writable: true ,
228
+ configurable: true
229
+ });
230
+ }
218
231
  }
219
232
  return compObj;
220
233
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.63",
3
+ "version": "1.0.65",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -225,6 +225,7 @@ export function composeClassPart
225
225
  (base:Base,mixin:Mixin,...fields:Field[]):ComposedClassPart<Base,Mixin,Field>{
226
226
  const compObj = base as any;
227
227
  for(const fd of fields){
228
+ /**
228
229
  Object.defineProperty(compObj, fd, {
229
230
  get: ()=>mixin[fd],
230
231
  set: (value)=>{mixin[fd] = value},
@@ -232,7 +233,18 @@ export function composeClassPart
232
233
  //writable: true ,
233
234
  configurable: true
234
235
  });
235
- //(compObj as any)[fd] = (mixin[fd] as any).bind(mixin);
236
+ */
237
+ if(typeof mixin[fd] === 'function') {
238
+ (compObj as any)[fd] = (mixin[fd] as any).bind(mixin);
239
+ } else {
240
+ Object.defineProperty(compObj, fd, {
241
+ get: ()=>mixin[fd],
242
+ set: (value)=>{mixin[fd] = value},
243
+ enumerable:true ,
244
+ //writable: true ,
245
+ configurable: true
246
+ });
247
+ }
236
248
  }
237
249
  return compObj;
238
250
  }