@zwa73/utils 1.0.63 → 1.0.64
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 +6 -4
- package/package.json +1 -1
- package/src/UtilFunctions.ts +4 -2
package/dist/UtilFunctions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComposedClassMult, ComposedClassPart, JToken, PromiseProcFn, PromiseVerifyFn } from "./UtilInterfaces";
|
|
1
|
+
import { ComposedClassMult, ComposedClassPart, FuncPropNames, 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 FuncPropNames<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
|
@@ -207,14 +207,16 @@ 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: ()
|
|
212
|
-
set: (value)
|
|
213
|
-
enumerable:
|
|
212
|
+
get: ()=>mixin[fd],
|
|
213
|
+
set: (value)=>{mixin[fd] = value},
|
|
214
|
+
enumerable:true ,
|
|
214
215
|
//writable: true ,
|
|
215
216
|
configurable: true
|
|
216
217
|
});
|
|
217
|
-
|
|
218
|
+
*/
|
|
219
|
+
compObj[fd] = mixin[fd].bind(mixin);
|
|
218
220
|
}
|
|
219
221
|
return compObj;
|
|
220
222
|
}
|
package/package.json
CHANGED
package/src/UtilFunctions.ts
CHANGED
|
@@ -221,10 +221,11 @@ 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 FuncPropNames<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){
|
|
228
|
+
/**
|
|
228
229
|
Object.defineProperty(compObj, fd, {
|
|
229
230
|
get: ()=>mixin[fd],
|
|
230
231
|
set: (value)=>{mixin[fd] = value},
|
|
@@ -232,7 +233,8 @@ export function composeClassPart
|
|
|
232
233
|
//writable: true ,
|
|
233
234
|
configurable: true
|
|
234
235
|
});
|
|
235
|
-
|
|
236
|
+
*/
|
|
237
|
+
(compObj as any)[fd] = (mixin[fd] as any).bind(mixin);
|
|
236
238
|
}
|
|
237
239
|
return compObj;
|
|
238
240
|
}
|