@zwa73/utils 1.0.64 → 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.
- package/dist/UtilFunctions.d.ts +2 -2
- package/dist/UtilFunctions.js +12 -1
- package/package.json +1 -1
- package/src/UtilFunctions.ts +12 -2
package/dist/UtilFunctions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComposedClassMult, ComposedClassPart,
|
|
1
|
+
import { ComposedClassMult, ComposedClassPart, JToken, PromiseProcFn, PromiseVerifyFn } from "./UtilInterfaces";
|
|
2
2
|
/**常用函数 */
|
|
3
3
|
export declare namespace UtilFunc {
|
|
4
4
|
/**获取当前时间戳
|
|
@@ -64,7 +64,7 @@ export declare namespace UtilFunc {
|
|
|
64
64
|
* @param fields - 需要混入的字段
|
|
65
65
|
* @returns 混合完成的类
|
|
66
66
|
*/
|
|
67
|
-
function composeClassPart<Base extends object, Mixin extends object, Field extends
|
|
67
|
+
function composeClassPart<Base extends object, Mixin extends object, Field extends keyof Mixin>(base: Base, mixin: Mixin, ...fields: Field[]): ComposedClassPart<Base, Mixin, Field>;
|
|
68
68
|
/**类组合
|
|
69
69
|
* 将mixinList每个成员的字段混入base
|
|
70
70
|
* @param base - 基础类
|
package/dist/UtilFunctions.js
CHANGED
|
@@ -216,7 +216,18 @@ var UtilFunc;
|
|
|
216
216
|
configurable: true
|
|
217
217
|
});
|
|
218
218
|
*/
|
|
219
|
-
|
|
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
|
+
}
|
|
220
231
|
}
|
|
221
232
|
return compObj;
|
|
222
233
|
}
|
package/package.json
CHANGED
package/src/UtilFunctions.ts
CHANGED
|
@@ -221,7 +221,7 @@ export async function repeatPromise<T>(procFn:PromiseProcFn<T>,verifyFn?:Promise
|
|
|
221
221
|
* @returns 混合完成的类
|
|
222
222
|
*/
|
|
223
223
|
export function composeClassPart
|
|
224
|
-
<Base extends object,Mixin extends object,Field extends
|
|
224
|
+
<Base extends object,Mixin extends object,Field extends keyof Mixin>
|
|
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){
|
|
@@ -234,7 +234,17 @@ export function composeClassPart
|
|
|
234
234
|
configurable: true
|
|
235
235
|
});
|
|
236
236
|
*/
|
|
237
|
-
(
|
|
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
|
+
}
|
|
238
248
|
}
|
|
239
249
|
return compObj;
|
|
240
250
|
}
|