xshell 1.0.192 → 1.0.193

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.192",
3
+ "version": "1.0.193",
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.26.0",
53
- "@babel/parser": "^7.26.1",
53
+ "@babel/parser": "^7.26.2",
54
54
  "@babel/traverse": "^7.25.9",
55
55
  "@koa/cors": "^5.0.0",
56
- "@stylistic/eslint-plugin": "^2.9.0",
56
+ "@stylistic/eslint-plugin": "^2.10.0",
57
57
  "@svgr/webpack": "^8.1.0",
58
58
  "@types/sass-loader": "^8.0.9",
59
59
  "@types/ws": "^8.5.12",
@@ -126,7 +126,7 @@
126
126
  "@types/koa-compress": "^4.0.6",
127
127
  "@types/lodash": "^4.17.13",
128
128
  "@types/mime-types": "^2.1.4",
129
- "@types/node": "^22.8.4",
129
+ "@types/node": "^22.8.5",
130
130
  "@types/react": "^18.3.12",
131
131
  "@types/through2": "^2.0.41",
132
132
  "@types/tough-cookie": "^4.0.5",
@@ -76,6 +76,10 @@ declare global {
76
76
  indent: number;
77
77
  text: string;
78
78
  };
79
+ /** 将 string 根据首个找到的 splitter 拆分 string 为两个部分(必须包含 splitter,否则抛出错误)
80
+ - spitter: 不会包含在结果中
81
+ - last?: `false` 为 true 时从后往前找 splitter */
82
+ split2(this: string, splitter: string, last?: boolean): [string, string];
79
83
  space(this: string): string;
80
84
  /** 返回去掉 prefix 开头的字符串
81
85
  - validate?: `false` 传 true 时确保字符串以 prefix 开头(失败时抛出错误) */
@@ -259,6 +259,12 @@ Object.defineProperties(String.prototype, {
259
259
  text: this.slice(i)
260
260
  };
261
261
  },
262
+ split2(splitter, last = false) {
263
+ const isplitter = last ? this.lastIndexOf(splitter) : this.indexOf(splitter);
264
+ if (isplitter === -1)
265
+ throw new Error(`字符串: ${this} 必须包含 splitter: ${splitter}`);
266
+ return [this.slice(0, isplitter), this.slice(isplitter + splitter.length)];
267
+ },
262
268
  strip_start(prefix, validate) {
263
269
  if (validate && !this.startsWith(prefix))
264
270
  throw new Error(`字符串没有以前缀 ${prefix} 开头: ${this}`);
package/prototype.d.ts CHANGED
@@ -93,6 +93,10 @@ declare global {
93
93
  indent: number;
94
94
  text: string;
95
95
  };
96
+ /** 将 string 根据首个找到的 splitter 拆分 string 为两个部分(必须包含 splitter,否则抛出错误)
97
+ - spitter: 不会包含在结果中
98
+ - last?: `false` 为 true 时从后往前找 splitter */
99
+ split2(this: string, splitter: string, last?: boolean): [string, string];
96
100
  to_base64(this: string): string;
97
101
  /** - buffer: `false` 直接返回 Buffer */
98
102
  decode_base64(this: string): string;
package/prototype.js CHANGED
@@ -263,6 +263,12 @@ if (!globalThis.my_prototype_defined) {
263
263
  text: this.slice(i)
264
264
  };
265
265
  },
266
+ split2(splitter, last = false) {
267
+ const isplitter = last ? this.lastIndexOf(splitter) : this.indexOf(splitter);
268
+ if (isplitter === -1)
269
+ throw new Error(`字符串: ${this} 必须包含 splitter: ${splitter}`);
270
+ return [this.slice(0, isplitter), this.slice(isplitter + splitter.length)];
271
+ },
266
272
  trim_doc_comment() {
267
273
  return `/** ${this.slice(3, -2).replace(/\s*\*\s*/g, ' ').replace(/@(param|params|return) \{.*?\}\s*/g, '').trim()} */`;
268
274
  },