@maiyunnet/kebab 5.3.0 → 6.0.0

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/lib/sql.js CHANGED
@@ -24,7 +24,7 @@ export class Sql {
24
24
  /** --- 表别名列表 --- */
25
25
  this._alias = [];
26
26
  /** --- PostgreSQL 占位符计数器 --- */
27
- this._placeholder = 1;
27
+ this._placeholderCounter = 1;
28
28
  /** --- where 的 data 的开始处和结束处 --- */
29
29
  this._whereDataPosition = [0, 0];
30
30
  this._pre = pre ?? '';
@@ -43,7 +43,7 @@ export class Sql {
43
43
  */
44
44
  insert(table) {
45
45
  this._data = [];
46
- this._placeholder = 1;
46
+ this._placeholderCounter = 1;
47
47
  this._alias.length = 0;
48
48
  const sql = 'INSERT INTO ' + this.field(table, this._pre);
49
49
  this._sql = [sql];
@@ -71,84 +71,10 @@ export class Sql {
71
71
  for (const v of vs) {
72
72
  sql += '(';
73
73
  for (const v1 of v) {
74
- // --- v1 是项目值,如 {'x': 1, 'y': 2}, 'string', 0 ---
75
- if (v1 === undefined || Number.isNaN(v1)) {
76
- // --- 异常情况 ---
77
- lCore.log({}, '[SQL][values] value error', '-error');
78
- sql += `'', `;
79
- }
80
- else if (v1 === null) {
81
- sql += 'NULL, ';
82
- }
83
- else if (typeof v1 === 'string' || typeof v1 === 'number') {
84
- sql += this.placeholder() + ', ';
85
- this._data.push(v1);
86
- }
87
- else if (Array.isArray(v1)) {
88
- if (v1[0]?.x === undefined && typeof v1[0] === 'string' &&
89
- v1[0].includes('(') && v1[0].includes(')')) {
90
- // --- v1: ['POINT(?)', ['20']] ---
91
- sql += this.field(v1[0].replace(/\?/g, () => this.placeholder())) + ', ';
92
- if (v1[1]) {
93
- this._data.push(...v1[1]);
94
- }
95
- }
96
- else if (v1[0]?.y !== undefined) {
97
- // --- v1: [{'x': 1, 'y': 2}, { ... }, { ... }, ... ]---
98
- if (this._service === ESERVICE.MYSQL) {
99
- // --- MYSQL ---
100
- sql += `ST_POLYGONFROMTEXT(${this.placeholder()}), `;
101
- this._data.push(`POLYGON((${v1.map(item => {
102
- return `${item.x} ${item.y}`;
103
- }).join(', ')}))`);
104
- }
105
- else {
106
- // --- PGSQL ---
107
- sql += `${this.placeholder()}, `;
108
- this._data.push(`(${v1.map(item => {
109
- return `(${item.x}, ${item.y})`;
110
- }).join(', ')})`);
111
- }
112
- }
113
- else {
114
- // --- v1: json ---
115
- sql += this.placeholder() + ', ';
116
- this._data.push(this._service === ESERVICE.MYSQL ? lText.stringifyJson(v1) : v1);
117
- }
118
- }
119
- else if (v1.x !== undefined) {
120
- if (v1.y !== undefined) {
121
- // --- v1: {'x': 1, 'y': 2} ---
122
- if (this._service === ESERVICE.MYSQL) {
123
- // --- MYSQL ---
124
- sql += `ST_POINTFROMTEXT(${this.placeholder()}), `;
125
- this._data.push(`POINT(${v1.x} ${v1.y})`);
126
- }
127
- else {
128
- // --- PGSQL ---
129
- sql += `${this.placeholder()}, `;
130
- this._data.push(`(${v1.x}, ${v1.y})`);
131
- }
132
- }
133
- else {
134
- // --- v1: json ---
135
- sql += this.placeholder() + ', ';
136
- this._data.push(this._service === ESERVICE.MYSQL ? lText.stringifyJson(v1) : v1);
137
- }
138
- }
139
- else if (v1 instanceof Buffer) {
140
- // --- Buffer ---
141
- sql += this.placeholder() + ', ';
142
- this._data.push(v);
143
- }
144
- else if (this._isField(v1)) {
145
- // --- 3 ---
146
- sql += this.field(v1.value) + ', ';
147
- }
148
- else {
149
- // --- json ---
150
- sql += this.placeholder() + ', ';
151
- this._data.push(this._service === ESERVICE.MYSQL ? lText.stringifyJson(v1) : v1);
74
+ const result = this._processValue(v1);
75
+ sql += result.sql + ', ';
76
+ if (result.data !== undefined) {
77
+ this._data.push(...result.data);
152
78
  }
153
79
  }
154
80
  sql = sql.slice(0, -2) + '), ';
@@ -162,88 +88,49 @@ export class Sql {
162
88
  for (const k in cs) {
163
89
  const v = cs[k];
164
90
  sql += this.field(k) + ', ';
165
- if (v === undefined || Number.isNaN(v)) {
166
- // --- 异常情况 ---
167
- lCore.log({}, '[SQL][values] value error', '-error');
168
- values += `'', `;
169
- }
170
- else if (v === null) {
171
- values += 'NULL, ';
91
+ // --- 使用 _processValue 处理普通值 ---
92
+ const result = this._processValue(v);
93
+ values += result.sql + ', ';
94
+ if (result.data !== undefined) {
95
+ this._data.push(...result.data);
172
96
  }
173
- else if (typeof v === 'string' || typeof v === 'number') {
174
- values += this.placeholder() + ', ';
175
- this._data.push(v);
176
- }
177
- else if (Array.isArray(v)) {
178
- if (v[0]?.x === undefined && typeof v[0] === 'string' &&
179
- v[0].includes('(') && v[0].includes(')')) {
180
- // --- v: ['POINT(?)', ['20']] ---
181
- values += this.field(v[0].replace(/\?/g, () => this.placeholder())) + ', ';
182
- if (v[1] !== undefined) {
183
- this._data.push(...v[1]);
184
- }
185
- }
186
- else if (v[0]?.y !== undefined) {
187
- // --- v: [{'x': 1, 'y': 2}, { ... }, { ... }, ... ]---
188
- if (this._service === ESERVICE.MYSQL) {
189
- // --- MYSQL ---
190
- values += `ST_POLYGONFROMTEXT(${this.placeholder()}), `;
191
- this._data.push(`POLYGON((${v.map(item => {
192
- return `${item.x} ${item.y}`;
193
- }).join(', ')}))`);
194
- }
195
- else {
196
- // --- PGSQL ---
197
- values += `${this.placeholder()}, `;
198
- this._data.push(`(${v.map(item => {
199
- return `(${item.x}, ${item.y})`;
200
- }).join(', ')})`);
201
- }
202
- }
203
- else {
204
- // --- v: json ---
205
- values += this.placeholder() + ', ';
206
- this._data.push(this._service === ESERVICE.MYSQL ? lText.stringifyJson(v) : v);
207
- }
208
- }
209
- else if (v.x !== undefined) {
210
- if (v.y !== undefined) {
211
- // --- v: {'x': 1, 'y': 2} ---
212
- if (this._service === ESERVICE.MYSQL) {
213
- // --- MYSQL ---
214
- values += `ST_POINTFROMTEXT(${this.placeholder()}), `;
215
- this._data.push(`POINT(${v.x} ${v.y})`);
216
- }
217
- else {
218
- // --- PGSQL ---
219
- values += `${this.placeholder()}, `;
220
- this._data.push(`(${v.x}, ${v.y})`);
221
- }
222
- }
223
- else {
224
- // --- v: json ---
225
- values += this.placeholder() + ', ';
226
- this._data.push(this._service === ESERVICE.MYSQL ? lText.stringifyJson(v) : v);
227
- }
228
- }
229
- else if (v instanceof Buffer) {
230
- // --- Buffer ---
231
- values += this.placeholder() + ', ';
232
- this._data.push(v);
233
- }
234
- else if (this._isField(v)) {
235
- // --- 3 ---
236
- values += this.field(v.value) + ', ';
97
+ }
98
+ sql = sql.slice(0, -2) + ') VALUES (' + values.slice(0, -2) + ')';
99
+ }
100
+ this._sql.push(sql);
101
+ return this;
102
+ }
103
+ /**
104
+ * --- 如果存在则更新不存在则插入(UPSERT)---
105
+ * @param data 更新的数据
106
+ * @param conflict 冲突字段,PostgreSQL 用于指定 ON CONFLICT 字段;MySQL 时忽略,因为会对所有唯一键冲突执行更新
107
+ */
108
+ upsert(data, conflict) {
109
+ if (this._service === ESERVICE.MYSQL) {
110
+ // --- MySQL: 使用 ON DUPLICATE KEY UPDATE ---
111
+ // --- 注意:MySQL 会对任何唯一键冲突都执行更新,无法像 PostgreSQL 那样指定具体冲突字段 ---
112
+ // --- 如果需要精确控制冲突字段,建议在应用层先查询再决定插入或更新 ---
113
+ this._sql.push(' ON DUPLICATE KEY UPDATE ' + this._updateSub(data));
114
+ }
115
+ else {
116
+ // --- PostgreSQL: 使用 ON CONFLICT ---
117
+ let clause = ' ON CONFLICT ';
118
+ if (conflict) {
119
+ // --- 指定冲突字段 ---
120
+ if (typeof conflict === 'string') {
121
+ clause += '(' + this.field(conflict) + ') ';
237
122
  }
238
123
  else {
239
- // --- json ---
240
- values += this.placeholder() + ', ';
241
- this._data.push(this._service === ESERVICE.MYSQL ? lText.stringifyJson(v) : v);
124
+ clause += '(';
125
+ for (const f of conflict) {
126
+ clause += this.field(f) + ', ';
127
+ }
128
+ clause = clause.slice(0, -2) + ') ';
242
129
  }
243
130
  }
244
- sql = sql.slice(0, -2) + ') VALUES (' + values.slice(0, -2) + ')';
131
+ // --- DO UPDATE SET ---
132
+ this._sql.push(clause + 'DO UPDATE SET ' + this._updateSub(data));
245
133
  }
246
- this._sql.push(sql);
247
134
  return this;
248
135
  }
249
136
  /**
@@ -253,7 +140,7 @@ export class Sql {
253
140
  */
254
141
  select(c, f) {
255
142
  this._data = [];
256
- this._placeholder = 1;
143
+ this._placeholderCounter = 1;
257
144
  let sql = 'SELECT ';
258
145
  if (typeof c === 'string') {
259
146
  sql += this.field(c);
@@ -263,7 +150,7 @@ export class Sql {
263
150
  for (const i of c) {
264
151
  if (Array.isArray(i)) {
265
152
  // --- i: ['xx', ['x']] ---
266
- sql += this.field(i[0].replace(/\?/g, () => this.placeholder())) + ', ';
153
+ sql += this.field(i[0].replace(/\?/g, () => this._placeholder())) + ', ';
267
154
  this._data.push(...i[1]);
268
155
  }
269
156
  else {
@@ -293,7 +180,7 @@ export class Sql {
293
180
  */
294
181
  update(f, s) {
295
182
  this._data = [];
296
- this._placeholder = 1;
183
+ this._placeholderCounter = 1;
297
184
  const sql = `UPDATE ${this.field(f, this._pre)} SET ${this._updateSub(s)}`;
298
185
  this._sql = [sql];
299
186
  return this;
@@ -332,10 +219,10 @@ export class Sql {
332
219
  }
333
220
  else {
334
221
  if (v[1] === '=') {
335
- sql += this.field(v[0]) + ' = ' + this.placeholder() + ', ';
222
+ sql += this.field(v[0]) + ' = ' + this._placeholder() + ', ';
336
223
  }
337
224
  else {
338
- sql += this.field(v[0]) + ' = ' + this.field(v[0]) + ' ' + v[1] + ' ' + this.placeholder() + ', ';
225
+ sql += this.field(v[0]) + ' = ' + this.field(v[0]) + ' ' + v[1] + ' ' + this._placeholder() + ', ';
339
226
  }
340
227
  this._data.push(nv);
341
228
  }
@@ -343,91 +230,10 @@ export class Sql {
343
230
  else {
344
231
  // --- 2, 3, 4, 5, 6, 7, 8 ---
345
232
  sql += this.field(k) + ' = ';
346
- if (v === undefined || Number.isNaN(v)) {
347
- // --- 异常情况 ---
348
- lCore.log({}, '[SQL][_updateSub] value error, key: ' + k, '-error');
349
- sql += '"", ';
350
- }
351
- else if (v === null) {
352
- sql += 'NULL, ';
353
- }
354
- else if (typeof v === 'string' || typeof v === 'number') {
355
- // --- 2 ---
356
- sql += this.placeholder() + ', ';
357
- this._data.push(v);
358
- }
359
- else if (Array.isArray(v)) {
360
- if (v[0]?.x === undefined && typeof v[0] === 'string' &&
361
- v[0].includes('(') && v[0].includes(')')) {
362
- // --- 4, 5: ['(CASE `id` WHEN 1 THEN ? WHEN 2 THEN ? END)', ['val1', 'val2']] ---
363
- sql += this.field(v[0]) + ', ';
364
- if (v[1] !== undefined) {
365
- this._data.push(...v[1]);
366
- }
367
- }
368
- else if (v[0]?.y !== undefined) {
369
- // --- 7 ---
370
- if (this._service === ESERVICE.MYSQL) {
371
- // --- MYSQL ---
372
- sql += `ST_POLYGONFROMTEXT(${this.placeholder()}), `;
373
- this._data.push(`POLYGON((${v.map(item => {
374
- return `${item.x} ${item.y}`;
375
- }).join(', ')}))`);
376
- }
377
- else {
378
- // --- PGSQL ---
379
- sql += `${this.placeholder()}, `;
380
- this._data.push(`(${v.map(item => {
381
- return `(${item.x}, ${item.y})`;
382
- }).join(', ')})`);
383
- }
384
- }
385
- else {
386
- // --- v: json ---
387
- sql += this.placeholder() + ', ';
388
- this._data.push(this._service === ESERVICE.MYSQL ? lText.stringifyJson(v) : v);
389
- }
390
- }
391
- else if (v.x !== undefined) {
392
- if (v.y !== undefined) {
393
- // --- 6: v: {'x': 1, 'y': 2} ---
394
- if (this._service === ESERVICE.MYSQL) {
395
- // --- MYSQL ---
396
- sql += `ST_POINTFROMTEXT(${this.placeholder()}), `;
397
- this._data.push(`POINT(${v.x} ${v.y})`);
398
- }
399
- else {
400
- // --- PGSQL ---
401
- sql += `${this.placeholder()}, `;
402
- this._data.push(`(${v.x}, ${v.y})`);
403
- }
404
- }
405
- else {
406
- // --- v: json ---
407
- if (this._isField(v)) {
408
- // --- 3 ---
409
- sql += this.field(v.value) + ', ';
410
- }
411
- else {
412
- // --- 8 ---
413
- sql += this.placeholder() + ', ';
414
- this._data.push(this._service === ESERVICE.MYSQL ? lText.stringifyJson(v) : v);
415
- }
416
- }
417
- }
418
- else if (v instanceof Buffer) {
419
- // --- Buffer ---
420
- sql += this.placeholder() + ', ';
421
- this._data.push(v);
422
- }
423
- else if (this._isField(v)) {
424
- // --- 3 ---
425
- sql += this.field(v.value) + ', ';
426
- }
427
- else {
428
- // --- json ---
429
- sql += this.placeholder() + ', ';
430
- this._data.push(this._service === ESERVICE.MYSQL ? lText.stringifyJson(v) : v);
233
+ const result = this._processValue(v);
234
+ sql += result.sql + ', ';
235
+ if (result.data !== undefined) {
236
+ this._data.push(...result.data);
431
237
  }
432
238
  }
433
239
  }
@@ -440,13 +246,13 @@ export class Sql {
440
246
  */
441
247
  delete(f) {
442
248
  this._data = [];
443
- this._placeholder = 1;
249
+ this._placeholderCounter = 1;
444
250
  this._sql = ['DELETE FROM ' + this.field(f, this._pre)];
445
251
  return this;
446
252
  }
447
253
  /**
448
254
  * --- 联查另一个 sql 对象 ---
449
- * @param sql sql 对象
255
+ * @param lsql sql 对象
450
256
  * @param type 类型
451
257
  */
452
258
  union(lsql, type = '') {
@@ -457,7 +263,7 @@ export class Sql {
457
263
  }
458
264
  /**
459
265
  * --- 所有联查另一个 sql 对象 ---
460
- * @param sql sql 对象
266
+ * @param lsql sql 对象
461
267
  */
462
268
  unionAll(lsql) {
463
269
  return this.union(lsql, 'ALL');
@@ -635,7 +441,7 @@ export class Sql {
635
441
  // --- 3 ---
636
442
  sql += this.field(v[0]) + ' ' + v[1].toUpperCase() + ' (';
637
443
  for (const v1 of v[2]) {
638
- sql += this.placeholder() + ', ';
444
+ sql += this._placeholder() + ', ';
639
445
  data.push(v1);
640
446
  }
641
447
  sql = sql.slice(0, -2) + ') AND ';
@@ -649,7 +455,7 @@ export class Sql {
649
455
  sql += this.field(v[0]) + ' ' + v[1] + ' ' + this.field(nv.value) + ' AND ';
650
456
  }
651
457
  else {
652
- sql += this.field(v[0]) + ' ' + v[1] + ' ' + this.placeholder() + ' AND ';
458
+ sql += this.field(v[0]) + ' ' + v[1] + ' ' + this._placeholder() + ' AND ';
653
459
  data.push(nv);
654
460
  }
655
461
  }
@@ -679,7 +485,7 @@ export class Sql {
679
485
  }
680
486
  else if (typeof v === 'string' || typeof v === 'number') {
681
487
  // --- 1 ---
682
- sql += this.field(k) + ' = ' + this.placeholder() + ' AND ';
488
+ sql += this.field(k) + ' = ' + this._placeholder() + ' AND ';
683
489
  data.push(v);
684
490
  }
685
491
  else if (this._isField(v)) {
@@ -691,7 +497,7 @@ export class Sql {
691
497
  if (v.length > 0) {
692
498
  sql += this.field(k) + ' IN (';
693
499
  for (const v1 of v) {
694
- sql += this.placeholder() + ', ';
500
+ sql += this._placeholder() + ', ';
695
501
  data.push(v1);
696
502
  }
697
503
  sql = sql.slice(0, -2) + ') AND ';
@@ -890,10 +696,6 @@ export class Sql {
890
696
  this._sql.push(sql);
891
697
  return this;
892
698
  }
893
- /** --- 获取占位符 --- */
894
- placeholder() {
895
- return this._service === ESERVICE.MYSQL ? '?' : `$${this._placeholder++}`;
896
- }
897
699
  /**
898
700
  * --- 对字段进行包裹 ---
899
701
  * @param str
@@ -1053,6 +855,123 @@ export class Sql {
1053
855
  }
1054
856
  return true;
1055
857
  }
858
+ /** --- 获取占位符 --- */
859
+ _placeholder() {
860
+ return this._service === ESERVICE.MYSQL ? '?' : `$${this._placeholderCounter++}`;
861
+ }
862
+ /**
863
+ * --- 处理单个值,检测数据类型并返回 SQL 和 data ---
864
+ * @param v 要处理的值
865
+ */
866
+ _processValue(v) {
867
+ if (v === undefined || Number.isNaN(v)) {
868
+ // --- 异常情况 ---
869
+ lCore.log({}, '[SQL][_processValue] value error', '-error');
870
+ return { 'sql': "''", 'data': [] };
871
+ }
872
+ else if (v === null) {
873
+ return { 'sql': 'NULL', 'data': [] };
874
+ }
875
+ else if (typeof v === 'string' || typeof v === 'number') {
876
+ return { 'sql': this._placeholder(), 'data': [v] };
877
+ }
878
+ else if (Array.isArray(v)) {
879
+ if (v[0]?.x === undefined && typeof v[0] === 'string' &&
880
+ v[0].includes('(') && v[0].includes(')')) {
881
+ // --- 函数式插入,对参数按位置分别处理 ---
882
+ // --- v: ['POINT(?)', ['20']] ---
883
+ // --- v: ['(CASE `id` WHEN 1 THEN ? WHEN 2 THEN ? END)', ['val1', 'val2']] ---
884
+ /** --- 函数 SQL 字符串 --- */
885
+ const sql = v[0];
886
+ /** --- 函数参数数组 --- */
887
+ const ps = v[1] ?? [];
888
+ /** --- 所有处理后的 SQL 片段 --- */
889
+ const sqls = [];
890
+ /** --- 所有处理后的数据 --- */
891
+ const ds = [];
892
+ for (const p of ps) {
893
+ const res = this._processValue(p);
894
+ sqls.push(res.sql);
895
+ ds.push(...res.data);
896
+ }
897
+ let i = 0;
898
+ const replacedSql = sql.replace(/\?/g, () => sqls[i++]);
899
+ return {
900
+ 'sql': this.field(replacedSql),
901
+ 'data': ds
902
+ };
903
+ }
904
+ else if (v[0]?.y !== undefined) {
905
+ // --- v: [{'x': 1, 'y': 2}, { ... }, { ... }, ... ]---
906
+ if (this._service === ESERVICE.MYSQL) {
907
+ // --- MYSQL ---
908
+ return {
909
+ 'sql': `ST_POLYGONFROMTEXT(${this._placeholder()})`,
910
+ 'data': [`POLYGON((${v.map(item => {
911
+ return `${item.x} ${item.y}`;
912
+ }).join(', ')}))`]
913
+ };
914
+ }
915
+ else {
916
+ // --- PGSQL ---
917
+ return {
918
+ 'sql': this._placeholder(),
919
+ 'data': [`(${v.map(item => {
920
+ return `(${item.x}, ${item.y})`;
921
+ }).join(', ')})`]
922
+ };
923
+ }
924
+ }
925
+ else {
926
+ // --- v: json ---
927
+ return {
928
+ 'sql': this._placeholder(),
929
+ 'data': [this._service === ESERVICE.MYSQL ? lText.stringifyJson(v) : v]
930
+ };
931
+ }
932
+ }
933
+ else if (v.x !== undefined) {
934
+ if (v.y !== undefined) {
935
+ // --- v: {'x': 1, 'y': 2} ---
936
+ if (this._service === ESERVICE.MYSQL) {
937
+ // --- MYSQL ---
938
+ return {
939
+ 'sql': `ST_POINTFROMTEXT(${this._placeholder()})`,
940
+ 'data': [`POINT(${v.x} ${v.y})`]
941
+ };
942
+ }
943
+ else {
944
+ // --- PGSQL ---
945
+ return {
946
+ 'sql': this._placeholder(),
947
+ 'data': [`(${v.x}, ${v.y})`]
948
+ };
949
+ }
950
+ }
951
+ else {
952
+ // --- v: json ---
953
+ return {
954
+ 'sql': this._placeholder(),
955
+ 'data': [this._service === ESERVICE.MYSQL ? lText.stringifyJson(v) : v]
956
+ };
957
+ }
958
+ }
959
+ else if (v instanceof Buffer) {
960
+ // --- Buffer ---
961
+ return { 'sql': this._placeholder(), 'data': [v] };
962
+ }
963
+ else if (this._isField(v)) {
964
+ // --- field ---
965
+ return { 'sql': this.field(v.value), 'data': [] };
966
+ }
967
+ else {
968
+ // --- json ---
969
+ return {
970
+ 'sql': this._placeholder(),
971
+ 'data': [this._service === ESERVICE.MYSQL ? lText.stringifyJson(v) : v]
972
+ };
973
+ }
974
+ }
1056
975
  }
1057
976
  /**
1058
977
  * --- 创建 sql 对象 ---
package/lib/ssh.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  import * as ssh2 from 'ssh2';
7
7
  import * as shell from './ssh/shell.js';
8
8
  import * as sftp from './ssh/sftp.js';
9
- interface IExtOptions {
9
+ export interface IExtOptions {
10
10
  'mproxy'?: {
11
11
  'host': string;
12
12
  'port': number;
@@ -53,4 +53,3 @@ export declare class Connection {
53
53
  * @param opt 选项
54
54
  */
55
55
  export declare function get(opt: ssh2.ConnectConfig & IExtOptions): Promise<Connection | null>;
56
- export {};
package/lib/text.d.ts CHANGED
@@ -47,7 +47,7 @@ export declare function isIPv6(ip: string): boolean;
47
47
  export declare const REGEXP_DOMAIN: RegExp;
48
48
  /**
49
49
  * --- 判断是否是域名 ---
50
- * @param string $domain
50
+ * @param domain 域名
51
51
  * @return bool
52
52
  */
53
53
  export declare function isDomain(domain: string): boolean;
@@ -120,7 +120,7 @@ export declare function isRealPath(path: string): boolean;
120
120
  export declare function getFilename(path: string): string;
121
121
  /**
122
122
  * --- 将普通的返回 JSON 对象序列化为字符串 ---
123
- * @param o 返回 JSON 对象
123
+ * @param rtn 返回 JSON 对象
124
124
  */
125
125
  export declare function stringifyResult(rtn: kebab.Json): string;
126
126
  /**
@@ -143,7 +143,8 @@ export declare function stringifyBuffer(buf: Buffer): string;
143
143
  * --- 递归删除 json 中的字符串首尾空格,会返回一个新的对象 ---
144
144
  */
145
145
  export declare function trimJson(json: kebab.Json): kebab.Json;
146
- type TFalsy = false | '' | 0 | null | undefined | typeof NaN;
146
+ /** --- 虚假值类型 --- */
147
+ export type TFalsy = false | '' | 0 | null | undefined | typeof NaN;
147
148
  /**
148
149
  * --- 判断一个值是否是虚假的(为 null/undefined/空字符串/false/0) ---
149
150
  * @param val 要判断的值
@@ -183,4 +184,3 @@ export declare function str2int(str: string, digits?: number): number;
183
184
  * @param decimal 最终保留的小数位数
184
185
  */
185
186
  export declare function int2str(int: number, digits?: number, decimal?: number): string;
186
- export {};
package/lib/text.js CHANGED
@@ -205,7 +205,7 @@ export function isIPv6(ip) {
205
205
  export const REGEXP_DOMAIN = /^.+?\.((?![0-9]).)+$/i;
206
206
  /**
207
207
  * --- 判断是否是域名 ---
208
- * @param string $domain
208
+ * @param domain 域名
209
209
  * @return bool
210
210
  */
211
211
  export function isDomain(domain) {
@@ -432,7 +432,7 @@ export function getFilename(path) {
432
432
  }
433
433
  /**
434
434
  * --- 将普通的返回 JSON 对象序列化为字符串 ---
435
- * @param o 返回 JSON 对象
435
+ * @param rtn 返回 JSON 对象
436
436
  */
437
437
  export function stringifyResult(rtn) {
438
438
  if (Array.isArray(rtn)) {
package/lib/vector.d.ts CHANGED
@@ -66,6 +66,6 @@ export declare class Vector {
66
66
  }
67
67
  /**
68
68
  * --- 创建一个 Vector 对象 ---
69
- * @param opt 选项
69
+ * @param ctrEtc 控制器或配置信息
70
70
  */
71
71
  export declare function get(ctrEtc: sCtr.Ctr | kebab.IConfigVector): Vector;