xshell 1.0.195 → 1.0.196

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/i18n/dict.json CHANGED
@@ -143,6 +143,9 @@
143
143
  "断言失败": {
144
144
  "en": "assertion failed"
145
145
  },
146
+ "检查失败": {
147
+ "en": "check failed"
148
+ },
146
149
  " 太短": {
147
150
  "en": " is too short"
148
151
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.195",
3
+ "version": "1.0.196",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -92,7 +92,7 @@
92
92
  "ora": "^8.1.1",
93
93
  "react": "^18.3.1",
94
94
  "react-i18next": "^15.1.0",
95
- "react-object-model": "^1.2.15",
95
+ "react-object-model": "^1.2.17",
96
96
  "resolve-path": "^1.4.0",
97
97
  "sass": "^1.80.6",
98
98
  "sass-loader": "^16.0.3",
@@ -2,6 +2,8 @@ export declare const noop: () => void;
2
2
  /** value 不为 null 或 undefined */
3
3
  export declare const not_empty: (value: any) => boolean;
4
4
  export declare function assert(assertion: any, message?: string): never | void;
5
+ /** 做参数校验,逻辑检查 */
6
+ export declare function check(condition: any, message?: string): never | void;
5
7
  /** 通过 console.log 打印对象并返回
6
8
  @example
7
9
  log('label', obj)
package/utils.browser.js CHANGED
@@ -5,7 +5,14 @@ export const not_empty = (value) => value !== null && value !== undefined;
5
5
  export function assert(assertion, message) {
6
6
  if (!assertion) {
7
7
  debugger;
8
- throw Object.assign(new Error(`断言失败: ${message ? `${message}: ` : ''}${assertion}`), { assertion });
8
+ throw new Error(`断言失败: ${message ? `${message}: ` : ''}`);
9
+ }
10
+ }
11
+ /** 做参数校验,逻辑检查 */
12
+ export function check(condition, message) {
13
+ if (!condition) {
14
+ debugger;
15
+ throw new Error(message || '检查失败');
9
16
  }
10
17
  }
11
18
  export function log(...args) {
package/utils.d.ts CHANGED
@@ -10,6 +10,8 @@ export declare const not_empty: (value: any) => boolean;
10
10
  export declare const output_width = 230;
11
11
  export declare function set_inspect_options(colors?: boolean): void;
12
12
  export declare function assert(assertion: any, message?: string): never | void;
13
+ /** 做参数校验,逻辑检查 */
14
+ export declare function check(condition: any, message?: string): never | void;
13
15
  /** 通过 console.log 打印对象并返回
14
16
  @example
15
17
  log('label', obj)
package/utils.js CHANGED
@@ -27,7 +27,14 @@ export function set_inspect_options(colors = true) {
27
27
  export function assert(assertion, message) {
28
28
  if (!assertion) {
29
29
  debugger;
30
- throw Object.assign(new Error(`${t('断言失败')}: ${message ? `${message}: ` : ''}${inspect(assertion, { colors: false, compact: true })}`), { assertion });
30
+ throw new Error(`${t('断言失败')}: ${message ? `${message}: ` : ''}`);
31
+ }
32
+ }
33
+ /** 做参数校验,逻辑检查 */
34
+ export function check(condition, message) {
35
+ if (!condition) {
36
+ debugger;
37
+ throw new Error(message || t('检查失败'));
31
38
  }
32
39
  }
33
40
  export function log(...args) {