light-h5-core-lib 2.7.5 → 2.8.1
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/LightCore.js +50 -35
- package/common/base/BaseSingleton.js +29 -23
- package/common/base/IClear.js +2 -2
- package/common/base/IDestroy.js +2 -2
- package/common/md5/MD5.js +353 -346
- package/common/util/BeizerUtil.js +83 -83
- package/common/util/BitUtil.js +43 -43
- package/common/util/BooleanUtil.js +23 -0
- package/common/util/Crc32Util.js +35 -0
- package/common/util/DateUtil.js +116 -89
- package/common/util/FloatDigitUtil.js +63 -22
- package/common/util/NumberUtil.js +23 -0
- package/common/util/PromiseUtil.js +74 -0
- package/common/util/RandomNumUtil.js +92 -54
- package/common/util/StringUtil.js +88 -81
- package/common/util/UniqueIDUtil.js +21 -21
- package/package.json +16 -16
- package/pool/PoolObj.js +79 -79
- package/type/index.d.ts +94 -3
package/type/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface IClear extends IDestroy {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* 对象池(泛型)
|
|
11
|
-
* @author
|
|
11
|
+
* @author Aonaufly
|
|
12
12
|
*/
|
|
13
13
|
export declare class PoolObj<T> implements IClear {
|
|
14
14
|
private _pool;
|
|
@@ -42,11 +42,15 @@ export declare abstract class BaseSingleton<T> implements IDestroy {
|
|
|
42
42
|
static getInstance<T>(c: {
|
|
43
43
|
new (): T;
|
|
44
44
|
}): T;
|
|
45
|
+
/**
|
|
46
|
+
* 相当于构造函数
|
|
47
|
+
*/
|
|
48
|
+
protected ctor(): void;
|
|
45
49
|
destroy(): void;
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* 位操作工具(从右向左←)
|
|
49
|
-
* @author
|
|
53
|
+
* @author Aonaufly
|
|
50
54
|
*/
|
|
51
55
|
export declare class BitUtil {
|
|
52
56
|
/**
|
|
@@ -106,6 +110,20 @@ export declare class DateUtil {
|
|
|
106
110
|
* @param millisecond 指定的毫秒数 0~999
|
|
107
111
|
*/
|
|
108
112
|
static getTodayAppointTimeStamp(nowSecond: number, hour: number, minute?: number, second?: number, millisecond?: number): number;
|
|
113
|
+
/**
|
|
114
|
+
* 获得剩余的过期时间秒(S)用于倒计时
|
|
115
|
+
* @param targetExpireSecond 过期的时间戳(s)
|
|
116
|
+
* @param curSecond 当前时间戳(s)
|
|
117
|
+
* @param offsetSecond 误差值(s) (targetExpireSecond + offsetSecond)用于延长/缩短一些过期时间
|
|
118
|
+
*/
|
|
119
|
+
static getRemainingSecond(targetExpireSecond: number, curSecond?: number, offsetSecond?: number): number;
|
|
120
|
+
/**
|
|
121
|
+
* 获得过期的时间戳(S)
|
|
122
|
+
* @param durationSecond 过期的时间倒计时(s)
|
|
123
|
+
* @param curSecond 当前的时间(s)
|
|
124
|
+
* @return 过期的时间戳(s)
|
|
125
|
+
*/
|
|
126
|
+
static getExpireSecond(durationSecond: number, curSecond?: number): number;
|
|
109
127
|
}
|
|
110
128
|
/**
|
|
111
129
|
* Float精度
|
|
@@ -118,6 +136,14 @@ export declare class FloatDigitUtil {
|
|
|
118
136
|
* @param digit 精度
|
|
119
137
|
*/
|
|
120
138
|
static formatFloat(fNum: number, digit: number): number;
|
|
139
|
+
/**
|
|
140
|
+
* 小数的格式化
|
|
141
|
+
*/
|
|
142
|
+
static formatDecimalNumber(num: number, factor: number, isRound?: boolean): number;
|
|
143
|
+
/**
|
|
144
|
+
* 小数的格式化
|
|
145
|
+
*/
|
|
146
|
+
static formatDecimalString(num: number, factor: number, isRound?: boolean, isSupplementZero?: boolean): string;
|
|
121
147
|
}
|
|
122
148
|
/**
|
|
123
149
|
* 随机数生成工具
|
|
@@ -138,6 +164,21 @@ export declare class RandomNumUtil {
|
|
|
138
164
|
* 打乱数组
|
|
139
165
|
*/
|
|
140
166
|
static shuffleSort<T>(arr: T[]): void;
|
|
167
|
+
/**
|
|
168
|
+
* 获得偏振系数
|
|
169
|
+
* @param factor 偏振因子(>0)
|
|
170
|
+
* @param negativeIntRadio 负数的比率(> 0的整数)
|
|
171
|
+
* @param positiveIntRadio 正数的比率 (>0的整数)
|
|
172
|
+
* @return -factor 或者factor
|
|
173
|
+
*/
|
|
174
|
+
static getPolarizationFactor(factor?: number, negativeIntRadio?: number, positiveIntRadio?: number): number;
|
|
175
|
+
/**
|
|
176
|
+
* 按照比率获得随机数(对于整数)
|
|
177
|
+
* @param min 最小数
|
|
178
|
+
* @param max 最大数
|
|
179
|
+
* @param radioArr 比率
|
|
180
|
+
*/
|
|
181
|
+
static randomNumWithRadio(min: number, max: number, radioArr: number[]): number;
|
|
141
182
|
}
|
|
142
183
|
/**
|
|
143
184
|
* 字符串工具
|
|
@@ -149,7 +190,11 @@ export declare class StringUtil {
|
|
|
149
190
|
* @param str 源字符串
|
|
150
191
|
* @param args 填充参数
|
|
151
192
|
*/
|
|
152
|
-
static format(str: string, ...args:
|
|
193
|
+
static format(str: string, ...args: any): string;
|
|
194
|
+
/**
|
|
195
|
+
* 将字符串中所有的\/替换成/
|
|
196
|
+
*/
|
|
197
|
+
static replaceBackslash(input: string): string;
|
|
153
198
|
private static code2utf8;
|
|
154
199
|
/**
|
|
155
200
|
* 将字符串转化成UTF8的Buffer
|
|
@@ -227,6 +272,52 @@ export declare class MD5 extends BaseSingleton<MD5> {
|
|
|
227
272
|
md5_ii(a: any, b: any, c: any, d: any, x: any, s: any, t: any): number;
|
|
228
273
|
safe_add(x: any, y: any): number;
|
|
229
274
|
bit_rol(num: any, cnt: any): number;
|
|
275
|
+
selfDecrypt(data: string, secretKey: string): string;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* 异步处理工具
|
|
279
|
+
* @author Aonaufly
|
|
280
|
+
*/
|
|
281
|
+
export declare class PromiseUtil {
|
|
282
|
+
/**
|
|
283
|
+
* 执行所有异步并返回数据
|
|
284
|
+
*/
|
|
285
|
+
static all(promiseArr: Promise<any>[]): Promise<any>;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Crc32验证工具
|
|
289
|
+
* @author Aonaufly
|
|
290
|
+
*/
|
|
291
|
+
export declare class Crc32Util {
|
|
292
|
+
private static table;
|
|
293
|
+
/**
|
|
294
|
+
* Crc32 number
|
|
295
|
+
*/
|
|
296
|
+
static getCrc32Number(str: string, crc?: number): number;
|
|
297
|
+
/**
|
|
298
|
+
* Crc32 string
|
|
299
|
+
*/
|
|
300
|
+
static getCrc32String(str: string, crc?: number): string;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Bool类型处理
|
|
304
|
+
* @author Aonaufly
|
|
305
|
+
*/
|
|
306
|
+
export declare class BooleanUtil {
|
|
307
|
+
/**
|
|
308
|
+
* 获得Proto中的Bool值
|
|
309
|
+
*/
|
|
310
|
+
static getProtoBool(data: any, key: string, defaultValue?: boolean): boolean;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* 数值类型处理
|
|
314
|
+
* @author Aonaufly
|
|
315
|
+
*/
|
|
316
|
+
export declare class NumberUtil {
|
|
317
|
+
/**
|
|
318
|
+
* 获得Proto中的数字
|
|
319
|
+
*/
|
|
320
|
+
static getProtoNum(data: any, key: string, defaultValue?: number): number;
|
|
230
321
|
}
|
|
231
322
|
|
|
232
323
|
export {};
|