@anjianshi/utils 2.2.4 → 2.2.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.
@@ -4,9 +4,7 @@
4
4
  */
5
5
  declare global {
6
6
  interface Window {
7
- app: {
8
- [key: string]: unknown;
9
- };
7
+ app: Record<string, unknown>;
10
8
  }
11
9
  }
12
10
  export default function registerGlobal(key: string, content: unknown): void;
@@ -16,12 +16,12 @@ export interface Success<T = void> {
16
16
  success: true;
17
17
  data: T;
18
18
  }
19
- export type Failed<T = void> = {
19
+ export interface Failed<T = void> {
20
20
  success: false;
21
21
  message: string;
22
22
  code?: string | number;
23
23
  data: T;
24
- };
24
+ }
25
25
  export type MaySuccess<T = void, FT = void> = Success<T> | Failed<FT>;
26
26
  /** 生成 Success 数据 */
27
27
  declare function success(): Success;
package/lang/string.js CHANGED
@@ -47,7 +47,7 @@ export function numericCompare(a, b) {
47
47
  */
48
48
  export function safeParseInt(value, fallback, redix = 10) {
49
49
  const raw = parseInt(String(value), redix);
50
- return isFinite(raw) ? raw : fallback ?? raw;
50
+ return isFinite(raw) ? raw : (fallback ?? raw);
51
51
  }
52
52
  /**
53
53
  * 字符串解析成浮点数;若解析结果是 NaN,返回 fallback
package/logging/adapt.js CHANGED
@@ -15,6 +15,7 @@ export function adaptDebugLib(debugLib, enable = '', logger) {
15
15
  emulate.storage.data[name] = value;
16
16
  },
17
17
  removeItem(name) {
18
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
18
19
  delete emulate.storage.data[name];
19
20
  },
20
21
  },
package/logging/index.js CHANGED
@@ -27,8 +27,7 @@ export class Logger {
27
27
  base;
28
28
  level = LogLevel.Info;
29
29
  handlers = new Set();
30
- constructor(name = '', base = null // 指定上级 logger,当前 logger 记录的日志也会传递给上级
31
- ) {
30
+ constructor(name = '', base = null) {
32
31
  this.name = name;
33
32
  this.base = base;
34
33
  }
package/md5.js CHANGED
@@ -1,4 +1,4 @@
1
- /* eslint-disable no-multi-assign, @typescript-eslint/restrict-plus-operands */
1
+ /* eslint-disable no-multi-assign */
2
2
  /**
3
3
  * MD5 算法来自:https://github.com/emn178/js-md5
4
4
  */
@@ -297,7 +297,6 @@ export class MD5 {
297
297
  const HEX_CHARS = '0123456789abcdef'.split('');
298
298
  return (
299
299
  // prettier-ignore
300
- // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
301
300
  HEX_CHARS[(h0 >> 4) & 0x0f] + HEX_CHARS[h0 & 0x0f] + HEX_CHARS[(h0 >> 12) & 0x0f] + HEX_CHARS[(h0 >> 8) & 0x0f] + HEX_CHARS[(h0 >> 20) & 0x0f] +
302
301
  HEX_CHARS[(h0 >> 16) & 0x0f] + HEX_CHARS[(h0 >> 28) & 0x0f] + HEX_CHARS[(h0 >> 24) & 0x0f] + HEX_CHARS[(h1 >> 4) & 0x0f] + HEX_CHARS[h1 & 0x0f] +
303
302
  HEX_CHARS[(h1 >> 12) & 0x0f] + HEX_CHARS[(h1 >> 8) & 0x0f] + HEX_CHARS[(h1 >> 20) & 0x0f] + HEX_CHARS[(h1 >> 16) & 0x0f] + HEX_CHARS[(h1 >> 28) & 0x0f] +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anjianshi/utils",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "description": "Common JavaScript Utils",
5
5
  "homepage": "https://github.com/anjianshi/js-packages/utils",
6
6
  "bugs": {
@@ -27,8 +27,8 @@
27
27
  "typescript": "^5.5.4",
28
28
  "vconsole": "^3.15.1",
29
29
  "@anjianshi/presets-eslint-node": "4.0.8",
30
- "@anjianshi/presets-eslint-typescript": "5.0.5",
31
30
  "@anjianshi/presets-prettier": "3.0.1",
31
+ "@anjianshi/presets-eslint-typescript": "5.0.5",
32
32
  "@anjianshi/presets-typescript": "3.2.2"
33
33
  },
34
34
  "peerDependencies": {
@@ -22,6 +22,7 @@ export interface CommonOptions<Defaults = unknown> {
22
22
  * 指定后 required 选项将失去作用。
23
23
  */
24
24
  defaults?: Defaults;
25
+ [key: string]: unknown;
25
26
  }
26
27
  /**
27
28
  * 补全了的 Options