baja-lite 1.3.25 → 1.3.27

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 (74) hide show
  1. package/.eslintignore +7 -0
  2. package/.eslintrc.cjs +89 -0
  3. package/.prettierrc +4 -0
  4. package/.vscode/settings.json +8 -0
  5. package/ci.js +29 -0
  6. package/package-cjs.json +17 -0
  7. package/package.json +2 -2
  8. package/{boot-remote.js → src/boot-remote.ts} +7 -6
  9. package/{boot.js → src/boot.ts} +38 -31
  10. package/{code.js → src/code.ts} +66 -71
  11. package/{convert-xml.js → src/convert-xml.ts} +155 -105
  12. package/src/enum.ts +71 -0
  13. package/src/error.ts +11 -0
  14. package/src/fn.ts +295 -0
  15. package/{index.d.ts → src/index.ts} +12 -11
  16. package/{list.js → src/list.ts} +9 -8
  17. package/src/math.ts +405 -0
  18. package/src/object.ts +247 -0
  19. package/{snowflake.js → src/snowflake.ts} +52 -33
  20. package/src/sql.ts +5023 -0
  21. package/{sqlite.js → src/sqlite.ts} +52 -53
  22. package/src/string.ts +111 -0
  23. package/src/test-mysql.ts +144 -0
  24. package/{test-postgresql.js → src/test-postgresql.ts} +80 -91
  25. package/{test-sqlite.js → src/test-sqlite.ts} +80 -90
  26. package/{test-xml.js → src/test-xml.ts} +1 -1
  27. package/{test.js → src/test.ts} +3 -2
  28. package/src/wx/base.ts +76 -0
  29. package/src/wx/mini.ts +147 -0
  30. package/src/wx/organ.ts +290 -0
  31. package/{wx/types.d.ts → src/wx/types.ts} +10 -21
  32. package/tsconfig.cjs.json +42 -0
  33. package/tsconfig.json +44 -0
  34. package/tsconfig.tsbuildinfo +1 -0
  35. package/xml/event-report.xml +13 -0
  36. package/yarn.lock +1757 -0
  37. package/boot-remote.d.ts +0 -2
  38. package/boot.d.ts +0 -2
  39. package/code.d.ts +0 -2
  40. package/convert-xml.d.ts +0 -10
  41. package/enum.d.ts +0 -18
  42. package/enum.js +0 -59
  43. package/error.d.ts +0 -5
  44. package/error.js +0 -13
  45. package/fn.d.ts +0 -128
  46. package/fn.js +0 -172
  47. package/index.js +0 -11
  48. package/list.d.ts +0 -10
  49. package/math.d.ts +0 -83
  50. package/math.js +0 -451
  51. package/object.d.ts +0 -83
  52. package/object.js +0 -221
  53. package/snowflake.d.ts +0 -12
  54. package/sql.d.ts +0 -1788
  55. package/sql.js +0 -4765
  56. package/sqlite.d.ts +0 -32
  57. package/string.d.ts +0 -17
  58. package/string.js +0 -105
  59. package/test-mysql.d.ts +0 -2
  60. package/test-mysql.js +0 -109
  61. package/test-postgresql.d.ts +0 -2
  62. package/test-sqlite.d.ts +0 -1
  63. package/test-xml.d.ts +0 -1
  64. package/test.d.ts +0 -1
  65. package/wx/base.d.ts +0 -11
  66. package/wx/base.js +0 -78
  67. package/wx/mini.d.ts +0 -52
  68. package/wx/mini.js +0 -112
  69. package/wx/organ.d.ts +0 -65
  70. package/wx/organ.js +0 -171
  71. package/wx/types.js +0 -1
  72. package/wx.js +0 -3
  73. /package/{README.md → Readme.md} +0 -0
  74. /package/{wx.d.ts → src/wx.ts} +0 -0
