baja-lite 1.0.33 → 1.0.35

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.
Files changed (103) hide show
  1. package/{cjs/boot-remote.d.ts → boot-remote.d.ts} +1 -1
  2. package/{es/boot-remote.js → boot-remote.js} +2 -2
  3. package/{es/boot.d.ts → boot.d.ts} +1 -1
  4. package/{es/boot.js → boot.js} +2 -2
  5. package/{es/enum.js → enum.js} +1 -1
  6. package/{es/fn.js → fn.js} +2 -2
  7. package/index.d.ts +10 -0
  8. package/index.js +10 -0
  9. package/package.json +11 -12
  10. package/{cjs/sql.d.ts → sql.d.ts} +3 -3
  11. package/{es/sql.js → sql.js} +7 -7
  12. package/{es/sqlite.d.ts → sqlite.d.ts} +1 -1
  13. package/{es/sqlite.js → sqlite.js} +1 -1
  14. package/{es/test-mysql.js → test-mysql.js} +2 -2
  15. package/{es/test-postgresql.js → test-postgresql.js} +2 -2
  16. package/cjs/boot-remote.js +0 -49
  17. package/cjs/boot.d.ts +0 -2
  18. package/cjs/boot.js +0 -183
  19. package/cjs/code.js +0 -379
  20. package/cjs/convert-xml.js +0 -417
  21. package/cjs/enum.js +0 -64
  22. package/cjs/error.js +0 -16
  23. package/cjs/fn.js +0 -179
  24. package/cjs/index.d.ts +0 -10
  25. package/cjs/index.js +0 -26
  26. package/cjs/list.js +0 -60
  27. package/cjs/math.js +0 -474
  28. package/cjs/object.js +0 -242
  29. package/cjs/set-ex.js +0 -345
  30. package/cjs/sql.js +0 -5083
  31. package/cjs/sqlite.d.ts +0 -32
  32. package/cjs/sqlite.js +0 -169
  33. package/cjs/string.js +0 -119
  34. package/cjs/test-mysql.js +0 -138
  35. package/cjs/test-postgresql.js +0 -93
  36. package/cjs/test-sqlite.js +0 -91
  37. package/cjs/test-xml.js +0 -75
  38. package/cjs/test.js +0 -4
  39. package/es/boot-remote.d.ts +0 -2
  40. package/es/code.d.ts +0 -2
  41. package/es/convert-xml.d.ts +0 -10
  42. package/es/enum.d.ts +0 -18
  43. package/es/error.d.ts +0 -5
  44. package/es/fn.d.ts +0 -128
  45. package/es/index.d.ts +0 -10
  46. package/es/index.js +0 -10
  47. package/es/list.d.ts +0 -10
  48. package/es/math.d.ts +0 -83
  49. package/es/object.d.ts +0 -83
  50. package/es/set-ex.d.ts +0 -198
  51. package/es/sql.d.ts +0 -1858
  52. package/es/string.d.ts +0 -17
  53. package/es/test-mysql.d.ts +0 -2
  54. package/es/test-postgresql.d.ts +0 -2
  55. package/es/test-sqlite.d.ts +0 -1
  56. package/es/test-xml.d.ts +0 -1
  57. package/es/test.d.ts +0 -1
  58. package/src/boot-remote.ts +0 -46
  59. package/src/boot.ts +0 -153
  60. package/src/code.ts +0 -377
  61. package/src/convert-xml.ts +0 -460
  62. package/src/enum.ts +0 -71
  63. package/src/error.ts +0 -11
  64. package/src/fn.ts +0 -295
  65. package/src/index.ts +0 -10
  66. package/src/list.ts +0 -57
  67. package/src/math.ts +0 -405
  68. package/src/object.ts +0 -247
  69. package/src/set-ex.ts +0 -374
  70. package/src/sql.ts +0 -5281
  71. package/src/sqlite.ts +0 -161
  72. package/src/string.ts +0 -111
  73. package/src/test-mysql.ts +0 -126
  74. package/src/test-postgresql.ts +0 -79
  75. package/src/test-sqlite.ts +0 -80
  76. package/src/test-xml.ts +0 -70
  77. package/src/test.ts +0 -2
  78. /package/{cjs/code.d.ts → code.d.ts} +0 -0
  79. /package/{es/code.js → code.js} +0 -0
  80. /package/{cjs/convert-xml.d.ts → convert-xml.d.ts} +0 -0
  81. /package/{es/convert-xml.js → convert-xml.js} +0 -0
  82. /package/{cjs/enum.d.ts → enum.d.ts} +0 -0
  83. /package/{cjs/error.d.ts → error.d.ts} +0 -0
  84. /package/{es/error.js → error.js} +0 -0
  85. /package/{cjs/fn.d.ts → fn.d.ts} +0 -0
  86. /package/{cjs/list.d.ts → list.d.ts} +0 -0
  87. /package/{es/list.js → list.js} +0 -0
  88. /package/{cjs/math.d.ts → math.d.ts} +0 -0
  89. /package/{es/math.js → math.js} +0 -0
  90. /package/{cjs/object.d.ts → object.d.ts} +0 -0
  91. /package/{es/object.js → object.js} +0 -0
  92. /package/{cjs/set-ex.d.ts → set-ex.d.ts} +0 -0
  93. /package/{es/set-ex.js → set-ex.js} +0 -0
  94. /package/{cjs/string.d.ts → string.d.ts} +0 -0
  95. /package/{es/string.js → string.js} +0 -0
  96. /package/{cjs/test-mysql.d.ts → test-mysql.d.ts} +0 -0
  97. /package/{cjs/test-postgresql.d.ts → test-postgresql.d.ts} +0 -0
  98. /package/{cjs/test-sqlite.d.ts → test-sqlite.d.ts} +0 -0
  99. /package/{es/test-sqlite.js → test-sqlite.js} +0 -0
  100. /package/{cjs/test-xml.d.ts → test-xml.d.ts} +0 -0
  101. /package/{es/test-xml.js → test-xml.js} +0 -0
  102. /package/{cjs/test.d.ts → test.d.ts} +0 -0
  103. /package/{es/test.js → test.js} +0 -0
