baja-lite 1.6.2 → 1.6.4
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/.eslintignore +7 -0
- package/.eslintrc.cjs +89 -0
- package/.prettierrc +7 -0
- package/.vscode/settings.json +9 -0
- package/ci.js +33 -0
- package/package-cjs.json +17 -0
- package/package.json +80 -80
- package/pnpm-lock.yaml +2840 -0
- package/pnpm-workspace.yaml +2 -0
- package/{boot-remote.js → src/boot-remote.ts} +64 -63
- package/{boot.js → src/boot.ts} +170 -163
- package/{code.js → src/code.ts} +526 -517
- package/{convert-xml.js → src/convert-xml.ts} +460 -410
- package/src/error.ts +11 -0
- package/src/event.ts +34 -0
- package/src/fn.ts +295 -0
- package/{index.d.ts → src/index.ts} +11 -10
- package/src/math.ts +405 -0
- package/src/object.ts +342 -0
- package/{snowflake.js → src/snowflake.ts} +127 -108
- package/src/sql.ts +5529 -0
- package/{sqlite.js → src/sqlite.ts} +157 -156
- package/src/string.ts +111 -0
- package/src/test-mysql.ts +148 -0
- package/{test-postgresql.js → src/test-postgresql.ts} +80 -91
- package/{test-sqlite.js → src/test-sqlite.ts} +80 -90
- package/{test-xml.js → src/test-xml.ts} +70 -70
- package/{test.js → src/test.ts} +3 -2
- package/src/wx/base.ts +77 -0
- package/src/wx/mini.ts +147 -0
- package/src/wx/organ.ts +290 -0
- package/{wx/types.d.ts → src/wx/types.ts} +549 -560
- package/{wx.d.ts → src/wx.ts} +3 -3
- package/tsconfig.cjs.json +42 -0
- package/tsconfig.json +44 -0
- package/xml/event-report.xml +13 -0
- package/yarn.lock +1977 -0
- package/boot-remote.d.ts +0 -2
- package/boot.d.ts +0 -2
- package/code.d.ts +0 -2
- package/convert-xml.d.ts +0 -10
- package/error.d.ts +0 -5
- package/error.js +0 -13
- package/event.d.ts +0 -10
- package/event.js +0 -38
- package/fn.d.ts +0 -128
- package/fn.js +0 -172
- package/index.js +0 -10
- package/math.d.ts +0 -83
- package/math.js +0 -451
- package/object.d.ts +0 -126
- package/object.js +0 -321
- package/snowflake.d.ts +0 -12
- package/sql.d.ts +0 -2148
- package/sql.js +0 -5372
- package/sqlite.d.ts +0 -32
- package/string.d.ts +0 -17
- package/string.js +0 -105
- package/test-mysql.d.ts +0 -2
- package/test-mysql.js +0 -114
- package/test-postgresql.d.ts +0 -2
- package/test-sqlite.d.ts +0 -1
- package/test-xml.d.ts +0 -1
- package/test.d.ts +0 -1
- package/wx/base.d.ts +0 -11
- package/wx/base.js +0 -78
- package/wx/mini.d.ts +0 -52
- package/wx/mini.js +0 -112
- package/wx/organ.d.ts +0 -65
- package/wx/organ.js +0 -171
- package/wx/types.js +0 -1
- package/wx.js +0 -3
- /package/{README.md → Readme.md} +0 -0
package/math.js
DELETED
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
11
|
-
import Decimal from 'decimal.js';
|
|
12
|
-
/** 金钱格式化可用样式 */
|
|
13
|
-
export class MoneyOption {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.style = 'currency';
|
|
16
|
-
this.currency = 'CNY';
|
|
17
|
-
this.prefix = 2;
|
|
18
|
-
this.def = 0;
|
|
19
|
-
this.currencyDisplay = 'symbol';
|
|
20
|
-
this.useGrouping = true;
|
|
21
|
-
this.local = 'zh';
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
// const ONE = new Decimal(1);
|
|
25
|
-
const ZERO = new Decimal(0);
|
|
26
|
-
function isNum(a) {
|
|
27
|
-
return a !== '' && a !== null && !isNaN(a);
|
|
28
|
-
}
|
|
29
|
-
export const num = (val, def = 0) => {
|
|
30
|
-
if (val instanceof Bus) {
|
|
31
|
-
return val.over();
|
|
32
|
-
}
|
|
33
|
-
else if (!isNum(val)) {
|
|
34
|
-
return def;
|
|
35
|
-
}
|
|
36
|
-
return +val;
|
|
37
|
-
};
|
|
38
|
-
function filterNumber(array) {
|
|
39
|
-
const res = [];
|
|
40
|
-
array.forEach((element) => {
|
|
41
|
-
if (element instanceof Bus) {
|
|
42
|
-
res.push(element.over());
|
|
43
|
-
}
|
|
44
|
-
else if (isNum(element)) {
|
|
45
|
-
res.push(+element);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
return res;
|
|
49
|
-
}
|
|
50
|
-
function filterNumber2(array, def) {
|
|
51
|
-
const res = [];
|
|
52
|
-
array.forEach((element) => {
|
|
53
|
-
if (element instanceof Bus) {
|
|
54
|
-
res.push(new Decimal(element.over()));
|
|
55
|
-
}
|
|
56
|
-
else if (isNum(element)) {
|
|
57
|
-
res.push(new Decimal(element));
|
|
58
|
-
}
|
|
59
|
-
else if (def !== undefined) {
|
|
60
|
-
res.push(new Decimal(def));
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
return res;
|
|
64
|
-
}
|
|
65
|
-
export const max = (...args) => {
|
|
66
|
-
const arr = filterNumber(args);
|
|
67
|
-
return Math.max.apply(null, arr);
|
|
68
|
-
};
|
|
69
|
-
export const min = (...args) => {
|
|
70
|
-
const arr = filterNumber(args);
|
|
71
|
-
return Math.min.apply(null, arr);
|
|
72
|
-
};
|
|
73
|
-
export const div = (...args) => {
|
|
74
|
-
const arr = filterNumber2(args);
|
|
75
|
-
if (arr.length > 1) {
|
|
76
|
-
return arr.reduce((a, b) => a.div(b)).toNumber();
|
|
77
|
-
}
|
|
78
|
-
else if (arr.length > 0) {
|
|
79
|
-
return arr[0].toNumber();
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
return 0;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
export const divDef = (def, ...args) => {
|
|
86
|
-
const arr = filterNumber2(args);
|
|
87
|
-
if (arr.length > 1) {
|
|
88
|
-
const zeros = arr.slice(1).findIndex(i => i.equals(ZERO));
|
|
89
|
-
if (zeros > -1) {
|
|
90
|
-
return new Decimal(def).toNumber();
|
|
91
|
-
}
|
|
92
|
-
return arr.reduce((a, b) => a.div(b)).toNumber();
|
|
93
|
-
}
|
|
94
|
-
else if (arr.length > 0) {
|
|
95
|
-
return arr[0].toNumber();
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
return 0;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
export const add = (...args) => {
|
|
102
|
-
const arr = filterNumber2(args);
|
|
103
|
-
if (arr.length > 1) {
|
|
104
|
-
return arr.reduce((a, b) => a.add(b)).toNumber();
|
|
105
|
-
}
|
|
106
|
-
else if (arr.length > 0) {
|
|
107
|
-
return arr[0].toNumber();
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
return 0;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
export const mul = (...args) => {
|
|
114
|
-
const arr = filterNumber2(args);
|
|
115
|
-
if (arr.length > 1) {
|
|
116
|
-
return arr.reduce((a, b) => a.mul(b)).toNumber();
|
|
117
|
-
}
|
|
118
|
-
else if (arr.length > 0) {
|
|
119
|
-
return arr[0].toNumber();
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
return 0;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
export const sub = (...args) => {
|
|
126
|
-
const arr = filterNumber2(args, 0);
|
|
127
|
-
if (arr.length > 1) {
|
|
128
|
-
return arr.reduce((a, b) => a.sub(b)).toNumber();
|
|
129
|
-
}
|
|
130
|
-
else if (arr.length > 0) {
|
|
131
|
-
return arr[0].toNumber();
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
return 0;
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
const roundMode = [Decimal.ROUND_HALF_UP, Decimal.ROUND_UP, Decimal.ROUND_DOWN];
|
|
138
|
-
export const round = (number, numDigits, upOrDown = 0) => {
|
|
139
|
-
if (isNum(number)) {
|
|
140
|
-
const nu = new Decimal(number);
|
|
141
|
-
return nu.toDP(numDigits, roundMode[upOrDown]).toNumber();
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
return 0;
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
/** =value.xx,其中xx=number,如number=99,表示修正数字为value.99 */
|
|
148
|
-
export const merge = function (value, number) {
|
|
149
|
-
if (isNum(value) && isNum(number)) {
|
|
150
|
-
return new Decimal(value).floor().add(`0.${number}`).toNumber();
|
|
151
|
-
}
|
|
152
|
-
else if (isNum(value)) {
|
|
153
|
-
return value;
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
return 0;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
export const money = (value, option = {}) => {
|
|
160
|
-
// Intl.NumberFormat(option.local ?? 'zh', {
|
|
161
|
-
// style: option.style ?? 'currency',
|
|
162
|
-
// currency: option.currency ?? 'CNY',
|
|
163
|
-
// minimumFractionDigits: option.prefix ?? 2,
|
|
164
|
-
// currencyDisplay: option.currencyDisplay ?? 'symbol',
|
|
165
|
-
// useGrouping: option.useGrouping ?? true
|
|
166
|
-
// }).format(isNum(value) ? value : option.def).replace(/CN|\s/g, '');
|
|
167
|
-
return (isNum(value) ? value : option.def).toLocaleString(option.local ?? 'zh', {
|
|
168
|
-
style: option.style ?? 'currency',
|
|
169
|
-
currency: option.currency ?? 'CNY',
|
|
170
|
-
minimumFractionDigits: option.prefix ?? 2,
|
|
171
|
-
currencyDisplay: option.currencyDisplay ?? 'symbol',
|
|
172
|
-
useGrouping: option.useGrouping ?? true
|
|
173
|
-
}).replace(/CN|\s/g, '');
|
|
174
|
-
};
|
|
175
|
-
const IF = function () {
|
|
176
|
-
return function (_target, _propertyKey, descriptor) {
|
|
177
|
-
const fn = descriptor.value;
|
|
178
|
-
descriptor.value = function () {
|
|
179
|
-
if (this['ifit'] === true) {
|
|
180
|
-
// eslint-disable-next-line prefer-rest-params
|
|
181
|
-
const args = Array.from(arguments);
|
|
182
|
-
fn.call(this, ...args);
|
|
183
|
-
}
|
|
184
|
-
this['ifit'] = true;
|
|
185
|
-
return this;
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
export class Bus {
|
|
190
|
-
constructor(result) {
|
|
191
|
-
this.ifit = true;
|
|
192
|
-
this.result = num(result);
|
|
193
|
-
}
|
|
194
|
-
add(...args) {
|
|
195
|
-
this.result = add(this.result, ...args);
|
|
196
|
-
return this;
|
|
197
|
-
}
|
|
198
|
-
sub(...args) {
|
|
199
|
-
this.result = sub(this.result, ...args);
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
div(...args) {
|
|
203
|
-
this.result = div(this.result, ...args);
|
|
204
|
-
return this;
|
|
205
|
-
}
|
|
206
|
-
divDef(def, ...args) {
|
|
207
|
-
this.result = divDef(def, this.result, ...args);
|
|
208
|
-
return this;
|
|
209
|
-
}
|
|
210
|
-
mul(...args) {
|
|
211
|
-
this.result = mul(this.result, ...args);
|
|
212
|
-
return this;
|
|
213
|
-
}
|
|
214
|
-
max(...args) {
|
|
215
|
-
this.result = max(this.result, ...args);
|
|
216
|
-
return this;
|
|
217
|
-
}
|
|
218
|
-
min(...args) {
|
|
219
|
-
this.result = min(this.result, ...args);
|
|
220
|
-
return this;
|
|
221
|
-
}
|
|
222
|
-
ac() {
|
|
223
|
-
this.result = sub(0, this.result);
|
|
224
|
-
return this;
|
|
225
|
-
}
|
|
226
|
-
abs() {
|
|
227
|
-
this.result = Math.abs(this.result);
|
|
228
|
-
return this;
|
|
229
|
-
}
|
|
230
|
-
round(numDigits, upOrDown) {
|
|
231
|
-
this.result = round(this.result, numDigits, upOrDown);
|
|
232
|
-
return this;
|
|
233
|
-
}
|
|
234
|
-
merge(number) {
|
|
235
|
-
this.result = merge(this.result, number);
|
|
236
|
-
return this;
|
|
237
|
-
}
|
|
238
|
-
if(condition) {
|
|
239
|
-
this.ifit = condition;
|
|
240
|
-
return this;
|
|
241
|
-
}
|
|
242
|
-
over() {
|
|
243
|
-
return this.result;
|
|
244
|
-
}
|
|
245
|
-
money(option) {
|
|
246
|
-
return money(this.result, option);
|
|
247
|
-
}
|
|
248
|
-
lt(data) {
|
|
249
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
250
|
-
return r.lessThan(d);
|
|
251
|
-
}
|
|
252
|
-
le(data) {
|
|
253
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
254
|
-
return r.lessThanOrEqualTo(d);
|
|
255
|
-
}
|
|
256
|
-
gt(data) {
|
|
257
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
258
|
-
return r.greaterThan(d);
|
|
259
|
-
}
|
|
260
|
-
ge(data) {
|
|
261
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
262
|
-
return r.greaterThanOrEqualTo(d);
|
|
263
|
-
}
|
|
264
|
-
nlt(data) {
|
|
265
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
266
|
-
return !r.lessThan(d);
|
|
267
|
-
}
|
|
268
|
-
nle(data) {
|
|
269
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
270
|
-
return !r.lessThanOrEqualTo(d);
|
|
271
|
-
}
|
|
272
|
-
ngt(data) {
|
|
273
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
274
|
-
return !r.greaterThan(d);
|
|
275
|
-
}
|
|
276
|
-
nge(data) {
|
|
277
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
278
|
-
return !r.greaterThanOrEqualTo(d);
|
|
279
|
-
}
|
|
280
|
-
eq(data) {
|
|
281
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
282
|
-
return r.equals(d);
|
|
283
|
-
}
|
|
284
|
-
ne(data) {
|
|
285
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
286
|
-
return !r.eq(d);
|
|
287
|
-
}
|
|
288
|
-
ifLt(data) {
|
|
289
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
290
|
-
this.ifit = r.lessThan(d);
|
|
291
|
-
return this;
|
|
292
|
-
}
|
|
293
|
-
ifLe(data) {
|
|
294
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
295
|
-
this.ifit = r.lessThanOrEqualTo(d);
|
|
296
|
-
return this;
|
|
297
|
-
}
|
|
298
|
-
ifGt(data) {
|
|
299
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
300
|
-
this.ifit = r.greaterThan(d);
|
|
301
|
-
return this;
|
|
302
|
-
}
|
|
303
|
-
ifGe(data) {
|
|
304
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
305
|
-
this.ifit = r.greaterThanOrEqualTo(d);
|
|
306
|
-
return this;
|
|
307
|
-
}
|
|
308
|
-
ifNlt(data) {
|
|
309
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
310
|
-
this.ifit = !r.lessThan(d);
|
|
311
|
-
return this;
|
|
312
|
-
}
|
|
313
|
-
ifNle(data) {
|
|
314
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
315
|
-
this.ifit = !r.lessThanOrEqualTo(d);
|
|
316
|
-
return this;
|
|
317
|
-
}
|
|
318
|
-
ifNgt(data) {
|
|
319
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
320
|
-
this.ifit = !r.greaterThan(d);
|
|
321
|
-
return this;
|
|
322
|
-
}
|
|
323
|
-
ifNge(data) {
|
|
324
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
325
|
-
this.ifit = !r.greaterThanOrEqualTo(d);
|
|
326
|
-
return this;
|
|
327
|
-
}
|
|
328
|
-
ifEq(data) {
|
|
329
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
330
|
-
this.ifit = r.equals(d);
|
|
331
|
-
return this;
|
|
332
|
-
}
|
|
333
|
-
ifNe(data) {
|
|
334
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
335
|
-
this.ifit = !r.eq(d);
|
|
336
|
-
return this;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
__decorate([
|
|
340
|
-
IF(),
|
|
341
|
-
__metadata("design:type", Function),
|
|
342
|
-
__metadata("design:paramtypes", [Object]),
|
|
343
|
-
__metadata("design:returntype", Object)
|
|
344
|
-
], Bus.prototype, "add", null);
|
|
345
|
-
__decorate([
|
|
346
|
-
IF(),
|
|
347
|
-
__metadata("design:type", Function),
|
|
348
|
-
__metadata("design:paramtypes", [Object]),
|
|
349
|
-
__metadata("design:returntype", Object)
|
|
350
|
-
], Bus.prototype, "sub", null);
|
|
351
|
-
__decorate([
|
|
352
|
-
IF(),
|
|
353
|
-
__metadata("design:type", Function),
|
|
354
|
-
__metadata("design:paramtypes", [Object]),
|
|
355
|
-
__metadata("design:returntype", Object)
|
|
356
|
-
], Bus.prototype, "div", null);
|
|
357
|
-
__decorate([
|
|
358
|
-
IF(),
|
|
359
|
-
__metadata("design:type", Function),
|
|
360
|
-
__metadata("design:paramtypes", [Object, Object]),
|
|
361
|
-
__metadata("design:returntype", Object)
|
|
362
|
-
], Bus.prototype, "divDef", null);
|
|
363
|
-
__decorate([
|
|
364
|
-
IF(),
|
|
365
|
-
__metadata("design:type", Function),
|
|
366
|
-
__metadata("design:paramtypes", [Object]),
|
|
367
|
-
__metadata("design:returntype", Object)
|
|
368
|
-
], Bus.prototype, "mul", null);
|
|
369
|
-
__decorate([
|
|
370
|
-
IF(),
|
|
371
|
-
__metadata("design:type", Function),
|
|
372
|
-
__metadata("design:paramtypes", [Object]),
|
|
373
|
-
__metadata("design:returntype", Object)
|
|
374
|
-
], Bus.prototype, "max", null);
|
|
375
|
-
__decorate([
|
|
376
|
-
IF(),
|
|
377
|
-
__metadata("design:type", Function),
|
|
378
|
-
__metadata("design:paramtypes", [Object]),
|
|
379
|
-
__metadata("design:returntype", Object)
|
|
380
|
-
], Bus.prototype, "min", null);
|
|
381
|
-
__decorate([
|
|
382
|
-
IF(),
|
|
383
|
-
__metadata("design:type", Function),
|
|
384
|
-
__metadata("design:paramtypes", []),
|
|
385
|
-
__metadata("design:returntype", Object)
|
|
386
|
-
], Bus.prototype, "ac", null);
|
|
387
|
-
__decorate([
|
|
388
|
-
IF(),
|
|
389
|
-
__metadata("design:type", Function),
|
|
390
|
-
__metadata("design:paramtypes", []),
|
|
391
|
-
__metadata("design:returntype", Object)
|
|
392
|
-
], Bus.prototype, "abs", null);
|
|
393
|
-
__decorate([
|
|
394
|
-
IF(),
|
|
395
|
-
__metadata("design:type", Function),
|
|
396
|
-
__metadata("design:paramtypes", [Number, Number]),
|
|
397
|
-
__metadata("design:returntype", Object)
|
|
398
|
-
], Bus.prototype, "round", null);
|
|
399
|
-
__decorate([
|
|
400
|
-
IF(),
|
|
401
|
-
__metadata("design:type", Function),
|
|
402
|
-
__metadata("design:paramtypes", [Object]),
|
|
403
|
-
__metadata("design:returntype", void 0)
|
|
404
|
-
], Bus.prototype, "merge", null);
|
|
405
|
-
export const calc = (result) => {
|
|
406
|
-
return new Bus(result);
|
|
407
|
-
};
|
|
408
|
-
export const getGeo = (p1, p2) => {
|
|
409
|
-
p1.lat = calc(p1.latitude).mul(Math.PI).div(180).over();
|
|
410
|
-
p1.long = calc(p1.longitude).mul(Math.PI).div(180).over();
|
|
411
|
-
p2.lat = calc(p2.latitude).mul(Math.PI).div(180).over();
|
|
412
|
-
p2.long = calc(p2.longitude).mul(Math.PI).div(180).over();
|
|
413
|
-
return calc(Math.round(mul(Math.asin(Math.sqrt(add(Math.pow(Math.sin(div(sub(p1.lat, p2.lat), 2)), 2), mul(Math.cos(p1.lat), Math.cos(p2.lat), Math.pow(Math.sin(div(sub(p1.long, p2.long), 2)), 2))))), 2, 6378.137, 10000))).div(10000).round(2).over();
|
|
414
|
-
};
|
|
415
|
-
const ZM = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
416
|
-
/**
|
|
417
|
-
* 十进制转换自定义进制
|
|
418
|
-
* @param from 数字
|
|
419
|
-
* @param to 自定义进制的字符
|
|
420
|
-
* @returns
|
|
421
|
-
*/
|
|
422
|
-
export function ten2Any(from, to = ZM) {
|
|
423
|
-
let result = '';
|
|
424
|
-
const length = to.length;
|
|
425
|
-
while (from > 0) {
|
|
426
|
-
from--;
|
|
427
|
-
let remainder = from % length;
|
|
428
|
-
result = to.charAt(remainder) + result;
|
|
429
|
-
from = Math.floor(from / length);
|
|
430
|
-
}
|
|
431
|
-
return result;
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* 自定义进制转换十进制
|
|
435
|
-
* @param from
|
|
436
|
-
* @param to
|
|
437
|
-
* @returns
|
|
438
|
-
*/
|
|
439
|
-
export function any2Ten(from, to = ZM) {
|
|
440
|
-
let decimal = 0;
|
|
441
|
-
from = from.toUpperCase();
|
|
442
|
-
for (let i = 0; i < from.length; i++) {
|
|
443
|
-
const char = from[from.length - 1 - i].toUpperCase();
|
|
444
|
-
const index = to.indexOf(char);
|
|
445
|
-
if (index > -1) {
|
|
446
|
-
const value = to.indexOf(char) + 1;
|
|
447
|
-
decimal += value * Math.pow(26, i);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
return decimal;
|
|
451
|
-
}
|
package/object.d.ts
DELETED
|
@@ -1,126 +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
|
-
/**
|
|
60
|
-
* 1. 统计array中某个字段key的数量:{ [k: string]: number }
|
|
61
|
-
*
|
|
62
|
-
* @param array T组成的array,数据源
|
|
63
|
-
* @param key 返回结果{ [k: string]: number }的key
|
|
64
|
-
* @param defKey 如果array中某个对象没有key字段,则归类到默认key中
|
|
65
|
-
* @returns
|
|
66
|
-
*/
|
|
67
|
-
export declare const mixArray: <T>(array: T[], key: keyof T, defKey?: string) => {
|
|
68
|
-
[key: string]: number;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* 1. 将T组成的array按照某个字段(key)提取为{ [key: string]: V[] }
|
|
72
|
-
* @param array T组成的array,数据源
|
|
73
|
-
* @param key 返回结果{ [key: string]: V[] }的key
|
|
74
|
-
* @param value 返回结果{ [key: string]: V[] }中的V可以是T,也可以是T的某个字段(指定value参数)
|
|
75
|
-
* @param defKey 如果array中某个对象没有key字段,则归类到默认key中
|
|
76
|
-
* @returns
|
|
77
|
-
*/
|
|
78
|
-
export declare const mixList: <T, V = T>(array: T[], key: keyof T, value?: keyof T, defKey?: string) => {
|
|
79
|
-
[key: string]: V[];
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* ## 仿照Object.assign的数组方法
|
|
83
|
-
* ### 1. 用法参照
|
|
84
|
-
* ```
|
|
85
|
-
* // ID 是 数组中对象的关键字段,用来区分同一条记录.支持多个字段(联合主键场景)
|
|
86
|
-
* // 与assign的逻辑相同,后面的数组会覆盖前面数组的相同对象的同名字段
|
|
87
|
-
* const result = assignArray('ID', Array1, Array2, Array3...);
|
|
88
|
-
* ```
|
|
89
|
-
* @param key
|
|
90
|
-
* @param arrays
|
|
91
|
-
* @returns
|
|
92
|
-
*/
|
|
93
|
-
export declare const assignArray: <T>(key: keyof T | (keyof T)[] | ((t1: T, t2: T) => boolean), ...arrays: T[][]) => T[];
|
|
94
|
-
export declare const array2map: <T = string | number>(array: string[], v: T) => {
|
|
95
|
-
[key: string]: T;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* 数组分割
|
|
99
|
-
* @param datas
|
|
100
|
-
* @param config(二选一) everyLength=每组个数(最后一组可能不足次数), groupCount=拆分几组
|
|
101
|
-
* @returns T[][]
|
|
102
|
-
*/
|
|
103
|
-
export declare const arraySplit: <T = any>(datas: T[], { everyLength, groupCount }?: {
|
|
104
|
-
everyLength?: number | undefined;
|
|
105
|
-
groupCount?: number | undefined;
|
|
106
|
-
}) => T[][];
|
|
107
|
-
/**
|
|
108
|
-
* 合并对象(浅),忽略后续参数的null、undefined、空字符串
|
|
109
|
-
* @param source
|
|
110
|
-
* @param os
|
|
111
|
-
* @returns
|
|
112
|
-
*/
|
|
113
|
-
export declare const assginObject: <T extends Object>(source: T, ...os: T[]) => void;
|
|
114
|
-
/**
|
|
115
|
-
* 去除数组中重复数据,同时可以通过each函数为每个数据执行某项操作
|
|
116
|
-
* @param source
|
|
117
|
-
* @param each
|
|
118
|
-
*/
|
|
119
|
-
export declare const distinctArray: <T extends Object>(source: T[], keys: (keyof T)[], each?: (data: T) => void) => T[];
|
|
120
|
-
export declare const P2C: (pro: string, IF?: boolean) => string;
|
|
121
|
-
export declare const C2P: (pro: string, IF?: boolean) => string;
|
|
122
|
-
export declare function C2P2<T extends Object = any, L extends Object = T>(datas: L[], hump?: boolean, convert?: Record<string, (data: any) => any>): T[];
|
|
123
|
-
export declare function C2P2<T extends Object = any, L extends Object = T>(datas: L, hump?: boolean, convert?: Record<string, (data: any) => any>): T;
|
|
124
|
-
export declare function P2C2<T extends Object = any, L extends Object = T>(datas: L[]): T[];
|
|
125
|
-
export declare function P2C2<T extends Object = any, L extends Object = T>(datas: L): T;
|
|
126
|
-
export declare function fillArrayToMinLength<T>(arr: T[], minLength: number, fillValue: T): T[];
|