light-h5-core-lib 2.0.1 → 2.1.0
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/common/base/BaseSingleton.d.ts +6 -6
- package/common/base/IClear.d.ts +4 -4
- package/common/base/IDestroy.d.ts +3 -3
- package/common/util/BitUtil.d.ts +17 -17
- package/common/util/DateUtil.d.ts +46 -46
- package/common/util/FloatDigitUtil.d.ts +12 -12
- package/common/util/RandomNumUtil.d.ts +16 -16
- package/common/util/StringUtil.d.ts +19 -19
- package/common/util/UniqueIDUtil.d.ts +10 -0
- package/common/util/UniqueIDUtil.js +18 -0
- package/package.json +6 -3
- package/pool/PoolObj.d.ts +28 -28
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare class BaseSingleton<T> {
|
|
2
|
-
private static _instance;
|
|
3
|
-
static getInstance<T>(c: {
|
|
4
|
-
new (): T;
|
|
5
|
-
}): T;
|
|
6
|
-
}
|
|
1
|
+
export declare class BaseSingleton<T> {
|
|
2
|
+
private static _instance;
|
|
3
|
+
static getInstance<T>(c: {
|
|
4
|
+
new (): T;
|
|
5
|
+
}): T;
|
|
6
|
+
}
|
package/common/base/IClear.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDestroy } from "./IDestroy";
|
|
2
|
-
export interface IClear extends IDestroy {
|
|
3
|
-
clear(): void;
|
|
4
|
-
}
|
|
1
|
+
import { IDestroy } from "./IDestroy";
|
|
2
|
+
export interface IClear extends IDestroy {
|
|
3
|
+
clear(): void;
|
|
4
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export interface IDestroy {
|
|
2
|
-
destroy(): void;
|
|
3
|
-
}
|
|
1
|
+
export interface IDestroy {
|
|
2
|
+
destroy(): void;
|
|
3
|
+
}
|
package/common/util/BitUtil.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 位操作工具(从右向左←)
|
|
3
|
-
* @author aonaufly
|
|
4
|
-
*/
|
|
5
|
-
export declare class BitUtil {
|
|
6
|
-
/**
|
|
7
|
-
* 读取uint类型某位的值, bit从1开始
|
|
8
|
-
*/
|
|
9
|
-
static getBit(value: number, bit: number): number;
|
|
10
|
-
/**
|
|
11
|
-
* 设置value 第bit(从1开始)位的值为v(0|1)
|
|
12
|
-
* 谨记bit<32
|
|
13
|
-
*/
|
|
14
|
-
static setBit(value: number, bit: number, v: 0 | 1): number;
|
|
15
|
-
/**获取1的个数 */
|
|
16
|
-
static get1num(value: number): number;
|
|
17
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 位操作工具(从右向左←)
|
|
3
|
+
* @author aonaufly
|
|
4
|
+
*/
|
|
5
|
+
export declare class BitUtil {
|
|
6
|
+
/**
|
|
7
|
+
* 读取uint类型某位的值, bit从1开始
|
|
8
|
+
*/
|
|
9
|
+
static getBit(value: number, bit: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* 设置value 第bit(从1开始)位的值为v(0|1)
|
|
12
|
+
* 谨记bit<32
|
|
13
|
+
*/
|
|
14
|
+
static setBit(value: number, bit: number, v: 0 | 1): number;
|
|
15
|
+
/**获取1的个数 */
|
|
16
|
+
static get1num(value: number): number;
|
|
17
|
+
}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 日期(时间)工具
|
|
3
|
-
* @author aonaufly
|
|
4
|
-
*/
|
|
5
|
-
export declare class DateUtil {
|
|
6
|
-
/**
|
|
7
|
-
* 获取指定时间的时间戳 (单位:ms)
|
|
8
|
-
* @param date 如: "2020-3-14 11:30:30"
|
|
9
|
-
*/
|
|
10
|
-
static getTargetTimeStamp(date: string): number;
|
|
11
|
-
/**
|
|
12
|
-
* 获取指定时间的时间秒 (单位:s)
|
|
13
|
-
* @param date 如: "2020-3-14 11:30:30"
|
|
14
|
-
*/
|
|
15
|
-
static getTargetSeconds(date: string): number;
|
|
16
|
-
/**
|
|
17
|
-
* 格式化时间(时,分,秒)
|
|
18
|
-
* @param s 秒
|
|
19
|
-
* @param separator 分隔符(default: ":")
|
|
20
|
-
* @param isSingle0 是否补0(default:true)
|
|
21
|
-
* @param isDiscardH 小时数为0时,是否舍弃显示变成分,秒(default:false)
|
|
22
|
-
*/
|
|
23
|
-
static format_HMS(s: number, separator?: string, isSingle0?: boolean, isDiscardH?: boolean): string;
|
|
24
|
-
/**
|
|
25
|
-
* 格式化时间(分,秒)
|
|
26
|
-
* @param s 秒
|
|
27
|
-
* @param separator 分隔符(default: ":")
|
|
28
|
-
* @param isSingle0 是否补0(default:true)
|
|
29
|
-
*/
|
|
30
|
-
static format_MS(s: number, separator?: string, isSingle0?: boolean): string;
|
|
31
|
-
/**
|
|
32
|
-
* 获取下一天的时间(凌晨)秒 存在1ms误差可以忽略不计
|
|
33
|
-
* @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
|
|
34
|
-
* @return 下一天的时间Second
|
|
35
|
-
* */
|
|
36
|
-
static getNextDayTimeStamp(nowSecond: number): number;
|
|
37
|
-
/**
|
|
38
|
-
* 获取今日指定的时间秒, 例如今日20:00
|
|
39
|
-
* @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
|
|
40
|
-
* @param hour 指定的小时数 0~23
|
|
41
|
-
* @param minute 指定的分钟数 0~59
|
|
42
|
-
* @param second 指定的秒数 0~59
|
|
43
|
-
* @param millisecond 指定的毫秒数 0~999
|
|
44
|
-
*/
|
|
45
|
-
static getTodayAppointTimeStamp(nowSecond: number, hour: number, minute?: number, second?: number, millisecond?: number): number;
|
|
46
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 日期(时间)工具
|
|
3
|
+
* @author aonaufly
|
|
4
|
+
*/
|
|
5
|
+
export declare class DateUtil {
|
|
6
|
+
/**
|
|
7
|
+
* 获取指定时间的时间戳 (单位:ms)
|
|
8
|
+
* @param date 如: "2020-3-14 11:30:30"
|
|
9
|
+
*/
|
|
10
|
+
static getTargetTimeStamp(date: string): number;
|
|
11
|
+
/**
|
|
12
|
+
* 获取指定时间的时间秒 (单位:s)
|
|
13
|
+
* @param date 如: "2020-3-14 11:30:30"
|
|
14
|
+
*/
|
|
15
|
+
static getTargetSeconds(date: string): number;
|
|
16
|
+
/**
|
|
17
|
+
* 格式化时间(时,分,秒)
|
|
18
|
+
* @param s 秒
|
|
19
|
+
* @param separator 分隔符(default: ":")
|
|
20
|
+
* @param isSingle0 是否补0(default:true)
|
|
21
|
+
* @param isDiscardH 小时数为0时,是否舍弃显示变成分,秒(default:false)
|
|
22
|
+
*/
|
|
23
|
+
static format_HMS(s: number, separator?: string, isSingle0?: boolean, isDiscardH?: boolean): string;
|
|
24
|
+
/**
|
|
25
|
+
* 格式化时间(分,秒)
|
|
26
|
+
* @param s 秒
|
|
27
|
+
* @param separator 分隔符(default: ":")
|
|
28
|
+
* @param isSingle0 是否补0(default:true)
|
|
29
|
+
*/
|
|
30
|
+
static format_MS(s: number, separator?: string, isSingle0?: boolean): string;
|
|
31
|
+
/**
|
|
32
|
+
* 获取下一天的时间(凌晨)秒 存在1ms误差可以忽略不计
|
|
33
|
+
* @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
|
|
34
|
+
* @return 下一天的时间Second
|
|
35
|
+
* */
|
|
36
|
+
static getNextDayTimeStamp(nowSecond: number): number;
|
|
37
|
+
/**
|
|
38
|
+
* 获取今日指定的时间秒, 例如今日20:00
|
|
39
|
+
* @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
|
|
40
|
+
* @param hour 指定的小时数 0~23
|
|
41
|
+
* @param minute 指定的分钟数 0~59
|
|
42
|
+
* @param second 指定的秒数 0~59
|
|
43
|
+
* @param millisecond 指定的毫秒数 0~999
|
|
44
|
+
*/
|
|
45
|
+
static getTodayAppointTimeStamp(nowSecond: number, hour: number, minute?: number, second?: number, millisecond?: number): number;
|
|
46
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Float精度
|
|
3
|
-
* @author aonaufly
|
|
4
|
-
*/
|
|
5
|
-
export declare class FloatDigitUtil {
|
|
6
|
-
/**
|
|
7
|
-
* 确定小数的精度<b style="color:red">2个小数相加会有精度错误</b>
|
|
8
|
-
* @param fNum 小数
|
|
9
|
-
* @param digit 精度
|
|
10
|
-
*/
|
|
11
|
-
static formatFloat(fNum: number, digit: number): number;
|
|
12
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Float精度
|
|
3
|
+
* @author aonaufly
|
|
4
|
+
*/
|
|
5
|
+
export declare class FloatDigitUtil {
|
|
6
|
+
/**
|
|
7
|
+
* 确定小数的精度<b style="color:red">2个小数相加会有精度错误</b>
|
|
8
|
+
* @param fNum 小数
|
|
9
|
+
* @param digit 精度
|
|
10
|
+
*/
|
|
11
|
+
static formatFloat(fNum: number, digit: number): number;
|
|
12
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 随机数生成工具
|
|
3
|
-
* @author aonaufly
|
|
4
|
-
*/
|
|
5
|
-
export declare class RandomNumUtil {
|
|
6
|
-
/**
|
|
7
|
-
* 获取一定方位的随机整数
|
|
8
|
-
*
|
|
9
|
-
* <b>( min ≤ r ≤ max )</b>
|
|
10
|
-
*
|
|
11
|
-
* @param min 最小数
|
|
12
|
-
* @param max 最大数
|
|
13
|
-
* @param isInt 是否返回整数
|
|
14
|
-
*/
|
|
15
|
-
static randomNumBoth(min: number, max: number, isInt?: boolean): number;
|
|
16
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 随机数生成工具
|
|
3
|
+
* @author aonaufly
|
|
4
|
+
*/
|
|
5
|
+
export declare class RandomNumUtil {
|
|
6
|
+
/**
|
|
7
|
+
* 获取一定方位的随机整数
|
|
8
|
+
*
|
|
9
|
+
* <b>( min ≤ r ≤ max )</b>
|
|
10
|
+
*
|
|
11
|
+
* @param min 最小数
|
|
12
|
+
* @param max 最大数
|
|
13
|
+
* @param isInt 是否返回整数
|
|
14
|
+
*/
|
|
15
|
+
static randomNumBoth(min: number, max: number, isInt?: boolean): number;
|
|
16
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 字符串工具
|
|
3
|
-
* @author aonaufly
|
|
4
|
-
*/
|
|
5
|
-
export declare class StringUtil {
|
|
6
|
-
/**
|
|
7
|
-
* 字符串的格式化 , 使用 {index = 0}的模式
|
|
8
|
-
* @param str 源字符串
|
|
9
|
-
* @param args 填充参数
|
|
10
|
-
*/
|
|
11
|
-
static format(str: string, ...args: Array<any>): string;
|
|
12
|
-
private static code2utf8;
|
|
13
|
-
/**
|
|
14
|
-
* 将字符串转化成UTF8的Buffer
|
|
15
|
-
* @param str 字符串
|
|
16
|
-
*/
|
|
17
|
-
static string2UTF8Buffer(str: string): ArrayBuffer;
|
|
18
|
-
static buffer2UTF8String: (buffer: ArrayBuffer) => string;
|
|
19
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 字符串工具
|
|
3
|
+
* @author aonaufly
|
|
4
|
+
*/
|
|
5
|
+
export declare class StringUtil {
|
|
6
|
+
/**
|
|
7
|
+
* 字符串的格式化 , 使用 {index = 0}的模式
|
|
8
|
+
* @param str 源字符串
|
|
9
|
+
* @param args 填充参数
|
|
10
|
+
*/
|
|
11
|
+
static format(str: string, ...args: Array<any>): string;
|
|
12
|
+
private static code2utf8;
|
|
13
|
+
/**
|
|
14
|
+
* 将字符串转化成UTF8的Buffer
|
|
15
|
+
* @param str 字符串
|
|
16
|
+
*/
|
|
17
|
+
static string2UTF8Buffer(str: string): ArrayBuffer;
|
|
18
|
+
static buffer2UTF8String: (buffer: ArrayBuffer) => string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 唯一ID生成器
|
|
3
|
+
* @author Aonaufly
|
|
4
|
+
*/
|
|
5
|
+
var UniqueIDUtil = /** @class */ (function () {
|
|
6
|
+
function UniqueIDUtil() {
|
|
7
|
+
}
|
|
8
|
+
/**生成唯一ID值*/
|
|
9
|
+
UniqueIDUtil.getUniqueId = function () {
|
|
10
|
+
return new Date().getTime() + Math.random().toString(36).substring(2);
|
|
11
|
+
};
|
|
12
|
+
/**生成复合的Key值*/
|
|
13
|
+
UniqueIDUtil.getCompositeKey = function (key, uniqueId) {
|
|
14
|
+
return "".concat(key, "-id:").concat(uniqueId);
|
|
15
|
+
};
|
|
16
|
+
return UniqueIDUtil;
|
|
17
|
+
}());
|
|
18
|
+
export { UniqueIDUtil };
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "light-h5-core-lib",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "light core lib",
|
|
5
5
|
"exports": {
|
|
6
|
-
"./
|
|
6
|
+
"./IDestroy": "./common/base/IDestroy.js",
|
|
7
|
+
"./IClear": "./common/base/IClear.js",
|
|
8
|
+
"./PoolObj": "./pool/PoolObj.js",
|
|
7
9
|
"./BaseSingleton": "./common/base/BaseSingleton.js",
|
|
8
10
|
"./BitUtil": "./common/util/BitUtil.js",
|
|
9
11
|
"./DateUtil": "./common/util/DateUtil.js",
|
|
10
12
|
"./FloatDigitUtil": "./common/util/FloatDigitUtil.js",
|
|
11
13
|
"./RandomNumUtil": "./common/util/RandomNumUtil.js",
|
|
12
|
-
"./StringUtil": "./common/util/StringUtil.js"
|
|
14
|
+
"./StringUtil": "./common/util/StringUtil.js",
|
|
15
|
+
"./UniqueIDUtil": "./common/util/UniqueIDUtil.js"
|
|
13
16
|
},
|
|
14
17
|
"scripts": {
|
|
15
18
|
"test": "echo \"Error: no test specified\" && exit 1"
|
package/pool/PoolObj.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { IClear } from "../common/base/IClear";
|
|
2
|
-
/**
|
|
3
|
-
* 对象池(泛型)
|
|
4
|
-
* @author aonaufly
|
|
5
|
-
*/
|
|
6
|
-
export declare class PoolObj<T> implements IClear {
|
|
7
|
-
private _pool;
|
|
8
|
-
private _cup;
|
|
9
|
-
/**
|
|
10
|
-
* @param cup 容量
|
|
11
|
-
*/
|
|
12
|
-
constructor(cup?: number);
|
|
13
|
-
put(obj: T): boolean;
|
|
14
|
-
one(): T;
|
|
15
|
-
/**
|
|
16
|
-
* 获取容量(容积)
|
|
17
|
-
*/
|
|
18
|
-
get cup(): number;
|
|
19
|
-
/**
|
|
20
|
-
* 获取当前数量(已经保存的元素个数)
|
|
21
|
-
*/
|
|
22
|
-
get size(): number;
|
|
23
|
-
/**
|
|
24
|
-
* 清理对象池
|
|
25
|
-
*/
|
|
26
|
-
clear(): void;
|
|
27
|
-
destroy(isCleared?: boolean): void;
|
|
28
|
-
}
|
|
1
|
+
import { IClear } from "../common/base/IClear";
|
|
2
|
+
/**
|
|
3
|
+
* 对象池(泛型)
|
|
4
|
+
* @author aonaufly
|
|
5
|
+
*/
|
|
6
|
+
export declare class PoolObj<T> implements IClear {
|
|
7
|
+
private _pool;
|
|
8
|
+
private _cup;
|
|
9
|
+
/**
|
|
10
|
+
* @param cup 容量
|
|
11
|
+
*/
|
|
12
|
+
constructor(cup?: number);
|
|
13
|
+
put(obj: T): boolean;
|
|
14
|
+
one(): T;
|
|
15
|
+
/**
|
|
16
|
+
* 获取容量(容积)
|
|
17
|
+
*/
|
|
18
|
+
get cup(): number;
|
|
19
|
+
/**
|
|
20
|
+
* 获取当前数量(已经保存的元素个数)
|
|
21
|
+
*/
|
|
22
|
+
get size(): number;
|
|
23
|
+
/**
|
|
24
|
+
* 清理对象池
|
|
25
|
+
*/
|
|
26
|
+
clear(): void;
|
|
27
|
+
destroy(isCleared?: boolean): void;
|
|
28
|
+
}
|