@aiot-toolkit/shared-utils 2.0.2-beta.4 → 2.0.2-beta.6

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.
@@ -13,6 +13,7 @@ declare class CommonUtil {
13
13
  * @returns hash 值
14
14
  */
15
15
  static calcDataDigest(buffer: Buffer): Buffer;
16
+ static calcImageDigest(filePath: string): string;
16
17
  /**
17
18
  * 从开发者项目的 node_module 中加载指定依赖;
18
19
  * 如果不存在,提示下载;存在则返回加载的依赖
@@ -25,6 +25,11 @@ class CommonUtil {
25
25
  hash.update(buffer);
26
26
  return hash.digest();
27
27
  }
28
+ static calcImageDigest(filePath) {
29
+ const data = fs_1.default.readFileSync(filePath);
30
+ const hash = crypto_1.default.createHash('md5').update(data);
31
+ return hash.digest('hex');
32
+ }
28
33
  /**
29
34
  * 从开发者项目的 node_module 中加载指定依赖;
30
35
  * 如果不存在,提示下载;存在则返回加载的依赖
@@ -116,10 +116,7 @@ class FileUtil {
116
116
  * @returns
117
117
  */
118
118
  static updatePath(path, fullName) {
119
- if (fs_extra_1.default.statSync(path).isFile()) {
120
- return path_1.default.join(path_1.default.dirname(path), fullName);
121
- }
122
- return path;
119
+ return path_1.default.join(path_1.default.dirname(path), fullName);
123
120
  }
124
121
  /**
125
122
  * 复制文件
@@ -22,7 +22,7 @@ declare class StringUtil {
22
22
  * @param styleTransform 是否为style解析树的数组转换
23
23
  * @returns
24
24
  */
25
- static arrayTostring(arr: any[], styleTransform?: boolean): string;
25
+ static arrayToString(arr: any[], styleTransform?: boolean): string;
26
26
  /**
27
27
  * 对象转字符串
28
28
  * @param obj
@@ -34,7 +34,7 @@ class StringUtil {
34
34
  * @param styleTransform 是否为style解析树的数组转换
35
35
  * @returns
36
36
  */
37
- static arrayTostring(arr, styleTransform = false) {
37
+ static arrayToString(arr, styleTransform = false) {
38
38
  if (Array.isArray(arr)) {
39
39
  if (arr.length <= 0) {
40
40
  return '[]';
@@ -48,7 +48,7 @@ class StringUtil {
48
48
  switch (typeof item) {
49
49
  case 'object':
50
50
  if (Array.isArray(item)) {
51
- valueStr = StringUtil.arrayTostring(item, styleTransform);
51
+ valueStr = StringUtil.arrayToString(item, styleTransform);
52
52
  }
53
53
  else {
54
54
  valueStr = StringUtil.objectToString(item, styleTransform);
@@ -83,7 +83,7 @@ class StringUtil {
83
83
  switch (typeof value) {
84
84
  case 'object':
85
85
  if (Array.isArray(value)) {
86
- valueStr = StringUtil.arrayTostring(value, styleTransform);
86
+ valueStr = StringUtil.arrayToString(value, styleTransform);
87
87
  }
88
88
  else {
89
89
  valueStr = StringUtil.objectToString(value, styleTransform);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/shared-utils",
3
- "version": "2.0.2-beta.4",
3
+ "version": "2.0.2-beta.6",
4
4
  "description": "The common method functions of the aiot-toolkit.",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -23,7 +23,8 @@
23
23
  "qrcode-terminal": "^0.12.0"
24
24
  },
25
25
  "devDependencies": {
26
+ "@types/fs-extra": "^11.0.4",
26
27
  "@types/qrcode-terminal": "^0.12.0"
27
28
  },
28
- "gitHead": "656add8e64d8101b9f3886957c5b9ae23e2e854f"
29
+ "gitHead": "b9b99afff176075380c2ec95b43797d696c393c1"
29
30
  }