@zwa73/utils 1.0.62 → 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.
@@ -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 keyof Mixin>(base: Base, mixin: Mixin, ...fields: Field[]): ComposedClassPart<Base, Mixin, Field>;
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 - 基础类
@@ -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: () => 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
+ compObj[fd] = mixin[fd].bind(mixin);
218
220
  }
219
221
  return compObj;
220
222
  }
@@ -99,5 +99,5 @@ export type MethodsThisAs<Methods, T> = {
99
99
  * @template T - 目标this类型
100
100
  * @param prototype - 类的原型
101
101
  */
102
- export declare function assignThisAs<Self, T>(prototype: MethodsThisAs<Self, T>): void;
102
+ export declare function assertThisAs<Self, T>(prototype: MethodsThisAs<Self, T>): void;
103
103
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assignThisAs = exports.stringifyJToken = void 0;
3
+ exports.assertThisAs = exports.stringifyJToken = void 0;
4
4
  /**将JToken转换为字符串
5
5
  * @param token - 待转换的Token
6
6
  * @param space - 插入的空格 数字为空格数量 默认为制表符\t
@@ -19,5 +19,5 @@ exports.stringifyJToken = stringifyJToken;
19
19
  * @template T - 目标this类型
20
20
  * @param prototype - 类的原型
21
21
  */
22
- function assignThisAs(prototype) { }
23
- exports.assignThisAs = assignThisAs;
22
+ function assertThisAs(prototype) { }
23
+ exports.assertThisAs = assertThisAs;
@@ -41,7 +41,7 @@ function composeC(obj) {
41
41
  return ob3;
42
42
  }
43
43
  exports.C = _C;
44
- (0, __1.assignThisAs)(exports.C.prototype);
44
+ (0, __1.assertThisAs)(exports.C.prototype);
45
45
  const insc = exports.C.create(); //?
46
46
  insc.getC().testFunc(); //?
47
47
  insc.testFunc(); //?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.62",
3
+ "version": "1.0.64",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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 keyof Mixin>
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
- //(compObj as any)[fd] = (mixin[fd] as any).bind(mixin);
236
+ */
237
+ (compObj as any)[fd] = (mixin[fd] as any).bind(mixin);
236
238
  }
237
239
  return compObj;
238
240
  }
@@ -155,4 +155,4 @@ export type MethodsThisAs<Methods, T> = {
155
155
  * @template T - 目标this类型
156
156
  * @param prototype - 类的原型
157
157
  */
158
- export function assignThisAs<Self,T>(prototype: MethodsThisAs<Self, T>) {}
158
+ export function assertThisAs<Self,T>(prototype: MethodsThisAs<Self, T>) {}
@@ -1,4 +1,4 @@
1
- import { UtilFP, UtilFunc, assignThisAs } from ".."
1
+ import { UtilFP, UtilFunc, assertThisAs } from ".."
2
2
 
3
3
  class A {
4
4
  private num = 1;
@@ -39,7 +39,7 @@ function composeC(obj:_C){
39
39
  }
40
40
  export type C = ReturnType<typeof composeC>;
41
41
  export const C = _C;
42
- assignThisAs<_C,C>(C.prototype);
42
+ assertThisAs<_C,C>(C.prototype);
43
43
 
44
44
  const insc:C=C.create();//?
45
45
  insc.getC().testFunc()//?