@zwa73/utils 1.0.166 → 1.0.167

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.166",
3
+ "version": "1.0.167",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/dist/backup.d.ts DELETED
@@ -1,32 +0,0 @@
1
- /**类组合
2
- * 将mixinList每个成员的字段混入base
3
- * @param base - 基础类
4
- * @param mixinList - 目标类
5
- * @returns - 混合完成的类
6
- */
7
- export declare function composeClassFull<Base extends object, MixinList extends object[]>(base: Base, ...mixinList: MixinList): ComposedFullClassMult<Base, MixinList>;
8
- /**组合的类
9
- * @template Base - 基类
10
- * @template Mixin - 待混入的类
11
- */
12
- export type ComposedFullClass<Base extends object, Mixin extends object> = Base & Mixin;
13
- /**组合的类 多组合变体
14
- * @template Base - 基类
15
- * @template MixinList- 待混入的类型数组
16
- */
17
- export type ComposedFullClassMult<Base extends object, MixinList extends object[]> = MixinList extends [infer Mixin, ...infer Rest] ? Mixin extends object ? Rest extends object[] ? ComposedFullClassMult<ComposedFullClass<Base, Mixin>, Rest> : Base : Base : Base;
18
- /**将一个类型的所有方法的 `this` 参数改为 `T` 类型
19
- * @template Methods - 待更改的函数表
20
- * @template T - 目标this类型
21
- */
22
- export type MethodsThisAs<Methods, T> = {
23
- [K in keyof Methods]: Methods[K] extends (...args: infer A) => infer R ? (this: T, ...args: A) => R : Methods[K];
24
- };
25
- /**尝试断言一个类的原型
26
- * 其所有函数的 this 都必须为某个类型
27
- * assignThisAs<Self,T>(Self.prototype);
28
- * @template Self - 类的类型
29
- * @template T - 目标this类型
30
- * @param prototype - 类的原型
31
- */
32
- export declare function assertThisAs<Self, T>(prototype: MethodsThisAs<Self, T>): void;
package/dist/backup.js DELETED
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.composeClassFull = composeClassFull;
4
- exports.assertThisAs = assertThisAs;
5
- /**类组合
6
- * 将mixinList每个成员的字段混入base
7
- * @param base - 基础类
8
- * @param mixinList - 目标类
9
- * @returns - 混合完成的类
10
- */
11
- function composeClassFull(base, ...mixinList) {
12
- let obj = base;
13
- for (let mixin of mixinList) {
14
- let propks = Object.getOwnPropertyNames(mixin.constructor.prototype);
15
- for (const key of propks) {
16
- if (key != "constructor") {
17
- Object.defineProperty(obj, key, {
18
- get: () => mixin[key],
19
- set: (value) => { mixin[key] = value; },
20
- enumerable: true,
21
- //writable: true,
22
- configurable: true
23
- });
24
- //obj[key] = (mixin as any)[key];
25
- }
26
- }
27
- for (const key in mixin) {
28
- Object.defineProperty(obj, key, {
29
- get: () => mixin[key],
30
- set: (value) => { mixin[key] = value; },
31
- enumerable: true,
32
- //writable: true ,
33
- configurable: true
34
- });
35
- //obj[key] = (mixin as any)[key];
36
- }
37
- }
38
- return obj;
39
- }
40
- /**尝试断言一个类的原型
41
- * 其所有函数的 this 都必须为某个类型
42
- * assignThisAs<Self,T>(Self.prototype);
43
- * @template Self - 类的类型
44
- * @template T - 目标this类型
45
- * @param prototype - 类的原型
46
- */
47
- function assertThisAs(prototype) { }
File without changes