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.
- package/{cjs/boot-remote.d.ts → boot-remote.d.ts} +1 -1
- package/{es/boot-remote.js → boot-remote.js} +2 -2
- package/{es/boot.d.ts → boot.d.ts} +1 -1
- package/{es/boot.js → boot.js} +2 -2
- package/{es/enum.js → enum.js} +1 -1
- package/{es/fn.js → fn.js} +2 -2
- package/index.d.ts +10 -0
- package/index.js +10 -0
- package/package.json +11 -12
- package/{cjs/sql.d.ts → sql.d.ts} +3 -3
- package/{es/sql.js → sql.js} +7 -7
- package/{es/sqlite.d.ts → sqlite.d.ts} +1 -1
- package/{es/sqlite.js → sqlite.js} +1 -1
- package/{es/test-mysql.js → test-mysql.js} +2 -2
- package/{es/test-postgresql.js → test-postgresql.js} +2 -2
- package/cjs/boot-remote.js +0 -49
- package/cjs/boot.d.ts +0 -2
- package/cjs/boot.js +0 -183
- package/cjs/code.js +0 -379
- package/cjs/convert-xml.js +0 -417
- package/cjs/enum.js +0 -64
- package/cjs/error.js +0 -16
- package/cjs/fn.js +0 -179
- package/cjs/index.d.ts +0 -10
- package/cjs/index.js +0 -26
- package/cjs/list.js +0 -60
- package/cjs/math.js +0 -474
- package/cjs/object.js +0 -242
- package/cjs/set-ex.js +0 -345
- package/cjs/sql.js +0 -5083
- package/cjs/sqlite.d.ts +0 -32
- package/cjs/sqlite.js +0 -169
- package/cjs/string.js +0 -119
- package/cjs/test-mysql.js +0 -138
- package/cjs/test-postgresql.js +0 -93
- package/cjs/test-sqlite.js +0 -91
- package/cjs/test-xml.js +0 -75
- package/cjs/test.js +0 -4
- package/es/boot-remote.d.ts +0 -2
- package/es/code.d.ts +0 -2
- package/es/convert-xml.d.ts +0 -10
- package/es/enum.d.ts +0 -18
- package/es/error.d.ts +0 -5
- package/es/fn.d.ts +0 -128
- package/es/index.d.ts +0 -10
- package/es/index.js +0 -10
- package/es/list.d.ts +0 -10
- package/es/math.d.ts +0 -83
- package/es/object.d.ts +0 -83
- package/es/set-ex.d.ts +0 -198
- package/es/sql.d.ts +0 -1858
- package/es/string.d.ts +0 -17
- package/es/test-mysql.d.ts +0 -2
- package/es/test-postgresql.d.ts +0 -2
- package/es/test-sqlite.d.ts +0 -1
- package/es/test-xml.d.ts +0 -1
- package/es/test.d.ts +0 -1
- package/src/boot-remote.ts +0 -46
- package/src/boot.ts +0 -153
- package/src/code.ts +0 -377
- package/src/convert-xml.ts +0 -460
- package/src/enum.ts +0 -71
- package/src/error.ts +0 -11
- package/src/fn.ts +0 -295
- package/src/index.ts +0 -10
- package/src/list.ts +0 -57
- package/src/math.ts +0 -405
- package/src/object.ts +0 -247
- package/src/set-ex.ts +0 -374
- package/src/sql.ts +0 -5281
- package/src/sqlite.ts +0 -161
- package/src/string.ts +0 -111
- package/src/test-mysql.ts +0 -126
- package/src/test-postgresql.ts +0 -79
- package/src/test-sqlite.ts +0 -80
- package/src/test-xml.ts +0 -70
- package/src/test.ts +0 -2
- /package/{cjs/code.d.ts → code.d.ts} +0 -0
- /package/{es/code.js → code.js} +0 -0
- /package/{cjs/convert-xml.d.ts → convert-xml.d.ts} +0 -0
- /package/{es/convert-xml.js → convert-xml.js} +0 -0
- /package/{cjs/enum.d.ts → enum.d.ts} +0 -0
- /package/{cjs/error.d.ts → error.d.ts} +0 -0
- /package/{es/error.js → error.js} +0 -0
- /package/{cjs/fn.d.ts → fn.d.ts} +0 -0
- /package/{cjs/list.d.ts → list.d.ts} +0 -0
- /package/{es/list.js → list.js} +0 -0
- /package/{cjs/math.d.ts → math.d.ts} +0 -0
- /package/{es/math.js → math.js} +0 -0
- /package/{cjs/object.d.ts → object.d.ts} +0 -0
- /package/{es/object.js → object.js} +0 -0
- /package/{cjs/set-ex.d.ts → set-ex.d.ts} +0 -0
- /package/{es/set-ex.js → set-ex.js} +0 -0
- /package/{cjs/string.d.ts → string.d.ts} +0 -0
- /package/{es/string.js → string.js} +0 -0
- /package/{cjs/test-mysql.d.ts → test-mysql.d.ts} +0 -0
- /package/{cjs/test-postgresql.d.ts → test-postgresql.d.ts} +0 -0
- /package/{cjs/test-sqlite.d.ts → test-sqlite.d.ts} +0 -0
- /package/{es/test-sqlite.js → test-sqlite.js} +0 -0
- /package/{cjs/test-xml.d.ts → test-xml.d.ts} +0 -0
- /package/{es/test-xml.js → test-xml.js} +0 -0
- /package/{cjs/test.d.ts → test.d.ts} +0 -0
- /package/{es/test.js → test.js} +0 -0
package/cjs/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
require("reflect-metadata");
|
|
18
|
-
__exportStar(require("./error"), exports);
|
|
19
|
-
__exportStar(require("./fn"), exports);
|
|
20
|
-
__exportStar(require("./math"), exports);
|
|
21
|
-
__exportStar(require("./object"), exports);
|
|
22
|
-
__exportStar(require("./set-ex"), exports);
|
|
23
|
-
__exportStar(require("./sql"), exports);
|
|
24
|
-
__exportStar(require("./string"), exports);
|
|
25
|
-
__exportStar(require("./enum"), exports);
|
|
26
|
-
__exportStar(require("./list"), exports);
|
package/cjs/list.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayList = void 0;
|
|
4
|
-
class ArrayList extends Array {
|
|
5
|
-
constructor(array) {
|
|
6
|
-
super();
|
|
7
|
-
if (array instanceof Array) {
|
|
8
|
-
super.push(...array);
|
|
9
|
-
}
|
|
10
|
-
else if (typeof array !== 'undefined') {
|
|
11
|
-
super.push(array);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
add(...items) {
|
|
15
|
-
this.push(...items);
|
|
16
|
-
}
|
|
17
|
-
size() {
|
|
18
|
-
return this.length;
|
|
19
|
-
}
|
|
20
|
-
isEmpty() {
|
|
21
|
-
return this.length === 0;
|
|
22
|
-
}
|
|
23
|
-
get(index) {
|
|
24
|
-
return this[index];
|
|
25
|
-
}
|
|
26
|
-
clear() {
|
|
27
|
-
this.length = 0;
|
|
28
|
-
}
|
|
29
|
-
set(index, item) {
|
|
30
|
-
this[index] = item;
|
|
31
|
-
}
|
|
32
|
-
remove(index) {
|
|
33
|
-
this.splice(index, 1);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.ArrayList = ArrayList;
|
|
37
|
-
// export class ArrayMap<T> extends Array<T> {
|
|
38
|
-
// private _map: Map<string, T> = new Map();
|
|
39
|
-
// private key: keyof T;
|
|
40
|
-
// constructor(key: keyof T, array?: Array<T> | T | undefined) {
|
|
41
|
-
// super();
|
|
42
|
-
// this.key = key;
|
|
43
|
-
// if (array instanceof Array) {
|
|
44
|
-
// super.push(...array);
|
|
45
|
-
// } else if (typeof array !== 'undefined') {
|
|
46
|
-
// super.push(array);
|
|
47
|
-
// }
|
|
48
|
-
// }
|
|
49
|
-
// override push(...items: T[]): number {
|
|
50
|
-
// for (const item of items) {
|
|
51
|
-
// const key = item[this.key] as string;
|
|
52
|
-
// if (!this._map.has(key)) {
|
|
53
|
-
// super.push(item);
|
|
54
|
-
// this._map.set(key, item);
|
|
55
|
-
// }
|
|
56
|
-
// }
|
|
57
|
-
// return this.length;
|
|
58
|
-
// }
|
|
59
|
-
// override
|
|
60
|
-
// }
|
package/cjs/math.js
DELETED
|
@@ -1,474 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getGeo = exports.calc = exports.Bus = exports.money = exports.merge = exports.round = exports.sub = exports.mul = exports.add = exports.divDef = exports.div = exports.min = exports.max = exports.num = exports.MoneyOption = void 0;
|
|
16
|
-
exports.ten2Any = ten2Any;
|
|
17
|
-
exports.any2Ten = any2Ten;
|
|
18
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
19
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
20
|
-
/** 金钱格式化可用样式 */
|
|
21
|
-
class MoneyOption {
|
|
22
|
-
constructor() {
|
|
23
|
-
this.style = 'currency';
|
|
24
|
-
this.currency = 'CNY';
|
|
25
|
-
this.prefix = 2;
|
|
26
|
-
this.def = 0;
|
|
27
|
-
this.currencyDisplay = 'symbol';
|
|
28
|
-
this.useGrouping = true;
|
|
29
|
-
this.local = 'zh';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.MoneyOption = MoneyOption;
|
|
33
|
-
// const ONE = new Decimal(1);
|
|
34
|
-
const ZERO = new decimal_js_1.default(0);
|
|
35
|
-
function isNum(a) {
|
|
36
|
-
return a !== '' && a !== null && !isNaN(a);
|
|
37
|
-
}
|
|
38
|
-
const num = (val, def = 0) => {
|
|
39
|
-
if (val instanceof Bus) {
|
|
40
|
-
return val.over();
|
|
41
|
-
}
|
|
42
|
-
else if (!isNum(val)) {
|
|
43
|
-
return def;
|
|
44
|
-
}
|
|
45
|
-
return +val;
|
|
46
|
-
};
|
|
47
|
-
exports.num = num;
|
|
48
|
-
function filterNumber(array) {
|
|
49
|
-
const res = [];
|
|
50
|
-
array.forEach((element) => {
|
|
51
|
-
if (element instanceof Bus) {
|
|
52
|
-
res.push(element.over());
|
|
53
|
-
}
|
|
54
|
-
else if (isNum(element)) {
|
|
55
|
-
res.push(+element);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return res;
|
|
59
|
-
}
|
|
60
|
-
function filterNumber2(array, def) {
|
|
61
|
-
const res = [];
|
|
62
|
-
array.forEach((element) => {
|
|
63
|
-
if (element instanceof Bus) {
|
|
64
|
-
res.push(new decimal_js_1.default(element.over()));
|
|
65
|
-
}
|
|
66
|
-
else if (isNum(element)) {
|
|
67
|
-
res.push(new decimal_js_1.default(element));
|
|
68
|
-
}
|
|
69
|
-
else if (def !== undefined) {
|
|
70
|
-
res.push(new decimal_js_1.default(def));
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
return res;
|
|
74
|
-
}
|
|
75
|
-
const max = (...args) => {
|
|
76
|
-
const arr = filterNumber(args);
|
|
77
|
-
return Math.max.apply(null, arr);
|
|
78
|
-
};
|
|
79
|
-
exports.max = max;
|
|
80
|
-
const min = (...args) => {
|
|
81
|
-
const arr = filterNumber(args);
|
|
82
|
-
return Math.min.apply(null, arr);
|
|
83
|
-
};
|
|
84
|
-
exports.min = min;
|
|
85
|
-
const div = (...args) => {
|
|
86
|
-
const arr = filterNumber2(args);
|
|
87
|
-
if (arr.length > 1) {
|
|
88
|
-
return arr.reduce((a, b) => a.div(b)).toNumber();
|
|
89
|
-
}
|
|
90
|
-
else if (arr.length > 0) {
|
|
91
|
-
return arr[0].toNumber();
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
return 0;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
exports.div = div;
|
|
98
|
-
const divDef = (def, ...args) => {
|
|
99
|
-
const arr = filterNumber2(args);
|
|
100
|
-
if (arr.length > 1) {
|
|
101
|
-
const zeros = arr.slice(1).findIndex(i => i.equals(ZERO));
|
|
102
|
-
if (zeros > -1) {
|
|
103
|
-
return new decimal_js_1.default(def).toNumber();
|
|
104
|
-
}
|
|
105
|
-
return arr.reduce((a, b) => a.div(b)).toNumber();
|
|
106
|
-
}
|
|
107
|
-
else if (arr.length > 0) {
|
|
108
|
-
return arr[0].toNumber();
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
return 0;
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
exports.divDef = divDef;
|
|
115
|
-
const add = (...args) => {
|
|
116
|
-
const arr = filterNumber2(args);
|
|
117
|
-
if (arr.length > 1) {
|
|
118
|
-
return arr.reduce((a, b) => a.add(b)).toNumber();
|
|
119
|
-
}
|
|
120
|
-
else if (arr.length > 0) {
|
|
121
|
-
return arr[0].toNumber();
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
return 0;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
exports.add = add;
|
|
128
|
-
const mul = (...args) => {
|
|
129
|
-
const arr = filterNumber2(args);
|
|
130
|
-
if (arr.length > 1) {
|
|
131
|
-
return arr.reduce((a, b) => a.mul(b)).toNumber();
|
|
132
|
-
}
|
|
133
|
-
else if (arr.length > 0) {
|
|
134
|
-
return arr[0].toNumber();
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
return 0;
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
exports.mul = mul;
|
|
141
|
-
const sub = (...args) => {
|
|
142
|
-
const arr = filterNumber2(args, 0);
|
|
143
|
-
if (arr.length > 1) {
|
|
144
|
-
return arr.reduce((a, b) => a.sub(b)).toNumber();
|
|
145
|
-
}
|
|
146
|
-
else if (arr.length > 0) {
|
|
147
|
-
return arr[0].toNumber();
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
return 0;
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
exports.sub = sub;
|
|
154
|
-
const roundMode = [decimal_js_1.default.ROUND_HALF_UP, decimal_js_1.default.ROUND_UP, decimal_js_1.default.ROUND_DOWN];
|
|
155
|
-
const round = (number, numDigits, upOrDown = 0) => {
|
|
156
|
-
if (isNum(number)) {
|
|
157
|
-
const nu = new decimal_js_1.default(number);
|
|
158
|
-
return nu.toDP(numDigits, roundMode[upOrDown]).toNumber();
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
return 0;
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
exports.round = round;
|
|
165
|
-
/** =value.xx,其中xx=number,如number=99,表示修正数字为value.99 */
|
|
166
|
-
const merge = function (value, number) {
|
|
167
|
-
if (isNum(value) && isNum(number)) {
|
|
168
|
-
return new decimal_js_1.default(value).floor().add(`0.${number}`).toNumber();
|
|
169
|
-
}
|
|
170
|
-
else if (isNum(value)) {
|
|
171
|
-
return value;
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
return 0;
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
exports.merge = merge;
|
|
178
|
-
const money = (value, option = {}) => {
|
|
179
|
-
// Intl.NumberFormat(option.local ?? 'zh', {
|
|
180
|
-
// style: option.style ?? 'currency',
|
|
181
|
-
// currency: option.currency ?? 'CNY',
|
|
182
|
-
// minimumFractionDigits: option.prefix ?? 2,
|
|
183
|
-
// currencyDisplay: option.currencyDisplay ?? 'symbol',
|
|
184
|
-
// useGrouping: option.useGrouping ?? true
|
|
185
|
-
// }).format(isNum(value) ? value : option.def).replace(/CN|\s/g, '');
|
|
186
|
-
return (isNum(value) ? value : option.def).toLocaleString(option.local ?? 'zh', {
|
|
187
|
-
style: option.style ?? 'currency',
|
|
188
|
-
currency: option.currency ?? 'CNY',
|
|
189
|
-
minimumFractionDigits: option.prefix ?? 2,
|
|
190
|
-
currencyDisplay: option.currencyDisplay ?? 'symbol',
|
|
191
|
-
useGrouping: option.useGrouping ?? true
|
|
192
|
-
}).replace(/CN|\s/g, '');
|
|
193
|
-
};
|
|
194
|
-
exports.money = money;
|
|
195
|
-
const IF = function () {
|
|
196
|
-
return function (_target, _propertyKey, descriptor) {
|
|
197
|
-
const fn = descriptor.value;
|
|
198
|
-
descriptor.value = function () {
|
|
199
|
-
if (this['ifit'] === true) {
|
|
200
|
-
// eslint-disable-next-line prefer-rest-params
|
|
201
|
-
const args = Array.from(arguments);
|
|
202
|
-
fn.call(this, ...args);
|
|
203
|
-
}
|
|
204
|
-
this['ifit'] = true;
|
|
205
|
-
return this;
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
|
-
};
|
|
209
|
-
class Bus {
|
|
210
|
-
constructor(result) {
|
|
211
|
-
this.ifit = true;
|
|
212
|
-
this.result = (0, exports.num)(result);
|
|
213
|
-
}
|
|
214
|
-
add(...args) {
|
|
215
|
-
this.result = (0, exports.add)(this.result, ...args);
|
|
216
|
-
return this;
|
|
217
|
-
}
|
|
218
|
-
sub(...args) {
|
|
219
|
-
this.result = (0, exports.sub)(this.result, ...args);
|
|
220
|
-
return this;
|
|
221
|
-
}
|
|
222
|
-
div(...args) {
|
|
223
|
-
this.result = (0, exports.div)(this.result, ...args);
|
|
224
|
-
return this;
|
|
225
|
-
}
|
|
226
|
-
divDef(def, ...args) {
|
|
227
|
-
this.result = (0, exports.divDef)(def, this.result, ...args);
|
|
228
|
-
return this;
|
|
229
|
-
}
|
|
230
|
-
mul(...args) {
|
|
231
|
-
this.result = (0, exports.mul)(this.result, ...args);
|
|
232
|
-
return this;
|
|
233
|
-
}
|
|
234
|
-
max(...args) {
|
|
235
|
-
this.result = (0, exports.max)(this.result, ...args);
|
|
236
|
-
return this;
|
|
237
|
-
}
|
|
238
|
-
min(...args) {
|
|
239
|
-
this.result = (0, exports.min)(this.result, ...args);
|
|
240
|
-
return this;
|
|
241
|
-
}
|
|
242
|
-
ac() {
|
|
243
|
-
this.result = (0, exports.sub)(0, this.result);
|
|
244
|
-
return this;
|
|
245
|
-
}
|
|
246
|
-
abs() {
|
|
247
|
-
this.result = Math.abs(this.result);
|
|
248
|
-
return this;
|
|
249
|
-
}
|
|
250
|
-
round(numDigits, upOrDown) {
|
|
251
|
-
this.result = (0, exports.round)(this.result, numDigits, upOrDown);
|
|
252
|
-
return this;
|
|
253
|
-
}
|
|
254
|
-
merge(number) {
|
|
255
|
-
this.result = (0, exports.merge)(this.result, number);
|
|
256
|
-
return this;
|
|
257
|
-
}
|
|
258
|
-
if(condition) {
|
|
259
|
-
this.ifit = condition;
|
|
260
|
-
return this;
|
|
261
|
-
}
|
|
262
|
-
over() {
|
|
263
|
-
return this.result;
|
|
264
|
-
}
|
|
265
|
-
money(option) {
|
|
266
|
-
return (0, exports.money)(this.result, option);
|
|
267
|
-
}
|
|
268
|
-
lt(data) {
|
|
269
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
270
|
-
return r.lessThan(d);
|
|
271
|
-
}
|
|
272
|
-
le(data) {
|
|
273
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
274
|
-
return r.lessThanOrEqualTo(d);
|
|
275
|
-
}
|
|
276
|
-
gt(data) {
|
|
277
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
278
|
-
return r.greaterThan(d);
|
|
279
|
-
}
|
|
280
|
-
ge(data) {
|
|
281
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
282
|
-
return r.greaterThanOrEqualTo(d);
|
|
283
|
-
}
|
|
284
|
-
nlt(data) {
|
|
285
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
286
|
-
return !r.lessThan(d);
|
|
287
|
-
}
|
|
288
|
-
nle(data) {
|
|
289
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
290
|
-
return !r.lessThanOrEqualTo(d);
|
|
291
|
-
}
|
|
292
|
-
ngt(data) {
|
|
293
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
294
|
-
return !r.greaterThan(d);
|
|
295
|
-
}
|
|
296
|
-
nge(data) {
|
|
297
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
298
|
-
return !r.greaterThanOrEqualTo(d);
|
|
299
|
-
}
|
|
300
|
-
eq(data) {
|
|
301
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
302
|
-
return r.equals(d);
|
|
303
|
-
}
|
|
304
|
-
ne(data) {
|
|
305
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
306
|
-
return !r.eq(d);
|
|
307
|
-
}
|
|
308
|
-
ifLt(data) {
|
|
309
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
310
|
-
this.ifit = r.lessThan(d);
|
|
311
|
-
return this;
|
|
312
|
-
}
|
|
313
|
-
ifLe(data) {
|
|
314
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
315
|
-
this.ifit = r.lessThanOrEqualTo(d);
|
|
316
|
-
return this;
|
|
317
|
-
}
|
|
318
|
-
ifGt(data) {
|
|
319
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
320
|
-
this.ifit = r.greaterThan(d);
|
|
321
|
-
return this;
|
|
322
|
-
}
|
|
323
|
-
ifGe(data) {
|
|
324
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
325
|
-
this.ifit = r.greaterThanOrEqualTo(d);
|
|
326
|
-
return this;
|
|
327
|
-
}
|
|
328
|
-
ifNlt(data) {
|
|
329
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
330
|
-
this.ifit = !r.lessThan(d);
|
|
331
|
-
return this;
|
|
332
|
-
}
|
|
333
|
-
ifNle(data) {
|
|
334
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
335
|
-
this.ifit = !r.lessThanOrEqualTo(d);
|
|
336
|
-
return this;
|
|
337
|
-
}
|
|
338
|
-
ifNgt(data) {
|
|
339
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
340
|
-
this.ifit = !r.greaterThan(d);
|
|
341
|
-
return this;
|
|
342
|
-
}
|
|
343
|
-
ifNge(data) {
|
|
344
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
345
|
-
this.ifit = !r.greaterThanOrEqualTo(d);
|
|
346
|
-
return this;
|
|
347
|
-
}
|
|
348
|
-
ifEq(data) {
|
|
349
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
350
|
-
this.ifit = r.equals(d);
|
|
351
|
-
return this;
|
|
352
|
-
}
|
|
353
|
-
ifNe(data) {
|
|
354
|
-
const [d, r] = filterNumber2([data, this.result]);
|
|
355
|
-
this.ifit = !r.eq(d);
|
|
356
|
-
return this;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
exports.Bus = Bus;
|
|
360
|
-
__decorate([
|
|
361
|
-
IF(),
|
|
362
|
-
__metadata("design:type", Function),
|
|
363
|
-
__metadata("design:paramtypes", [Object]),
|
|
364
|
-
__metadata("design:returntype", Object)
|
|
365
|
-
], Bus.prototype, "add", null);
|
|
366
|
-
__decorate([
|
|
367
|
-
IF(),
|
|
368
|
-
__metadata("design:type", Function),
|
|
369
|
-
__metadata("design:paramtypes", [Object]),
|
|
370
|
-
__metadata("design:returntype", Object)
|
|
371
|
-
], Bus.prototype, "sub", null);
|
|
372
|
-
__decorate([
|
|
373
|
-
IF(),
|
|
374
|
-
__metadata("design:type", Function),
|
|
375
|
-
__metadata("design:paramtypes", [Object]),
|
|
376
|
-
__metadata("design:returntype", Object)
|
|
377
|
-
], Bus.prototype, "div", null);
|
|
378
|
-
__decorate([
|
|
379
|
-
IF(),
|
|
380
|
-
__metadata("design:type", Function),
|
|
381
|
-
__metadata("design:paramtypes", [Object, Object]),
|
|
382
|
-
__metadata("design:returntype", Object)
|
|
383
|
-
], Bus.prototype, "divDef", null);
|
|
384
|
-
__decorate([
|
|
385
|
-
IF(),
|
|
386
|
-
__metadata("design:type", Function),
|
|
387
|
-
__metadata("design:paramtypes", [Object]),
|
|
388
|
-
__metadata("design:returntype", Object)
|
|
389
|
-
], Bus.prototype, "mul", null);
|
|
390
|
-
__decorate([
|
|
391
|
-
IF(),
|
|
392
|
-
__metadata("design:type", Function),
|
|
393
|
-
__metadata("design:paramtypes", [Object]),
|
|
394
|
-
__metadata("design:returntype", Object)
|
|
395
|
-
], Bus.prototype, "max", null);
|
|
396
|
-
__decorate([
|
|
397
|
-
IF(),
|
|
398
|
-
__metadata("design:type", Function),
|
|
399
|
-
__metadata("design:paramtypes", [Object]),
|
|
400
|
-
__metadata("design:returntype", Object)
|
|
401
|
-
], Bus.prototype, "min", null);
|
|
402
|
-
__decorate([
|
|
403
|
-
IF(),
|
|
404
|
-
__metadata("design:type", Function),
|
|
405
|
-
__metadata("design:paramtypes", []),
|
|
406
|
-
__metadata("design:returntype", Object)
|
|
407
|
-
], Bus.prototype, "ac", null);
|
|
408
|
-
__decorate([
|
|
409
|
-
IF(),
|
|
410
|
-
__metadata("design:type", Function),
|
|
411
|
-
__metadata("design:paramtypes", []),
|
|
412
|
-
__metadata("design:returntype", Object)
|
|
413
|
-
], Bus.prototype, "abs", null);
|
|
414
|
-
__decorate([
|
|
415
|
-
IF(),
|
|
416
|
-
__metadata("design:type", Function),
|
|
417
|
-
__metadata("design:paramtypes", [Number, Number]),
|
|
418
|
-
__metadata("design:returntype", Object)
|
|
419
|
-
], Bus.prototype, "round", null);
|
|
420
|
-
__decorate([
|
|
421
|
-
IF(),
|
|
422
|
-
__metadata("design:type", Function),
|
|
423
|
-
__metadata("design:paramtypes", [Object]),
|
|
424
|
-
__metadata("design:returntype", void 0)
|
|
425
|
-
], Bus.prototype, "merge", null);
|
|
426
|
-
const calc = (result) => {
|
|
427
|
-
return new Bus(result);
|
|
428
|
-
};
|
|
429
|
-
exports.calc = calc;
|
|
430
|
-
const getGeo = (p1, p2) => {
|
|
431
|
-
p1.lat = (0, exports.calc)(p1.latitude).mul(Math.PI).div(180).over();
|
|
432
|
-
p1.long = (0, exports.calc)(p1.longitude).mul(Math.PI).div(180).over();
|
|
433
|
-
p2.lat = (0, exports.calc)(p2.latitude).mul(Math.PI).div(180).over();
|
|
434
|
-
p2.long = (0, exports.calc)(p2.longitude).mul(Math.PI).div(180).over();
|
|
435
|
-
return (0, exports.calc)(Math.round((0, exports.mul)(Math.asin(Math.sqrt((0, exports.add)(Math.pow(Math.sin((0, exports.div)((0, exports.sub)(p1.lat, p2.lat), 2)), 2), (0, exports.mul)(Math.cos(p1.lat), Math.cos(p2.lat), Math.pow(Math.sin((0, exports.div)((0, exports.sub)(p1.long, p2.long), 2)), 2))))), 2, 6378.137, 10000))).div(10000).round(2).over();
|
|
436
|
-
};
|
|
437
|
-
exports.getGeo = getGeo;
|
|
438
|
-
const ZM = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
439
|
-
/**
|
|
440
|
-
* 十进制转换自定义进制
|
|
441
|
-
* @param from 数字
|
|
442
|
-
* @param to 自定义进制的字符
|
|
443
|
-
* @returns
|
|
444
|
-
*/
|
|
445
|
-
function ten2Any(from, to = ZM) {
|
|
446
|
-
let result = '';
|
|
447
|
-
const length = to.length;
|
|
448
|
-
while (from > 0) {
|
|
449
|
-
from--;
|
|
450
|
-
let remainder = from % length;
|
|
451
|
-
result = to.charAt(remainder) + result;
|
|
452
|
-
from = Math.floor(from / length);
|
|
453
|
-
}
|
|
454
|
-
return result;
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* 自定义进制转换十进制
|
|
458
|
-
* @param from
|
|
459
|
-
* @param to
|
|
460
|
-
* @returns
|
|
461
|
-
*/
|
|
462
|
-
function any2Ten(from, to = ZM) {
|
|
463
|
-
let decimal = 0;
|
|
464
|
-
from = from.toUpperCase();
|
|
465
|
-
for (let i = 0; i < from.length; i++) {
|
|
466
|
-
const char = from[from.length - 1 - i].toUpperCase();
|
|
467
|
-
const index = to.indexOf(char);
|
|
468
|
-
if (index > -1) {
|
|
469
|
-
const value = to.indexOf(char) + 1;
|
|
470
|
-
decimal += value * Math.pow(26, i);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
return decimal;
|
|
474
|
-
}
|