@whitesev/utils 2.5.5 → 2.5.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.
@@ -32,5 +32,14 @@ declare class UtilsGMCookie {
32
32
  * @param callback 删除操作后的回调(成功/失败)
33
33
  */
34
34
  delete(option: UtilsGMCookieDeleteOptions, callback?: (error?: Error) => void): void;
35
+ /**
36
+ * 解析cookie字符串
37
+ * 例如:document.cookie
38
+ * @param cookieStr
39
+ */
40
+ parseCookie(cookieStr: string): {
41
+ key: string;
42
+ value: string;
43
+ }[];
35
44
  }
36
45
  export { UtilsGMCookie };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/utils",
3
- "version": "2.5.5",
3
+ "version": "2.5.6",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
package/src/Utils.ts CHANGED
@@ -29,7 +29,7 @@ class Utils {
29
29
  this.windowApi = new WindowApi(option);
30
30
  }
31
31
  /** 版本号 */
32
- version = "2024.12.3";
32
+ version = "2024.12.25";
33
33
 
34
34
  /**
35
35
  * 在页面中增加style元素,如果html节点存在子节点,添加子节点第一个,反之,添加到html节点的子节点最后一个
@@ -1245,7 +1245,7 @@ class Utils {
1245
1245
  deviation = Number.isNaN(deviation) ? 1 : deviation;
1246
1246
  const UtilsContext = this;
1247
1247
  // 最大值 2147483647
1248
- const maxZIndex = Math.pow(2, 31) - 1;
1248
+ // const maxZIndex = Math.pow(2, 31) - 1;
1249
1249
  // 比较值 2000000000
1250
1250
  const maxZIndexCompare = 2 * Math.pow(10, 9);
1251
1251
  // 当前页面最大的z-index
@@ -223,6 +223,27 @@ class UtilsGMCookie {
223
223
  }
224
224
  }
225
225
  }
226
+ /**
227
+ * 解析cookie字符串
228
+ * 例如:document.cookie
229
+ * @param cookieStr
230
+ */
231
+ parseCookie(cookieStr: string) {
232
+ let cookies = cookieStr.split(";");
233
+ let result: { key: string; value: string }[] = [];
234
+ for (const cookieItem of cookies) {
235
+ let item = cookieItem.trim();
236
+ let itemSplit = item.split("=");
237
+ let itemName = itemSplit[0];
238
+ itemSplit.splice(0, 1);
239
+ let itemValue = decodeURIComponent(itemSplit.join(""));
240
+ result.push({
241
+ key: itemName,
242
+ value: itemValue,
243
+ });
244
+ }
245
+ return result;
246
+ }
226
247
  }
227
248
 
228
249
  export { UtilsGMCookie };