package/cjs/test-xml.js DELETED
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const html_parse_stringify_1 = __importDefault(require("html-parse-stringify"));
7
- console.log((html_parse_stringify_1.default.parse(`
8
- <sql id="reportField">
9
- a.left_e_foul leftEFoul,
10
- a.right_e_foul rightEFoul,
11
- a.left_em_foul leftEmFoul,
12
- a.right_em_foul rightEmFoul,
13
- a.left_s_foul leftSFoul,
14
- a.right_s_foul rightSFoul,
15
- a.left_sb_foul leftSbFoul,
16
- a.right_sb_foul rightSbFoul,
17
- a.left_p_foul leftPFoul,
18
- a.right_p_foul rightPFoul,
19
- a.left_attack_goal leftAttackGoal,
20
- a.right_attack_goal rightAttackGoal,
21
- a.left_point_goal leftPointGoal,
22
- a.right_point_goal rightPointGoal,
23
- a.left_over_time_goal leftOverTimeGoal,
24
- a.right_over_time_goal rightOverTimeGoal,
25
- a.left_normal_goal leftNormalGoal,
26
- a.right_normal_goal rightNormalGoal,
27
- a.left_own_goal leftOwnGoal,
28
- a.right_own_goal rightOwnGoal,
29
- a.left_time_out leftTimeOut,
30
- a.right_time_out rightTimeOut,
31
- a.left_coach_y_card leftCoachYCard,
32
- a.right_coach_y_card rightCoachYCard,
33
- a.left_player_r_card leftPlayerRCard,
34
- a.right_player_r_card rightPlayerRCard,
35
- a.left_jump_ball leftJumpBall,
36
- a.right_jump_ball rightJumpBall
37
- </sql>
38
- <select id="matchReport" resultType="org.jeecg.modules.event.entity.EventMatchReport">
39
- select
40
- b.event_name eventName,
41
- a.match_id matchId,
42
- a.event_times eventTimes,
43
- a.team_left_id teamLeftId,
44
- a.team_RIGHt_id teamRightId,
45
- a.team_left_name teamLeftName,
46
- a.team_right_name teamRightName,
47
- a.team_left_image teamLeftImage,
48
- a.team_right_image teamRightImage,
49
- <include refid="reportField" />
50
- <if test="matchInfo.reportType!=null and matchInfo.reportType!=''">
51
- from view_match_report a
52
- </if>
53
- <if test="matchInfo.reportType==null or matchInfo.reportType==''">
54
- from event_match_report a
55
- </if>
56
- left join event_main_info b on a.event_id = b.id
57
- <where>
58
- <if test="matchInfo.id!=null and matchInfo.id!=''">
59
- and a.match_id = #{matchInfo.id}
60
- </if>
61
- <if test="matchInfo.eventId!=null and matchInfo.eventId!=''">
62
- and a.event_id = #{matchInfo.eventId}
63
- </if>
64
- <if test="matchInfo.teamLeftId!=null and matchInfo.teamLeftId!=''">
65
- and (a.team_left_id = #{matchInfo.teamLeftId} OR a.team_right_id = #{matchInfo.teamLeftId})
66
- </if>
67
- <if test="dataIdList!=null">
68
- and a.event_id in
69
- <foreach collection="dataIdList" item="item" open="(" close=")" separator=",">
70
- #{item}
71
- </foreach>
72
- </if>
73
- </where>
74
- </select>
75
- >`)));
package/cjs/test.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const mysql2_1 = require("mysql2");
4
- console.log((0, mysql2_1.format)('select 1 from a where ?', [['1', '2', '3']]));
@@ -1,2 +0,0 @@
1
- import { GlobalSqlOptionForWeb } from './sql';
2
- export declare const BootRomote: (options: GlobalSqlOptionForWeb) => Promise<void>;
package/es/code.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,10 +0,0 @@
1
- export interface XML {
2
- type: 'tag' | 'text';
3
- name: string;
4
- id?: string;
5
- voidElement: boolean;
6
- attrs: Record<string, string>;
7
- children: XML[];
8
- content: string;
9
- }
10
- export declare const convert: (childrens: XML[], param: Record<string, any>, parentIds: string[], myBatisMapper: Record<string, XML[]>) => string;
package/es/enum.d.ts DELETED
@@ -1,18 +0,0 @@
1
- export declare class Enum {
2
- private _value;
3
- private _desc;
4
- private _config;
5
- constructor(value: string, desc: string, ...config: string[]);
6
- eq(value: string | number | undefined | null): boolean;
7
- value(): string;
8
- desc(): string;
9
- config(): string[];
10
- }
11
- export type EnumMap = Record<string, Enum>;
12
- export type GlobalArray = Record<string, Array<[string, string]>>;
13
- export type GlobalMap = Record<string, Record<string, string>>;
14
- export interface EnmuJson {
15
- GlobalArray: GlobalArray;
16
- GlobalMap: GlobalMap;
17
- }
18
- export declare const getEnums: (GlobalValues?: EnumMap) => EnmuJson;
package/es/error.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export declare const Throw: {
2
- if(test: boolean, message: string | Error | any): void;
3
- ifNot(test: boolean, message: string | Error | any): void;
4
- now(message: string | Error | any): never;
5
- };
package/es/fn.d.ts DELETED
@@ -1,128 +0,0 @@
1
- /**
2
- * 回调函数promise化
3
- * 调用示例
4
- * soap.excute(arg1, arg2, function(error, data){});
5
- * 可使用为:
6
- * const soap_excute = promise({
7
- * fn: soap.excute,
8
- * target: soap
9
- * });
10
- * const data = await soap_excute(arg1, arg2);
11
- * @param this
12
- * @param param1
13
- */
14
- export declare const promise: <T>(this: any, { fn, target, last }: {
15
- fn: (...args: any[]) => any;
16
- target?: any;
17
- last?: boolean;
18
- }) => (...args: any[]) => Promise<T>;
19
- export declare const sleep: (time?: number) => Promise<unknown>;
20
- /**
21
- * 执行器
22
- * @param fn
23
- * @param {
24
- ifFinish?: (result?: T) => boolean; // 是否结束,默认是建议判断 !!result
25
- maxTryTimes?: number; //最多尝试几次,默认是20
26
- onFail?: () => Promise<boolean | undefined> | boolean | undefined; // 失败时的回调,返回false表示停止执行
27
- name?: string; // 执行器名称,用于打印日志
28
- exitIfFail?: boolean; // 失败时是否退出,默认是false. 这里设置true后,onFail返回true,也会停止执行
29
- defVal?: T; // 失败时的默认值
30
- sleepAppend?: number; // 等待延迟MS,默认是1000内随机+200
31
- * }
32
- * @returns
33
- */
34
- export declare function dieTrying<T = any>(fn: (...args: any[]) => Promise<T | undefined> | T | undefined, { ifFinish, maxTryTimes, onFail, name, exitIfFail, defVal, sleepAppend }?: {
35
- ifFinish?: (result?: T) => boolean;
36
- maxTryTimes?: number;
37
- onFail?: () => Promise<boolean | undefined> | boolean | undefined;
38
- name?: string;
39
- exitIfFail?: boolean;
40
- defVal?: T;
41
- sleepAppend?: number;
42
- }): Promise<T | undefined>;
43
- export declare enum ExcuteSplitMode {
44
- SyncTrust = 0,
45
- SyncNoTrust = 1,
46
- AsyncTrust = 2,
47
- AsyncNoTrust = 3
48
- }
49
- /**
50
- * 数组分割执行
51
- * @param datas 数组
52
- * @param fn 执行的函数, 参数1:分割数组;参数2:第几个分割数组;参数3:分割数组的数量;参数4:从第几个下标(相对于总数组)元素开始;参数5:到第几个下标(相对于总数组)元素结束
53
- * @param config 配置(三选一):everyLength=每组个数(最后一组可能不足次数), groupCount=拆分几组, extendParams=依附拆分数组;
54
- * @param 额外选项 settled=是否并行?
55
- * T: datas类型
56
- * E: extendParams类型
57
- * R: 返回值类型
58
- */
59
- /**
60
- * 数组分割执行
61
- *
62
- * # 参数说明
63
- * @param sync 同步异步开关
64
- * @param datas 数组
65
- * @param fn 执行的函数
66
- ```
67
- ** `args`: 分割后的小数组
68
- ** `index`: 第几个小数组
69
- ** `length`: 总共多少个小数组
70
- ** `extendParam`?: `参见下面Option中的extendParams`
71
- ** `startIndex`?: 本次小数组的第一个元素是从总数组的第几个元素
72
- ** `endIndex`?: 本次小数组的最后一个元素是从总数组的第几个元素
73
- fn: (args: T[], index: number, length: number, extendParam?: E, startIndex?: number, endIndex?: number):R => {
74
-
75
- }
76
- ```
77
- * @param option 选项
78
-
79
- ## 分割数组方式:2种,选择一种即可
80
- 1. everyLength=每组个数(最后一组可能不足次数)
81
- 2. groupCount=拆分几组
82
- ## settled 异步执行是否并行执行? 默认false
83
- ## `extendParams`:扩展参数
84
- ** 数组
85
- ** 结合分组方式:groupCount使用。例如:
86
- ```
87
- `groupCount`=5,那么可以传入5个`extendParams`,在执行分组时,会为每个数组传入对应下标的`extendParam`
88
- ```
89
- ## `trust` 是否信任方法体,默认false
90
- * true时,执行时捕获不异常, 返回值变为 R[]
91
- * false时,执行时捕获异常,并返回 { result: R[]; error: string[]; };
92
- # 泛型说明:全部可选
93
- 1. T = 数组类型
94
- 2. R = 返回结果类型
95
- 3. E = 扩展参数类型
96
-
97
- * @returns
98
- */
99
- export declare function excuteSplit<T = any, R = any, E = any>(sync: ExcuteSplitMode.SyncTrust, datas: T[], fn: (args: T[], index: number, length: number, extendParam?: E, startIndex?: number, endIndex?: number) => R, option: {
100
- everyLength?: number;
101
- groupCount?: number;
102
- settled?: boolean;
103
- extendParams?: E[];
104
- }): R[];
105
- export declare function excuteSplit<T = any, R = any, E = any>(sync: ExcuteSplitMode.SyncNoTrust, datas: T[], fn: (args: T[], index: number, length: number, extendParam?: E, startIndex?: number, endIndex?: number) => R, option: {
106
- everyLength?: number;
107
- groupCount?: number;
108
- settled?: boolean;
109
- extendParams?: E[];
110
- }): {
111
- result: R[];
112
- error: string[];
113
- };
114
- export declare function excuteSplit<T = any, R = any, E = any>(sync: ExcuteSplitMode.AsyncTrust, datas: T[], fn: (args: T[], index: number, length: number, extendParam?: E, startIndex?: number, endIndex?: number) => Promise<R>, option: {
115
- everyLength?: number;
116
- groupCount?: number;
117
- settled?: boolean;
118
- extendParams?: E[];
119
- }): Promise<R[]>;
120
- export declare function excuteSplit<T = any, R = any, E = any>(sync: ExcuteSplitMode.AsyncNoTrust, datas: T[], fn: (args: T[], index: number, length: number, extendParam?: E, startIndex?: number, endIndex?: number) => Promise<R>, option: {
121
- everyLength?: number;
122
- groupCount?: number;
123
- settled?: boolean;
124
- extendParams?: E[];
125
- }): Promise<{
126
- result: R[];
127
- error: string[];
128
- }>;
package/es/index.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import 'reflect-metadata';
2
- export * from './error';
3
- export * from './fn';
4
- export * from './math';
5
- export * from './object';
6
- export * from './set-ex';
7
- export * from './sql';
8
- export * from './string';
9
- export * from './enum';
10
- export * from './list';
package/es/index.js DELETED
@@ -1,10 +0,0 @@
1
- import 'reflect-metadata';
2
- export * from './error';
3
- export * from './fn';
4
- export * from './math';
5
- export * from './object';
6
- export * from './set-ex';
7
- export * from './sql';
8
- export * from './string';
9
- export * from './enum';
10
- export * from './list';
package/es/list.d.ts DELETED
@@ -1,10 +0,0 @@
1
- export declare class ArrayList<T> extends Array<T> {
2
- constructor(array?: Array<T> | T | undefined);
3
- add(...items: T[]): void;
4
- size(): number;
5
- isEmpty(): boolean;
6
- get(index: number): T | undefined;
7
- clear(): void;
8
- set(index: number, item: T): void;
9
- remove(index: number): void;
10
- }
package/es/math.d.ts DELETED
@@ -1,83 +0,0 @@
1
- /** 金钱格式化可用样式 */
2
- export declare class MoneyOption {
3
- style?: 'currency' | 'decimal' | 'percent';
4
- currency?: string;
5
- prefix?: number;
6
- def?: number;
7
- currencyDisplay?: 'symbol' | 'name' | 'code';
8
- useGrouping?: boolean;
9
- local?: string;
10
- }
11
- export interface Point {
12
- latitude: string;
13
- longitude: string;
14
- lat: number;
15
- long: number;
16
- }
17
- export declare const num: (val: any, def?: number) => number;
18
- export declare const max: (...args: any[]) => number;
19
- export declare const min: (...args: any[]) => number;
20
- export declare const div: (...args: any[]) => number;
21
- export declare const divDef: (def: any, ...args: any[]) => number;
22
- export declare const add: (...args: any[]) => number;
23
- export declare const mul: (...args: any[]) => number;
24
- export declare const sub: (...args: any[]) => number;
25
- export declare const round: (number: any, numDigits: number, upOrDown?: number) => number;
26
- /** =value.xx,其中xx=number,如number=99,表示修正数字为value.99 */
27
- export declare const merge: (value: any, number: any) => any;
28
- export declare const money: (value: any, option?: MoneyOption) => string;
29
- export declare class Bus {
30
- private result;
31
- private ifit;
32
- constructor(result: any);
33
- add(...args: any[]): this;
34
- sub(...args: any[]): this;
35
- div(...args: any[]): this;
36
- divDef(def: any, ...args: any[]): this;
37
- mul(...args: any[]): this;
38
- max(...args: any[]): this;
39
- min(...args: any[]): this;
40
- ac(): this;
41
- abs(): this;
42
- round(numDigits: number, upOrDown?: number): this;
43
- merge(number: any): this;
44
- if(condition: boolean): this;
45
- over(): number;
46
- money(option?: MoneyOption): string;
47
- lt(data: any): boolean;
48
- le(data: any): boolean;
49
- gt(data: any): boolean;
50
- ge(data: any): boolean;
51
- nlt(data: any): boolean;
52
- nle(data: any): boolean;
53
- ngt(data: any): boolean;
54
- nge(data: any): boolean;
55
- eq(data: any): boolean;
56
- ne(data: any): boolean;
57
- ifLt(data: any): this;
58
- ifLe(data: any): this;
59
- ifGt(data: any): this;
60
- ifGe(data: any): this;
61
- ifNlt(data: any): this;
62
- ifNle(data: any): this;
63
- ifNgt(data: any): this;
64
- ifNge(data: any): this;
65
- ifEq(data: any): this;
66
- ifNe(data: any): this;
67
- }
68
- export declare const calc: (result: any) => Bus;
69
- export declare const getGeo: (p1: Point, p2: Point) => number;
70
- /**
71
- * 十进制转换自定义进制
72
- * @param from 数字
73
- * @param to 自定义进制的字符
74
- * @returns
75
- */
76
- export declare function ten2Any(from: number, to?: string): string;
77
- /**
78
- * 自定义进制转换十进制
79
- * @param from
80
- * @param to
81
- * @returns
82
- */
83
- export declare function any2Ten(from: string, to?: string): number;
package/es/object.d.ts DELETED
@@ -1,83 +0,0 @@
1
- /**
2
- * 对象对象(等同与convertBean)
3
- * 仅会将classType有的属性进行转换
4
- * * 相当与一次属性过滤
5
- * @param source
6
- * @param classType
7
- */
8
- export declare const copyBean: <T>(source: any, classType: any) => T;
9
- /**
10
- * 对象转换(等同与copyBean)
11
- * 仅会将classType有的属性进行转换
12
- * 相当与一次属性过滤
13
- * @param source
14
- * @param classType
15
- */
16
- export declare const convertBean: <T>(source: any, classType: any) => T;
17
- /**
18
- * 批量对象转换(等同与copyBean)
19
- * 仅会将classType有的属性进行转换
20
- * 相当与一次属性过滤
21
- * @param source
22
- * @param classType
23
- */
24
- export declare const convertBeans: <T>(source: any[], classType: any, cb?: (target: T, source: any) => void) => T[];
25
- /**
26
- * 创建一个空对象
27
- * 其内各属性都是null
28
- * @param classType
29
- */
30
- export declare const emptyBean: <T>(classType: any) => T;
31
- /**
32
- * 将一个json数组提取为一个json对象
33
- * @param source 源数组
34
- * @param key 作为新对象的key的字段
35
- * @param value 作为新对象value的字段,不传则将自身为value
36
- */
37
- export declare const createBeanFromArray: <F, T = F>(source: F[], key: keyof F, value?: keyof F) => {
38
- [name: string]: T;
39
- };
40
- /**
41
- * 转换复合对象为指定bean
42
- * @param source
43
- * @param classType
44
- */
45
- export declare const coverComplexBean: <T>(source: any, classType: any) => {
46
- data: T;
47
- array: {
48
- [key: string]: any[];
49
- };
50
- };
51
- /**
52
- * 将目标对象中为空的字段替换为source中对应key的值或者函数返回值
53
- * @param target
54
- * @param source
55
- */
56
- export declare const fixEmptyPrototy: (target: any, source: {
57
- [key: string]: any;
58
- }) => Promise<void>;
59
- export declare const mixArray: <T>(array: T[], key: keyof T, defKey?: string) => {
60
- [key: string]: number;
61
- };
62
- export declare const mixList: <T, V = T>(array: T[], key: keyof T, value?: keyof T, defKey?: string) => {
63
- [key: string]: V[];
64
- };
65
- export declare const array2map: <T = string | number>(array: string[], v: T) => {
66
- [key: string]: T;
67
- };
68
- /**
69
- * 数组分割
70
- * @param datas
71
- * @param config(二选一) everyLength=每组个数(最后一组可能不足次数), groupCount=拆分几组
72
- * @returns T[][]
73
- */
74
- export declare const arraySplit: <T = any>(datas: T[], { everyLength, groupCount }?: {
75
- everyLength?: number | undefined;
76
- groupCount?: number | undefined;
77
- }) => T[][];
78
- export declare const P2C: (pro: string, IF?: boolean) => string;
79
- export declare const C2P: (pro: string, IF?: boolean) => string;
80
- export declare function C2P2<T extends Object = any, L extends Object = T>(datas: L[]): T[];
81
- export declare function C2P2<T extends Object = any, L extends Object = T>(datas: L): T;
82
- export declare function P2C2<T extends Object = any, L extends Object = T>(datas: L[]): T[];
83
- export declare function P2C2<T extends Object = any, L extends Object = T>(datas: L): T;
package/es/set-ex.d.ts DELETED
@@ -1,198 +0,0 @@
1
- export declare class SetEx<T> extends Set {
2
- private _key;
3
- private _onExist1?;
4
- private _onNotExist1?;
5
- private _replaceIfExits1;
6
- private _onExist2?;
7
- private _onNotExist2?;
8
- private _replaceIfExits2;
9
- private _map;
10
- /**
11
- * @param key 识别是否存在的对象的属性名
12
- * @param onExist 当存在时作何操作? oldData/newData 哪个将添加到set,由replaceItemWhenExits决定,默认是oldData生效
13
- * @param onNotExist 当不存在时作何操作?
14
- * @param replaceWhenExits 当存在时是否覆盖?
15
- * @param values 初始数组
16
- */
17
- constructor(option: {
18
- key: keyof T;
19
- /** add&addAll触发 */
20
- onExist1?: (oldData: T, newData: T) => void;
21
- /** add&addAll触发 */
22
- onNotExist1?: (newData: T) => void;
23
- /** add&addAll触发 */
24
- replaceIfExits1?: boolean;
25
- /** add2&addAll2触发 */
26
- onExist2?: (oldData: T, newData: T) => void;
27
- /** add2&addAll2触发 */
28
- onNotExist2?: (newData: T) => void;
29
- /** add2&addAll2触发 */
30
- replaceIfExits2?: boolean;
31
- values?: ReadonlyArray<T> | null;
32
- });
33
- /**
34
- *
35
- * 添加返回
36
- * @param {T} value
37
- * @returns {this} 当前对象
38
- */
39
- add(value: T): this;
40
- /**
41
- * 批量添加
42
- * @param values
43
- * @returns 当前对象
44
- */
45
- addAll(...values: T[]): this;
46
- /**
47
- *
48
- * 添加
49
- * @param {T} value
50
- * @returns {T} 添加成功的对象:可能是新加入集合的,也可能是原本存在的
51
- */
52
- add2(value: T): T;
53
- /**
54
- *
55
- * 添加并返回添加成功的对象:可能是新加入集合的,也可能是原本存在的
56
- * @param {T} values
57
- * @returns {T}
58
- */
59
- addAll2(values: T[]): T[];
60
- /**
61
- * 用key找到匹配的第一个对象
62
- * @param {*} key 这是对象的关键属性,而非对象
63
- * @returns {(T | null)}
64
- */
65
- find(key: T[keyof T]): T | null;
66
- /**
67
- * 用key找到匹配的所有对象
68
- * @param {*} key 这是对象的关键属性,而非对象
69
- * @returns {T[]}
70
- */
71
- findAll(key: T[keyof T]): T[];
72
- /**
73
- *
74
- * 用函数回调找到匹配的第一个对象
75
- * @param {(item: T) => boolean} fn
76
- * @returns {T[]}
77
- */
78
- filter(fn: (item: T) => boolean): T | null;
79
- /**
80
- *
81
- * 用函数回调找到匹配的所有对象
82
- * @param {(item: T) => boolean} fn
83
- * @returns {T[]}
84
- */
85
- filterAll(fn: (item: T) => boolean): T[];
86
- /**
87
- *
88
- * 是否存在key对应的对象
89
- * @param {*} value 这是对象的关键属性,而非对象
90
- * @returns {boolean}
91
- */
92
- has(key: T[keyof T]): boolean;
93
- /**
94
- * 转为数组
95
- * @param param0
96
- * @returns
97
- */
98
- toArray({ sort, each, filter, map }?: {
99
- sort?: (a: T, b: T) => number;
100
- each?: (a: T) => void;
101
- filter?: (a: T) => boolean;
102
- map?: (a: T) => T;
103
- }): T[];
104
- /**
105
- * 转为JSON对象
106
- * @param key
107
- * @param value
108
- * @param param2
109
- * @returns
110
- */
111
- toJSON<L = T>(key: keyof T, value?: keyof T, { sort, each, filter, map }?: {
112
- sort?: (a: T, b: T) => number;
113
- each?: (a: T) => void;
114
- filter?: (a: T) => boolean;
115
- map?: (a: T) => T;
116
- }): {
117
- [k: string]: L;
118
- };
119
- /**
120
- *
121
- * 删除key对应的对象
122
- * @param {*} _key 这是对象的关键属性,而非对象
123
- * @returns {boolean}
124
- */
125
- delete(_key: T[keyof T]): boolean;
126
- /**
127
- *
128
- * 重置
129
- * @param {keyof T} key
130
- * @param {(oldData: T, newData: T) => void} [onExist]
131
- * @param {boolean} [replaceWhenExits=false]
132
- */
133
- reset(option: {
134
- key?: keyof T;
135
- /** add&addAll触发 */
136
- onExist1?: (oldData: T, newData: T) => void;
137
- /** add&addAll触发 */
138
- onNotExist1?: (newData: T) => void;
139
- /** add&addAll触发 */
140
- replaceIfExits1?: boolean;
141
- /** add2&addAll2触发 */
142
- onExist2?: (oldData: T, newData: T) => void;
143
- /** add2&addAll2触发 */
144
- onNotExist2?: (newData: T) => void;
145
- /** add2&addAll2触发 */
146
- replaceIfExits2?: boolean;
147
- values?: ReadonlyArray<T> | null;
148
- }): this;
149
- /**
150
- *
151
- * @param param0 转为JSON对象,value可能是数组
152
- * @returns
153
- */
154
- toJSONArray({ sort, each, filter, map }?: {
155
- sort?: (a: T, b: T) => number;
156
- each?: (a: T) => void;
157
- filter?: (a: T) => boolean;
158
- map?: (a: T) => T;
159
- }): {
160
- [k: string]: T[keyof T][];
161
- };
162
- /**
163
- * 转为hot-table支持的数组
164
- * @param param0
165
- * @param keys
166
- * @returns
167
- */
168
- toDataGrid({ sort, each, filter, map }?: {
169
- sort?: (a: T, b: T) => number;
170
- each?: (a: T) => void;
171
- filter?: (a: T) => boolean;
172
- map?: (a: T) => T;
173
- }, ...keys: (keyof T)[]): (keyof T | T[keyof T])[][];
174
- /**
175
- * 转为饼图支持的数组
176
- * @param param0
177
- * @param keys
178
- * @returns
179
- */
180
- toPieGrid({ sort, each, filter, map }?: {
181
- sort?: (a: T, b: T) => number;
182
- each?: (a: T) => void;
183
- filter?: (a: T) => boolean;
184
- map?: (a: T) => T;
185
- }, ...keys: (keyof T)[]): {
186
- [k: string]: {
187
- value: T[keyof T];
188
- name: T[keyof T];
189
- }[];
190
- };
191
- set onExist1(onExist1: ((oldData: T, newData: T) => void) | undefined);
192
- set onExist2(onExist2: ((oldData: T, newData: T) => void) | undefined);
193
- set onNotExist1(onNotExist1: ((newData: T) => void) | undefined);
194
- set onNotExist2(onNotExist2: ((newData: T) => void) | undefined);
195
- set replaceIfExits1(replaceIfExits1: boolean);
196
- set replaceIfExits2(replaceIfExits2: boolean);
197
- set key(key: keyof T);
198
- }