@bhsd/nodejs 0.1.1 → 0.2.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/dist/index.d.ts CHANGED
@@ -1,6 +1,31 @@
1
+ /**
2
+ * 进行性能分析,生成prof.json和prof-summary.json文件
3
+ * @param callback 要分析的函数
4
+ * @param dir 输出文件夹路径
5
+ */
1
6
  export declare const profile: (callback: () => void | Promise<void>, dir: string) => Promise<void>;
2
7
  /**
3
8
  * 刷新屏幕输出
4
9
  * @param str 要输出的字符串
5
10
  */
6
11
  export declare const refreshStdout: (str: string) => void;
12
+ /**
13
+ * 将字符串以绿色显示
14
+ * @param str 要显示的字符串
15
+ */
16
+ export declare const green: (str: string) => string;
17
+ /**
18
+ * 将字符串以黄色显示
19
+ * @param str 要显示的字符串
20
+ */
21
+ export declare const yellow: (str: string) => string;
22
+ /**
23
+ * 将字符串以红色显示
24
+ * @param str 要显示的字符串
25
+ */
26
+ export declare const red: (str: string) => string;
27
+ /**
28
+ * 将字符串以蓝色显示
29
+ * @param str 要显示的字符串
30
+ */
31
+ export declare const blue: (str: string) => string;
package/dist/index.js CHANGED
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.refreshStdout = exports.profile = void 0;
6
+ exports.blue = exports.red = exports.yellow = exports.green = exports.refreshStdout = exports.profile = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const promises_1 = require("inspector/promises");
10
+ const util_1 = __importDefault(require("util"));
10
11
  /**
11
12
  * Adds the ticks to the myTicks object.
12
13
  * @param myTicks ticks记录对象
@@ -19,6 +20,11 @@ const addTicks = (myTicks, positionTicks) => {
19
20
  }
20
21
  }
21
22
  };
23
+ /**
24
+ * 进行性能分析,生成prof.json和prof-summary.json文件
25
+ * @param callback 要分析的函数
26
+ * @param dir 输出文件夹路径
27
+ */
22
28
  const profile = async (callback, dir) => {
23
29
  const session = new promises_1.Session();
24
30
  session.connect();
@@ -57,3 +63,31 @@ const refreshStdout = (str) => {
57
63
  process.stdout.write(`\x1B[?7l${str}\x1B[?7h\r`);
58
64
  };
59
65
  exports.refreshStdout = refreshStdout;
66
+ /**
67
+ * 将字符串以绿色显示
68
+ * @param str 要显示的字符串
69
+ */
70
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
71
+ const green = (str) => util_1.default.styleText?.('green', str) ?? str;
72
+ exports.green = green;
73
+ /**
74
+ * 将字符串以黄色显示
75
+ * @param str 要显示的字符串
76
+ */
77
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
78
+ const yellow = (str) => util_1.default.styleText?.('yellow', str) ?? str;
79
+ exports.yellow = yellow;
80
+ /**
81
+ * 将字符串以红色显示
82
+ * @param str 要显示的字符串
83
+ */
84
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
85
+ const red = (str) => util_1.default.styleText?.('red', str) ?? str;
86
+ exports.red = red;
87
+ /**
88
+ * 将字符串以蓝色显示
89
+ * @param str 要显示的字符串
90
+ */
91
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
92
+ const blue = (str) => util_1.default.styleText?.('blue', str) ?? str;
93
+ exports.blue = blue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/nodejs",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "homepage": "https://github.com/bhsd-harry/nodejs#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/bhsd-harry/nodejs/issues"
@@ -19,18 +19,18 @@
19
19
  "lint": "npm run lint:ts"
20
20
  },
21
21
  "devDependencies": {
22
- "@bhsd/code-standard": "^2.1.0",
23
- "@stylistic/eslint-plugin": "^5.9.0",
22
+ "@bhsd/code-standard": "^2.1.1",
23
+ "@stylistic/eslint-plugin": "^5.10.0",
24
24
  "@types/node": "^24.11.0",
25
- "@typescript-eslint/eslint-plugin": "^8.54.0",
26
- "@typescript-eslint/parser": "^8.54.0",
27
- "eslint": "^9.39.3",
25
+ "@typescript-eslint/eslint-plugin": "^8.57.0",
26
+ "@typescript-eslint/parser": "^8.57.0",
27
+ "eslint": "^9.39.4",
28
28
  "eslint-plugin-eslint-comments": "^3.2.0",
29
29
  "eslint-plugin-jsdoc": "^62.7.1",
30
30
  "eslint-plugin-jsonc": "^3.1.1",
31
31
  "eslint-plugin-n": "^17.24.0",
32
32
  "eslint-plugin-promise": "^7.2.1",
33
- "eslint-plugin-regexp": "^3.0.0",
33
+ "eslint-plugin-regexp": "^3.1.0",
34
34
  "eslint-plugin-unicorn": "^63.0.0",
35
35
  "typescript": "^5.9.3"
36
36
  },