@jiakun-zhao/utils 1.1.1 → 1.1.2
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/dist/index.cjs +63 -0
- package/dist/index.d.cts +81 -9
- package/dist/index.d.mts +81 -9
- package/dist/index.d.ts +81 -9
- package/dist/index.mjs +62 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -40,8 +40,70 @@ function random(max, min = 0) {
|
|
|
40
40
|
return Math.floor(Math.random() * max) + min;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
const colors = {
|
|
44
|
+
/** 重置颜色 */
|
|
45
|
+
reset: "\x1B[0m",
|
|
46
|
+
/** 亮色(加粗) */
|
|
47
|
+
bright: "\x1B[1m",
|
|
48
|
+
/** 斜体 */
|
|
49
|
+
italic: "\x1B[3m",
|
|
50
|
+
/** 下划线 */
|
|
51
|
+
underline: "\x1B[4m",
|
|
52
|
+
/** 反向 */
|
|
53
|
+
reverse: "\x1B[7m",
|
|
54
|
+
/** 隐藏 */
|
|
55
|
+
hidden: "\x1B[8m",
|
|
56
|
+
/** 灰色 */
|
|
57
|
+
grey: "\x1B[2m",
|
|
58
|
+
/** 黑色 */
|
|
59
|
+
black: "\x1B[30m",
|
|
60
|
+
/** 红色 */
|
|
61
|
+
red: "\x1B[31m",
|
|
62
|
+
/** 绿色 */
|
|
63
|
+
green: "\x1B[32m",
|
|
64
|
+
/** 黄色 */
|
|
65
|
+
yellow: "\x1B[33m",
|
|
66
|
+
/** 蓝色 */
|
|
67
|
+
blue: "\x1B[34m",
|
|
68
|
+
/** 品红 */
|
|
69
|
+
magenta: "\x1B[35m",
|
|
70
|
+
/** 青色 */
|
|
71
|
+
cyan: "\x1B[36m",
|
|
72
|
+
/** 白色 */
|
|
73
|
+
white: "\x1B[37m",
|
|
74
|
+
/** 背景黑色 */
|
|
75
|
+
bgBlack: "\x1B[40m",
|
|
76
|
+
/** 背景红色 */
|
|
77
|
+
bgRed: "\x1B[41m",
|
|
78
|
+
/** 背景绿色 */
|
|
79
|
+
bgGreen: "\x1B[42m",
|
|
80
|
+
/** 背景黄色 */
|
|
81
|
+
bgYellow: "\x1B[43m",
|
|
82
|
+
/** 背景蓝色 */
|
|
83
|
+
bgBlue: "\x1B[44m",
|
|
84
|
+
/** 背景品红 */
|
|
85
|
+
bgMagenta: "\x1B[45m",
|
|
86
|
+
/** 背景青色 */
|
|
87
|
+
bgCyan: "\x1B[46m",
|
|
88
|
+
/** 背景白色 */
|
|
89
|
+
bgWhite: "\x1B[47m"
|
|
90
|
+
};
|
|
91
|
+
const map = {
|
|
92
|
+
info: { color: colors.blue, symbol: "\u{1D4F2}" },
|
|
93
|
+
warn: { color: colors.yellow, symbol: "\u{1D4F2}" },
|
|
94
|
+
success: { color: colors.green, symbol: "\u2714\uFE0E" },
|
|
95
|
+
error: { color: colors.red, symbol: "\u2718" }
|
|
96
|
+
};
|
|
97
|
+
function print(msg, type) {
|
|
98
|
+
if (!type)
|
|
99
|
+
console.log(msg);
|
|
100
|
+
else
|
|
101
|
+
console.log(`${map[type].color}${map[type].symbol} ${colors.grey}${msg}${colors.reset}`);
|
|
102
|
+
}
|
|
103
|
+
|
|
43
104
|
const timestamp = () => +Date.now();
|
|
44
105
|
|
|
106
|
+
exports.colors = colors;
|
|
45
107
|
exports.isArray = isArray;
|
|
46
108
|
exports.isBoolean = isBoolean;
|
|
47
109
|
exports.isDate = isDate;
|
|
@@ -55,6 +117,7 @@ exports.isUndefined = isUndefined;
|
|
|
55
117
|
exports.notNull = notNull;
|
|
56
118
|
exports.notNullish = notNullish;
|
|
57
119
|
exports.notUndefined = notUndefined;
|
|
120
|
+
exports.print = print;
|
|
58
121
|
exports.random = random;
|
|
59
122
|
exports.safe = safe;
|
|
60
123
|
exports.singleOrNull = singleOrNull;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
declare function singleOrNull<T>(arr: T[]): T | null;
|
|
2
|
-
declare function toArray<T>(array?: T | Array<T>): Array<T>;
|
|
3
|
-
|
|
4
|
-
declare function take<T, R = void>(value: T, fn: (it: T) => R): R;
|
|
5
|
-
declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
|
|
6
|
-
declare function takeIf<T>(value: T, predicate: (it: T) => boolean, defaultValue: T): T;
|
|
7
|
-
declare function safe<R>(fn: () => R): R | undefined;
|
|
8
|
-
|
|
9
1
|
type Nullable<T> = T | null | undefined;
|
|
10
2
|
type NotNullable<T> = Exclude<T, null | undefined>;
|
|
11
3
|
type NotNull<T> = Exclude<T, null>;
|
|
@@ -14,6 +6,14 @@ type Arrayable<T> = T | Array<T>;
|
|
|
14
6
|
type ElementOf<T> = T extends Array<infer Element> ? Element : never;
|
|
15
7
|
type Fn<R = void> = (...args: any[]) => R;
|
|
16
8
|
|
|
9
|
+
declare function singleOrNull<T>(arr: T[]): T | null;
|
|
10
|
+
declare function toArray<T>(array?: T | Array<T>): Array<T>;
|
|
11
|
+
|
|
12
|
+
declare function take<T, R = void>(value: T, fn: (it: T) => R): R;
|
|
13
|
+
declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
|
|
14
|
+
declare function takeIf<T>(value: T, predicate: (it: T) => boolean, defaultValue: T): T;
|
|
15
|
+
declare function safe<R>(fn: () => R): R | undefined;
|
|
16
|
+
|
|
17
17
|
declare const isFunction: (val: any) => val is Fn;
|
|
18
18
|
declare const isBoolean: (val: any) => val is boolean;
|
|
19
19
|
declare const isNumber: (val: any) => val is number;
|
|
@@ -33,6 +33,78 @@ declare const notUndefined: <T>(v: T | undefined) => v is Exclude<T, undefined>;
|
|
|
33
33
|
*/
|
|
34
34
|
declare function random(max: number, min?: number): number;
|
|
35
35
|
|
|
36
|
+
declare const colors: {
|
|
37
|
+
/** 重置颜色 */
|
|
38
|
+
reset: string;
|
|
39
|
+
/** 亮色(加粗) */
|
|
40
|
+
bright: string;
|
|
41
|
+
/** 斜体 */
|
|
42
|
+
italic: string;
|
|
43
|
+
/** 下划线 */
|
|
44
|
+
underline: string;
|
|
45
|
+
/** 反向 */
|
|
46
|
+
reverse: string;
|
|
47
|
+
/** 隐藏 */
|
|
48
|
+
hidden: string;
|
|
49
|
+
/** 灰色 */
|
|
50
|
+
grey: string;
|
|
51
|
+
/** 黑色 */
|
|
52
|
+
black: string;
|
|
53
|
+
/** 红色 */
|
|
54
|
+
red: string;
|
|
55
|
+
/** 绿色 */
|
|
56
|
+
green: string;
|
|
57
|
+
/** 黄色 */
|
|
58
|
+
yellow: string;
|
|
59
|
+
/** 蓝色 */
|
|
60
|
+
blue: string;
|
|
61
|
+
/** 品红 */
|
|
62
|
+
magenta: string;
|
|
63
|
+
/** 青色 */
|
|
64
|
+
cyan: string;
|
|
65
|
+
/** 白色 */
|
|
66
|
+
white: string;
|
|
67
|
+
/** 背景黑色 */
|
|
68
|
+
bgBlack: string;
|
|
69
|
+
/** 背景红色 */
|
|
70
|
+
bgRed: string;
|
|
71
|
+
/** 背景绿色 */
|
|
72
|
+
bgGreen: string;
|
|
73
|
+
/** 背景黄色 */
|
|
74
|
+
bgYellow: string;
|
|
75
|
+
/** 背景蓝色 */
|
|
76
|
+
bgBlue: string;
|
|
77
|
+
/** 背景品红 */
|
|
78
|
+
bgMagenta: string;
|
|
79
|
+
/** 背景青色 */
|
|
80
|
+
bgCyan: string;
|
|
81
|
+
/** 背景白色 */
|
|
82
|
+
bgWhite: string;
|
|
83
|
+
};
|
|
84
|
+
declare const map: {
|
|
85
|
+
info: {
|
|
86
|
+
color: string;
|
|
87
|
+
symbol: string;
|
|
88
|
+
};
|
|
89
|
+
warn: {
|
|
90
|
+
color: string;
|
|
91
|
+
symbol: string;
|
|
92
|
+
};
|
|
93
|
+
success: {
|
|
94
|
+
color: string;
|
|
95
|
+
symbol: string;
|
|
96
|
+
};
|
|
97
|
+
error: {
|
|
98
|
+
color: string;
|
|
99
|
+
symbol: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* process.stdout.write('msg')
|
|
104
|
+
* process.stdout.clearLine(0)
|
|
105
|
+
*/
|
|
106
|
+
declare function print(msg: any, type?: keyof typeof map): void;
|
|
107
|
+
|
|
36
108
|
declare const timestamp: () => number;
|
|
37
109
|
|
|
38
|
-
export { type Arrayable, type ElementOf, type Fn, type NotNull, type NotNullable, type NotUndefined, type Nullable, isArray, isBoolean, isDate, isFunction, isNull, isNumber, isObject, isRegExp, isString, isUndefined, notNull, notNullish, notUndefined, random, safe, singleOrNull, take, takeIf, timestamp, toArray };
|
|
110
|
+
export { type Arrayable, type ElementOf, type Fn, type NotNull, type NotNullable, type NotUndefined, type Nullable, colors, isArray, isBoolean, isDate, isFunction, isNull, isNumber, isObject, isRegExp, isString, isUndefined, notNull, notNullish, notUndefined, print, random, safe, singleOrNull, take, takeIf, timestamp, toArray };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
declare function singleOrNull<T>(arr: T[]): T | null;
|
|
2
|
-
declare function toArray<T>(array?: T | Array<T>): Array<T>;
|
|
3
|
-
|
|
4
|
-
declare function take<T, R = void>(value: T, fn: (it: T) => R): R;
|
|
5
|
-
declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
|
|
6
|
-
declare function takeIf<T>(value: T, predicate: (it: T) => boolean, defaultValue: T): T;
|
|
7
|
-
declare function safe<R>(fn: () => R): R | undefined;
|
|
8
|
-
|
|
9
1
|
type Nullable<T> = T | null | undefined;
|
|
10
2
|
type NotNullable<T> = Exclude<T, null | undefined>;
|
|
11
3
|
type NotNull<T> = Exclude<T, null>;
|
|
@@ -14,6 +6,14 @@ type Arrayable<T> = T | Array<T>;
|
|
|
14
6
|
type ElementOf<T> = T extends Array<infer Element> ? Element : never;
|
|
15
7
|
type Fn<R = void> = (...args: any[]) => R;
|
|
16
8
|
|
|
9
|
+
declare function singleOrNull<T>(arr: T[]): T | null;
|
|
10
|
+
declare function toArray<T>(array?: T | Array<T>): Array<T>;
|
|
11
|
+
|
|
12
|
+
declare function take<T, R = void>(value: T, fn: (it: T) => R): R;
|
|
13
|
+
declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
|
|
14
|
+
declare function takeIf<T>(value: T, predicate: (it: T) => boolean, defaultValue: T): T;
|
|
15
|
+
declare function safe<R>(fn: () => R): R | undefined;
|
|
16
|
+
|
|
17
17
|
declare const isFunction: (val: any) => val is Fn;
|
|
18
18
|
declare const isBoolean: (val: any) => val is boolean;
|
|
19
19
|
declare const isNumber: (val: any) => val is number;
|
|
@@ -33,6 +33,78 @@ declare const notUndefined: <T>(v: T | undefined) => v is Exclude<T, undefined>;
|
|
|
33
33
|
*/
|
|
34
34
|
declare function random(max: number, min?: number): number;
|
|
35
35
|
|
|
36
|
+
declare const colors: {
|
|
37
|
+
/** 重置颜色 */
|
|
38
|
+
reset: string;
|
|
39
|
+
/** 亮色(加粗) */
|
|
40
|
+
bright: string;
|
|
41
|
+
/** 斜体 */
|
|
42
|
+
italic: string;
|
|
43
|
+
/** 下划线 */
|
|
44
|
+
underline: string;
|
|
45
|
+
/** 反向 */
|
|
46
|
+
reverse: string;
|
|
47
|
+
/** 隐藏 */
|
|
48
|
+
hidden: string;
|
|
49
|
+
/** 灰色 */
|
|
50
|
+
grey: string;
|
|
51
|
+
/** 黑色 */
|
|
52
|
+
black: string;
|
|
53
|
+
/** 红色 */
|
|
54
|
+
red: string;
|
|
55
|
+
/** 绿色 */
|
|
56
|
+
green: string;
|
|
57
|
+
/** 黄色 */
|
|
58
|
+
yellow: string;
|
|
59
|
+
/** 蓝色 */
|
|
60
|
+
blue: string;
|
|
61
|
+
/** 品红 */
|
|
62
|
+
magenta: string;
|
|
63
|
+
/** 青色 */
|
|
64
|
+
cyan: string;
|
|
65
|
+
/** 白色 */
|
|
66
|
+
white: string;
|
|
67
|
+
/** 背景黑色 */
|
|
68
|
+
bgBlack: string;
|
|
69
|
+
/** 背景红色 */
|
|
70
|
+
bgRed: string;
|
|
71
|
+
/** 背景绿色 */
|
|
72
|
+
bgGreen: string;
|
|
73
|
+
/** 背景黄色 */
|
|
74
|
+
bgYellow: string;
|
|
75
|
+
/** 背景蓝色 */
|
|
76
|
+
bgBlue: string;
|
|
77
|
+
/** 背景品红 */
|
|
78
|
+
bgMagenta: string;
|
|
79
|
+
/** 背景青色 */
|
|
80
|
+
bgCyan: string;
|
|
81
|
+
/** 背景白色 */
|
|
82
|
+
bgWhite: string;
|
|
83
|
+
};
|
|
84
|
+
declare const map: {
|
|
85
|
+
info: {
|
|
86
|
+
color: string;
|
|
87
|
+
symbol: string;
|
|
88
|
+
};
|
|
89
|
+
warn: {
|
|
90
|
+
color: string;
|
|
91
|
+
symbol: string;
|
|
92
|
+
};
|
|
93
|
+
success: {
|
|
94
|
+
color: string;
|
|
95
|
+
symbol: string;
|
|
96
|
+
};
|
|
97
|
+
error: {
|
|
98
|
+
color: string;
|
|
99
|
+
symbol: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* process.stdout.write('msg')
|
|
104
|
+
* process.stdout.clearLine(0)
|
|
105
|
+
*/
|
|
106
|
+
declare function print(msg: any, type?: keyof typeof map): void;
|
|
107
|
+
|
|
36
108
|
declare const timestamp: () => number;
|
|
37
109
|
|
|
38
|
-
export { type Arrayable, type ElementOf, type Fn, type NotNull, type NotNullable, type NotUndefined, type Nullable, isArray, isBoolean, isDate, isFunction, isNull, isNumber, isObject, isRegExp, isString, isUndefined, notNull, notNullish, notUndefined, random, safe, singleOrNull, take, takeIf, timestamp, toArray };
|
|
110
|
+
export { type Arrayable, type ElementOf, type Fn, type NotNull, type NotNullable, type NotUndefined, type Nullable, colors, isArray, isBoolean, isDate, isFunction, isNull, isNumber, isObject, isRegExp, isString, isUndefined, notNull, notNullish, notUndefined, print, random, safe, singleOrNull, take, takeIf, timestamp, toArray };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
declare function singleOrNull<T>(arr: T[]): T | null;
|
|
2
|
-
declare function toArray<T>(array?: T | Array<T>): Array<T>;
|
|
3
|
-
|
|
4
|
-
declare function take<T, R = void>(value: T, fn: (it: T) => R): R;
|
|
5
|
-
declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
|
|
6
|
-
declare function takeIf<T>(value: T, predicate: (it: T) => boolean, defaultValue: T): T;
|
|
7
|
-
declare function safe<R>(fn: () => R): R | undefined;
|
|
8
|
-
|
|
9
1
|
type Nullable<T> = T | null | undefined;
|
|
10
2
|
type NotNullable<T> = Exclude<T, null | undefined>;
|
|
11
3
|
type NotNull<T> = Exclude<T, null>;
|
|
@@ -14,6 +6,14 @@ type Arrayable<T> = T | Array<T>;
|
|
|
14
6
|
type ElementOf<T> = T extends Array<infer Element> ? Element : never;
|
|
15
7
|
type Fn<R = void> = (...args: any[]) => R;
|
|
16
8
|
|
|
9
|
+
declare function singleOrNull<T>(arr: T[]): T | null;
|
|
10
|
+
declare function toArray<T>(array?: T | Array<T>): Array<T>;
|
|
11
|
+
|
|
12
|
+
declare function take<T, R = void>(value: T, fn: (it: T) => R): R;
|
|
13
|
+
declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
|
|
14
|
+
declare function takeIf<T>(value: T, predicate: (it: T) => boolean, defaultValue: T): T;
|
|
15
|
+
declare function safe<R>(fn: () => R): R | undefined;
|
|
16
|
+
|
|
17
17
|
declare const isFunction: (val: any) => val is Fn;
|
|
18
18
|
declare const isBoolean: (val: any) => val is boolean;
|
|
19
19
|
declare const isNumber: (val: any) => val is number;
|
|
@@ -33,6 +33,78 @@ declare const notUndefined: <T>(v: T | undefined) => v is Exclude<T, undefined>;
|
|
|
33
33
|
*/
|
|
34
34
|
declare function random(max: number, min?: number): number;
|
|
35
35
|
|
|
36
|
+
declare const colors: {
|
|
37
|
+
/** 重置颜色 */
|
|
38
|
+
reset: string;
|
|
39
|
+
/** 亮色(加粗) */
|
|
40
|
+
bright: string;
|
|
41
|
+
/** 斜体 */
|
|
42
|
+
italic: string;
|
|
43
|
+
/** 下划线 */
|
|
44
|
+
underline: string;
|
|
45
|
+
/** 反向 */
|
|
46
|
+
reverse: string;
|
|
47
|
+
/** 隐藏 */
|
|
48
|
+
hidden: string;
|
|
49
|
+
/** 灰色 */
|
|
50
|
+
grey: string;
|
|
51
|
+
/** 黑色 */
|
|
52
|
+
black: string;
|
|
53
|
+
/** 红色 */
|
|
54
|
+
red: string;
|
|
55
|
+
/** 绿色 */
|
|
56
|
+
green: string;
|
|
57
|
+
/** 黄色 */
|
|
58
|
+
yellow: string;
|
|
59
|
+
/** 蓝色 */
|
|
60
|
+
blue: string;
|
|
61
|
+
/** 品红 */
|
|
62
|
+
magenta: string;
|
|
63
|
+
/** 青色 */
|
|
64
|
+
cyan: string;
|
|
65
|
+
/** 白色 */
|
|
66
|
+
white: string;
|
|
67
|
+
/** 背景黑色 */
|
|
68
|
+
bgBlack: string;
|
|
69
|
+
/** 背景红色 */
|
|
70
|
+
bgRed: string;
|
|
71
|
+
/** 背景绿色 */
|
|
72
|
+
bgGreen: string;
|
|
73
|
+
/** 背景黄色 */
|
|
74
|
+
bgYellow: string;
|
|
75
|
+
/** 背景蓝色 */
|
|
76
|
+
bgBlue: string;
|
|
77
|
+
/** 背景品红 */
|
|
78
|
+
bgMagenta: string;
|
|
79
|
+
/** 背景青色 */
|
|
80
|
+
bgCyan: string;
|
|
81
|
+
/** 背景白色 */
|
|
82
|
+
bgWhite: string;
|
|
83
|
+
};
|
|
84
|
+
declare const map: {
|
|
85
|
+
info: {
|
|
86
|
+
color: string;
|
|
87
|
+
symbol: string;
|
|
88
|
+
};
|
|
89
|
+
warn: {
|
|
90
|
+
color: string;
|
|
91
|
+
symbol: string;
|
|
92
|
+
};
|
|
93
|
+
success: {
|
|
94
|
+
color: string;
|
|
95
|
+
symbol: string;
|
|
96
|
+
};
|
|
97
|
+
error: {
|
|
98
|
+
color: string;
|
|
99
|
+
symbol: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* process.stdout.write('msg')
|
|
104
|
+
* process.stdout.clearLine(0)
|
|
105
|
+
*/
|
|
106
|
+
declare function print(msg: any, type?: keyof typeof map): void;
|
|
107
|
+
|
|
36
108
|
declare const timestamp: () => number;
|
|
37
109
|
|
|
38
|
-
export { type Arrayable, type ElementOf, type Fn, type NotNull, type NotNullable, type NotUndefined, type Nullable, isArray, isBoolean, isDate, isFunction, isNull, isNumber, isObject, isRegExp, isString, isUndefined, notNull, notNullish, notUndefined, random, safe, singleOrNull, take, takeIf, timestamp, toArray };
|
|
110
|
+
export { type Arrayable, type ElementOf, type Fn, type NotNull, type NotNullable, type NotUndefined, type Nullable, colors, isArray, isBoolean, isDate, isFunction, isNull, isNumber, isObject, isRegExp, isString, isUndefined, notNull, notNullish, notUndefined, print, random, safe, singleOrNull, take, takeIf, timestamp, toArray };
|
package/dist/index.mjs
CHANGED
|
@@ -38,6 +38,67 @@ function random(max, min = 0) {
|
|
|
38
38
|
return Math.floor(Math.random() * max) + min;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
const colors = {
|
|
42
|
+
/** 重置颜色 */
|
|
43
|
+
reset: "\x1B[0m",
|
|
44
|
+
/** 亮色(加粗) */
|
|
45
|
+
bright: "\x1B[1m",
|
|
46
|
+
/** 斜体 */
|
|
47
|
+
italic: "\x1B[3m",
|
|
48
|
+
/** 下划线 */
|
|
49
|
+
underline: "\x1B[4m",
|
|
50
|
+
/** 反向 */
|
|
51
|
+
reverse: "\x1B[7m",
|
|
52
|
+
/** 隐藏 */
|
|
53
|
+
hidden: "\x1B[8m",
|
|
54
|
+
/** 灰色 */
|
|
55
|
+
grey: "\x1B[2m",
|
|
56
|
+
/** 黑色 */
|
|
57
|
+
black: "\x1B[30m",
|
|
58
|
+
/** 红色 */
|
|
59
|
+
red: "\x1B[31m",
|
|
60
|
+
/** 绿色 */
|
|
61
|
+
green: "\x1B[32m",
|
|
62
|
+
/** 黄色 */
|
|
63
|
+
yellow: "\x1B[33m",
|
|
64
|
+
/** 蓝色 */
|
|
65
|
+
blue: "\x1B[34m",
|
|
66
|
+
/** 品红 */
|
|
67
|
+
magenta: "\x1B[35m",
|
|
68
|
+
/** 青色 */
|
|
69
|
+
cyan: "\x1B[36m",
|
|
70
|
+
/** 白色 */
|
|
71
|
+
white: "\x1B[37m",
|
|
72
|
+
/** 背景黑色 */
|
|
73
|
+
bgBlack: "\x1B[40m",
|
|
74
|
+
/** 背景红色 */
|
|
75
|
+
bgRed: "\x1B[41m",
|
|
76
|
+
/** 背景绿色 */
|
|
77
|
+
bgGreen: "\x1B[42m",
|
|
78
|
+
/** 背景黄色 */
|
|
79
|
+
bgYellow: "\x1B[43m",
|
|
80
|
+
/** 背景蓝色 */
|
|
81
|
+
bgBlue: "\x1B[44m",
|
|
82
|
+
/** 背景品红 */
|
|
83
|
+
bgMagenta: "\x1B[45m",
|
|
84
|
+
/** 背景青色 */
|
|
85
|
+
bgCyan: "\x1B[46m",
|
|
86
|
+
/** 背景白色 */
|
|
87
|
+
bgWhite: "\x1B[47m"
|
|
88
|
+
};
|
|
89
|
+
const map = {
|
|
90
|
+
info: { color: colors.blue, symbol: "\u{1D4F2}" },
|
|
91
|
+
warn: { color: colors.yellow, symbol: "\u{1D4F2}" },
|
|
92
|
+
success: { color: colors.green, symbol: "\u2714\uFE0E" },
|
|
93
|
+
error: { color: colors.red, symbol: "\u2718" }
|
|
94
|
+
};
|
|
95
|
+
function print(msg, type) {
|
|
96
|
+
if (!type)
|
|
97
|
+
console.log(msg);
|
|
98
|
+
else
|
|
99
|
+
console.log(`${map[type].color}${map[type].symbol} ${colors.grey}${msg}${colors.reset}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
41
102
|
const timestamp = () => +Date.now();
|
|
42
103
|
|
|
43
|
-
export { isArray, isBoolean, isDate, isFunction, isNull, isNumber, isObject, isRegExp, isString, isUndefined, notNull, notNullish, notUndefined, random, safe, singleOrNull, take, takeIf, timestamp, toArray };
|
|
104
|
+
export { colors, isArray, isBoolean, isDate, isFunction, isNull, isNumber, isObject, isRegExp, isString, isUndefined, notNull, notNullish, notUndefined, print, random, safe, singleOrNull, take, takeIf, timestamp, toArray };
|