xshell 1.0.164 → 1.0.166

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.164",
3
+ "version": "1.0.166",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -50,10 +50,10 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@babel/core": "^7.25.2",
53
- "@babel/parser": "^7.25.4",
54
- "@babel/traverse": "^7.25.4",
53
+ "@babel/parser": "^7.25.6",
54
+ "@babel/traverse": "^7.25.6",
55
55
  "@koa/cors": "^5.0.0",
56
- "@stylistic/eslint-plugin": "^2.6.4",
56
+ "@stylistic/eslint-plugin": "^2.7.2",
57
57
  "@svgr/webpack": "^8.1.0",
58
58
  "@types/sass-loader": "^8.0.9",
59
59
  "@types/ws": "^8.5.12",
@@ -113,7 +113,7 @@
113
113
  "ws": "^8.18.0"
114
114
  },
115
115
  "devDependencies": {
116
- "@babel/types": "^7.25.4",
116
+ "@babel/types": "^7.25.6",
117
117
  "@types/ali-oss": "^6.16.11",
118
118
  "@types/archiver": "^6.0.2",
119
119
  "@types/babel__traverse": "^7.20.6",
@@ -126,8 +126,8 @@
126
126
  "@types/koa-compress": "^4.0.6",
127
127
  "@types/lodash": "^4.17.7",
128
128
  "@types/mime-types": "^2.1.4",
129
- "@types/node": "^22.5.0",
130
- "@types/react": "^18.3.4",
129
+ "@types/node": "^22.5.2",
130
+ "@types/react": "^18.3.5",
131
131
  "@types/through2": "^2.0.41",
132
132
  "@types/tough-cookie": "^4.0.5",
133
133
  "@types/ua-parser-js": "^0.7.39",
package/path.d.ts CHANGED
@@ -55,7 +55,7 @@ export declare function extname(path: string): string;
55
55
  /** `/` */
56
56
  export declare const sep = "/";
57
57
  /** The platform-specific file delimiter. ';' or ':'. */
58
- export declare const delimiter: ";" | ":";
58
+ export declare const delimiter: ":" | ";";
59
59
  /** Returns an object from a path string - the opposite of format().
60
60
  @param path path to evaluate.
61
61
  @throws {TypeError} if `path` is not a string. */
@@ -83,7 +83,7 @@ export declare let path: {
83
83
  basename: typeof basename;
84
84
  extname: typeof extname;
85
85
  sep: string;
86
- delimiter: ";" | ":";
86
+ delimiter: ":" | ";";
87
87
  parse: typeof parse;
88
88
  format: typeof format;
89
89
  toNamespacedPath: typeof toNamespacedPath;
@@ -11,6 +11,8 @@ export declare function unique<TObj>(iterable: TObj[] | Iterable<TObj>, selector
11
11
  export declare function seq<T = number>(n: number, generator?: (index: number) => T): T[];
12
12
  /** 将 keys, values 数组按对应的顺序组合成一个对象 */
13
13
  export declare function zip_object<TValue>(keys: (string | number)[], values: TValue[]): Record<string, TValue>;
14
+ /** 过滤对象中的 values, 返回新对象 */
15
+ export declare function filter_values<TObj extends Record<string, any>>(obj: TObj, filter?: (value: TObj[string]) => any): TObj;
14
16
  export declare function delay(milliseconds: number, { signal }?: {
15
17
  signal?: AbortSignal;
16
18
  }): Promise<void>;
@@ -68,7 +70,7 @@ export declare function encode(str: string): Uint8Array;
68
70
  在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
69
71
  export declare function decode(buffer: Uint8Array): string;
70
72
  /** 字符串字典序比较 */
71
- export declare function strcmp(l: string, r: string): 1 | 0 | -1;
73
+ export declare function strcmp(l: string, r: string): 0 | 1 | -1;
72
74
  /** 比较 1.10.02 这种版本号
73
75
  - l, r: 两个版本号字符串
74
76
  - loose?: 宽松模式,允许两个版本号格式(位数)不一致 */
@@ -90,7 +92,13 @@ export declare class Timer {
90
92
  /** 如果秒表未停止,获取当前秒表读数;
91
93
  如果秒表已停止,获取停止时的秒表读数; */
92
94
  get(): number;
93
- getstr(): string;
95
+ /** 获取时间表示字符串,如 1.2 s
96
+ - parenthesis?: `true` 字符串前后加上括号,如 (1.2 s) */
97
+ getstr(parenthesis?: boolean): string;
94
98
  print(): void;
99
+ /** 重置 started */
100
+ reset(): void;
101
+ get_and_reset(): number;
102
+ getstr_and_reset(parenthesis?: boolean): string;
95
103
  }
96
104
  export declare function lowercase_first_letter(str: string): string;
package/utils.browser.js CHANGED
@@ -38,6 +38,11 @@ export function zip_object(keys, values) {
38
38
  return obj;
39
39
  }, {});
40
40
  }
41
+ /** 过滤对象中的 values, 返回新对象 */
42
+ export function filter_values(obj, filter = not_empty) {
43
+ return Object.fromEntries(Object.entries(obj)
44
+ .filter(([, value]) => filter(value)));
45
+ }
41
46
  export async function delay(milliseconds, { signal } = {}) {
42
47
  signal?.throwIfAborted();
43
48
  return new Promise((resolve, reject) => {
@@ -265,11 +270,32 @@ export class Timer {
265
270
  get() {
266
271
  return (this.ended || new Date().getTime()) - this.started;
267
272
  }
268
- getstr() {
269
- return `(${delta2str(this.get())})`;
273
+ /** 获取时间表示字符串,如 1.2 s
274
+ - parenthesis?: `true` 字符串前后加上括号,如 (1.2 s) */
275
+ getstr(parenthesis = false) {
276
+ let s = delta2str(this.get());
277
+ if (parenthesis)
278
+ return s.bracket();
279
+ else
280
+ return s;
270
281
  }
271
282
  print() {
272
- console.log(this.getstr());
283
+ console.log(this.getstr(true));
284
+ }
285
+ /** 重置 started */
286
+ reset() {
287
+ this.started = new Date().getTime();
288
+ this.ended = null;
289
+ }
290
+ get_and_reset() {
291
+ const result = this.get();
292
+ this.reset();
293
+ return result;
294
+ }
295
+ getstr_and_reset(parenthesis) {
296
+ const result = this.getstr(parenthesis);
297
+ this.reset();
298
+ return result;
273
299
  }
274
300
  }
275
301
  export function lowercase_first_letter(str) {
package/utils.d.ts CHANGED
@@ -37,7 +37,7 @@ export declare function filter_values<TObj extends Record<string, any>>(obj: TOb
37
37
  /** 忽略对象中的 keys, 返回新对象 */
38
38
  export declare function omit<TObj>(obj: TObj, omit_keys: string[]): TObj;
39
39
  /** 字符串字典序比较 */
40
- export declare function strcmp(l: string, r: string): 1 | 0 | -1;
40
+ export declare function strcmp(l: string, r: string): 0 | 1 | -1;
41
41
  /** 比较 1.10.02 这种版本号
42
42
  - l, r: 两个版本号字符串
43
43
  - loose?: 宽松模式,允许两个版本号格式(位数)不一致 */
@@ -61,9 +61,13 @@ export declare class Timer {
61
61
  如果秒表已停止,获取停止时的秒表读数; */
62
62
  get(): number;
63
63
  /** 获取时间表示字符串,如 1.2 s
64
- - bracket?: `true` 字符串前后加上括号,如 (1.2 s) */
65
- getstr(bracket?: boolean): string;
64
+ - parenthesis?: `true` 字符串前后加上括号,如 (1.2 s) */
65
+ getstr(parenthesis?: boolean): string;
66
66
  print(): void;
67
+ /** 重置 started */
68
+ reset(): void;
69
+ get_and_reset(): number;
70
+ getstr_and_reset(parenthesis?: boolean): string;
67
71
  }
68
72
  export declare function log_line(): void;
69
73
  export declare function delay(milliseconds: number, options?: TimerOptions): Promise<void>;
package/utils.js CHANGED
@@ -189,10 +189,10 @@ export class Timer {
189
189
  return (this.ended || new Date().getTime()) - this.started;
190
190
  }
191
191
  /** 获取时间表示字符串,如 1.2 s
192
- - bracket?: `true` 字符串前后加上括号,如 (1.2 s) */
193
- getstr(bracket = false) {
192
+ - parenthesis?: `true` 字符串前后加上括号,如 (1.2 s) */
193
+ getstr(parenthesis = false) {
194
194
  let s = delta2str(this.get());
195
- if (bracket)
195
+ if (parenthesis)
196
196
  return s.bracket();
197
197
  else
198
198
  return s;
@@ -200,6 +200,21 @@ export class Timer {
200
200
  print() {
201
201
  console.log(this.getstr(true));
202
202
  }
203
+ /** 重置 started */
204
+ reset() {
205
+ this.started = new Date().getTime();
206
+ this.ended = null;
207
+ }
208
+ get_and_reset() {
209
+ const result = this.get();
210
+ this.reset();
211
+ return result;
212
+ }
213
+ getstr_and_reset(parenthesis) {
214
+ const result = this.getstr(parenthesis);
215
+ this.reset();
216
+ return result;
217
+ }
203
218
  }
204
219
  export function log_line() {
205
220
  console.log('---');