package/object.js DELETED
@@ -1,221 +0,0 @@
1
- import iterate from "iterare";
2
- /**
3
- * 对象对象(等同与convertBean)
4
- * 仅会将classType有的属性进行转换
5
- * * 相当与一次属性过滤
6
- * @param source
7
- * @param classType
8
- */
9
- export const copyBean = (source, classType) => {
10
- const result = {};
11
- Object.keys(classType).forEach((key) => {
12
- result[key] =
13
- source[key] !== undefined ? source[key] : (result[key] = null);
14
- });
15
- return result;
16
- };
17
- /**
18
- * 对象转换(等同与copyBean)
19
- * 仅会将classType有的属性进行转换
20
- * 相当与一次属性过滤
21
- * @param source
22
- * @param classType
23
- */
24
- export const convertBean = copyBean;
25
- /**
26
- * 批量对象转换(等同与copyBean)
27
- * 仅会将classType有的属性进行转换
28
- * 相当与一次属性过滤
29
- * @param source
30
- * @param classType
31
- */
32
- export const convertBeans = (source, classType, cb) => {
33
- const result = new Array();
34
- for (const bean of source) {
35
- const data = convertBean(bean, classType);
36
- if (cb) {
37
- cb(data, bean);
38
- }
39
- result.push(data);
40
- }
41
- return result;
42
- };
43
- /**
44
- * 创建一个空对象
45
- * 其内各属性都是null
46
- * @param classType
47
- */
48
- export const emptyBean = (classType) => {
49
- const target = {};
50
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
51
- Object.keys(classType).forEach((key) => {
52
- target[key] = null;
53
- });
54
- return target;
55
- };
56
- /**
57
- * 将一个json数组提取为一个json对象
58
- * @param source 源数组
59
- * @param key 作为新对象的key的字段
60
- * @param value 作为新对象value的字段,不传则将自身为value
61
- */
62
- export const createBeanFromArray = (source, key, value) => {
63
- const result = {};
64
- if (value) {
65
- source.forEach((item) => {
66
- if (item[key]) {
67
- result[`${item[key]}`] = item[value];
68
- }
69
- });
70
- }
71
- else {
72
- source.forEach((item) => {
73
- if (item[key]) {
74
- result[`${item[key]}`] = item;
75
- }
76
- });
77
- }
78
- return result;
79
- };
80
- /**
81
- * 转换复合对象为指定bean
82
- * @param source
83
- * @param classType
84
- */
85
- export const coverComplexBean = (source, classType) => {
86
- const result = {};
87
- const arrayData = {};
88
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
89
- for (const [key, value] of Object.entries(source)) {
90
- if (value instanceof Array) {
91
- arrayData[key] = value;
92
- }
93
- else if (typeof value === 'object') {
94
- Object.assign(result, value);
95
- }
96
- else {
97
- result[key] = value;
98
- }
99
- }
100
- return {
101
- data: convertBean(result, classType),
102
- array: arrayData
103
- };
104
- };
105
- /**
106
- * 将目标对象中为空的字段替换为source中对应key的值或者函数返回值
107
- * @param target
108
- * @param source
109
- */
110
- export const fixEmptyPrototy = async (target, source) => {
111
- for (const [key, fn] of Object.entries(source)) {
112
- if (!target[key]) {
113
- if (typeof fn === 'function') {
114
- target[key] = await fn();
115
- }
116
- else {
117
- target[key] = fn;
118
- }
119
- }
120
- }
121
- };
122
- export const mixArray = (array, key, defKey) => {
123
- const obj = array.map(item => item[key]);
124
- const result = {};
125
- for (const i of obj) {
126
- let ki = '';
127
- if (i !== undefined && i !== null) {
128
- ki = `${i}`;
129
- }
130
- else if (defKey) {
131
- ki = defKey;
132
- }
133
- if (!result[ki]) {
134
- result[ki] = 0;
135
- }
136
- result[ki]++;
137
- }
138
- return result;
139
- };
140
- export const mixList = (array, key, value, defKey) => {
141
- const result = {};
142
- for (const i of array) {
143
- let ki = '';
144
- if (i[key] !== undefined && i[key] !== null) {
145
- ki = `${i[key]}`;
146
- }
147
- else if (defKey) {
148
- ki = defKey;
149
- }
150
- if (!result[ki]) {
151
- result[ki] = [];
152
- }
153
- if (value) {
154
- result[ki].push(i[value]);
155
- }
156
- else {
157
- result[ki].push(i);
158
- }
159
- }
160
- return result;
161
- };
162
- export const array2map = (array, v) => {
163
- const ot = {};
164
- for (const item of array) {
165
- ot[item] = v;
166
- }
167
- return ot;
168
- };
169
- /**
170
- * 数组分割
171
- * @param datas
172
- * @param config(二选一) everyLength=每组个数(最后一组可能不足次数), groupCount=拆分几组
173
- * @returns T[][]
174
- */
175
- export const arraySplit = (datas, { everyLength = 0, groupCount = 0 } = {}) => {
176
- if (groupCount > 0) {
177
- everyLength = Math.floor(datas.length / groupCount + 0.9);
178
- const result = [];
179
- for (let i = 0; i < groupCount; i++) {
180
- result.push(datas.slice(i * everyLength, (i + 1) * everyLength));
181
- }
182
- return result;
183
- }
184
- else if (everyLength > 0) {
185
- groupCount = Math.ceil(datas.length / everyLength);
186
- const result = [];
187
- for (let i = 0; i < groupCount; i++) {
188
- result.push(datas.slice(i * everyLength, (i + 1) * everyLength));
189
- }
190
- return result;
191
- }
192
- else {
193
- throw new Error('参数错误!');
194
- }
195
- };
196
- const P2CEX = /[A-Z]/g;
197
- export const P2C = (pro, IF = true) => IF ? pro.replace(P2CEX, (a) => `_${a.toLowerCase()}`) : pro;
198
- const C2PEX = /_([a-z])/g;
199
- export const C2P = (pro, IF = true) => IF ? pro.replace(C2PEX, (a, b) => `${b.toUpperCase()}`) : pro;
200
- export function C2P2(datas) {
201
- if (datas instanceof Array) {
202
- return iterate(datas).map((data) => Object.fromEntries(Object.entries(data).map(([K, V]) => [C2P(K), V]))).toArray();
203
- }
204
- else if (datas) {
205
- return Object.fromEntries(Object.entries(datas).map(([K, V]) => [C2P(K), V]));
206
- }
207
- else {
208
- return datas;
209
- }
210
- }
211
- export function P2C2(datas) {
212
- if (datas instanceof Array) {
213
- return iterate(datas).map((data) => Object.fromEntries(Object.entries(data).map(([K, V]) => [P2C(K), V]))).toArray();
214
- }
215
- else if (datas) {
216
- return Object.fromEntries(Object.entries(datas).map(([K, V]) => [P2C(K), V]));
217
- }
218
- else {
219
- return datas;
220
- }
221
- }
package/snowflake.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export declare class Snowflake {
2
- private seq;
3
- private mid;
4
- private offset;
5
- private lastTime;
6
- constructor(options?: {
7
- mid?: number;
8
- offset?: number;
9
- });
10
- generate(): string | null;
11
- }
12
- export declare const snowflake: Snowflake;