assistsx-js 0.0.2011 → 0.0.2013
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/dist/Step.d.ts +20 -1
- package/dist/Step.js +46 -1
- package/package.json +1 -1
- package/src/Step.ts +52 -2
package/dist/Step.d.ts
CHANGED
|
@@ -55,8 +55,27 @@ export declare class Step {
|
|
|
55
55
|
/**
|
|
56
56
|
* 移除步骤拦截器
|
|
57
57
|
* @param interceptor 要移除的拦截器函数
|
|
58
|
+
* @returns 是否成功删除
|
|
58
59
|
*/
|
|
59
|
-
static removeInterceptor(interceptor: StepInterceptor):
|
|
60
|
+
static removeInterceptor(interceptor: StepInterceptor): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 按索引移除步骤拦截器
|
|
63
|
+
* @param index 要移除的拦截器索引
|
|
64
|
+
* @returns 是否成功删除
|
|
65
|
+
*/
|
|
66
|
+
static removeInterceptorByIndex(index: number): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* 移除所有匹配的步骤拦截器
|
|
69
|
+
* @param interceptor 要移除的拦截器函数
|
|
70
|
+
* @returns 删除的拦截器数量
|
|
71
|
+
*/
|
|
72
|
+
static removeAllInterceptors(interceptor: StepInterceptor): number;
|
|
73
|
+
/**
|
|
74
|
+
* 按条件移除步骤拦截器
|
|
75
|
+
* @param predicate 判断是否删除的条件函数
|
|
76
|
+
* @returns 删除的拦截器数量
|
|
77
|
+
*/
|
|
78
|
+
static removeInterceptorByPredicate(predicate: (interceptor: StepInterceptor, index: number) => boolean): number;
|
|
60
79
|
/**
|
|
61
80
|
* 清空所有拦截器
|
|
62
81
|
*/
|
package/dist/Step.js
CHANGED
|
@@ -50,7 +50,7 @@ export class Step {
|
|
|
50
50
|
for (const interceptor of this._interceptors) {
|
|
51
51
|
try {
|
|
52
52
|
const result = await interceptor(currentStep);
|
|
53
|
-
if (result
|
|
53
|
+
if (result) {
|
|
54
54
|
interceptedStep = result;
|
|
55
55
|
if (Step.showLog) {
|
|
56
56
|
console.log(`步骤${implnName}被拦截器拦截,执行拦截后的步骤`);
|
|
@@ -165,12 +165,57 @@ export class Step {
|
|
|
165
165
|
/**
|
|
166
166
|
* 移除步骤拦截器
|
|
167
167
|
* @param interceptor 要移除的拦截器函数
|
|
168
|
+
* @returns 是否成功删除
|
|
168
169
|
*/
|
|
169
170
|
static removeInterceptor(interceptor) {
|
|
170
171
|
const index = this._interceptors.indexOf(interceptor);
|
|
171
172
|
if (index > -1) {
|
|
172
173
|
this._interceptors.splice(index, 1);
|
|
174
|
+
return true;
|
|
173
175
|
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* 按索引移除步骤拦截器
|
|
180
|
+
* @param index 要移除的拦截器索引
|
|
181
|
+
* @returns 是否成功删除
|
|
182
|
+
*/
|
|
183
|
+
static removeInterceptorByIndex(index) {
|
|
184
|
+
if (index >= 0 && index < this._interceptors.length) {
|
|
185
|
+
this._interceptors.splice(index, 1);
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* 移除所有匹配的步骤拦截器
|
|
192
|
+
* @param interceptor 要移除的拦截器函数
|
|
193
|
+
* @returns 删除的拦截器数量
|
|
194
|
+
*/
|
|
195
|
+
static removeAllInterceptors(interceptor) {
|
|
196
|
+
let removedCount = 0;
|
|
197
|
+
for (let i = this._interceptors.length - 1; i >= 0; i--) {
|
|
198
|
+
if (this._interceptors[i] === interceptor) {
|
|
199
|
+
this._interceptors.splice(i, 1);
|
|
200
|
+
removedCount++;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return removedCount;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* 按条件移除步骤拦截器
|
|
207
|
+
* @param predicate 判断是否删除的条件函数
|
|
208
|
+
* @returns 删除的拦截器数量
|
|
209
|
+
*/
|
|
210
|
+
static removeInterceptorByPredicate(predicate) {
|
|
211
|
+
let removedCount = 0;
|
|
212
|
+
for (let i = this._interceptors.length - 1; i >= 0; i--) {
|
|
213
|
+
if (predicate(this._interceptors[i], i)) {
|
|
214
|
+
this._interceptors.splice(i, 1);
|
|
215
|
+
removedCount++;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return removedCount;
|
|
174
219
|
}
|
|
175
220
|
/**
|
|
176
221
|
* 清空所有拦截器
|
package/package.json
CHANGED
package/src/Step.ts
CHANGED
|
@@ -91,7 +91,7 @@ export class Step {
|
|
|
91
91
|
for (const interceptor of this._interceptors) {
|
|
92
92
|
try {
|
|
93
93
|
const result = await interceptor(currentStep);
|
|
94
|
-
if (result
|
|
94
|
+
if (result) {
|
|
95
95
|
interceptedStep = result;
|
|
96
96
|
if (Step.showLog) {
|
|
97
97
|
console.log(`步骤${implnName}被拦截器拦截,执行拦截后的步骤`);
|
|
@@ -226,12 +226,62 @@ export class Step {
|
|
|
226
226
|
/**
|
|
227
227
|
* 移除步骤拦截器
|
|
228
228
|
* @param interceptor 要移除的拦截器函数
|
|
229
|
+
* @returns 是否成功删除
|
|
229
230
|
*/
|
|
230
|
-
static removeInterceptor(interceptor: StepInterceptor):
|
|
231
|
+
static removeInterceptor(interceptor: StepInterceptor): boolean {
|
|
231
232
|
const index = this._interceptors.indexOf(interceptor);
|
|
232
233
|
if (index > -1) {
|
|
233
234
|
this._interceptors.splice(index, 1);
|
|
235
|
+
return true;
|
|
234
236
|
}
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 按索引移除步骤拦截器
|
|
242
|
+
* @param index 要移除的拦截器索引
|
|
243
|
+
* @returns 是否成功删除
|
|
244
|
+
*/
|
|
245
|
+
static removeInterceptorByIndex(index: number): boolean {
|
|
246
|
+
if (index >= 0 && index < this._interceptors.length) {
|
|
247
|
+
this._interceptors.splice(index, 1);
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* 移除所有匹配的步骤拦截器
|
|
255
|
+
* @param interceptor 要移除的拦截器函数
|
|
256
|
+
* @returns 删除的拦截器数量
|
|
257
|
+
*/
|
|
258
|
+
static removeAllInterceptors(interceptor: StepInterceptor): number {
|
|
259
|
+
let removedCount = 0;
|
|
260
|
+
for (let i = this._interceptors.length - 1; i >= 0; i--) {
|
|
261
|
+
if (this._interceptors[i] === interceptor) {
|
|
262
|
+
this._interceptors.splice(i, 1);
|
|
263
|
+
removedCount++;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return removedCount;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 按条件移除步骤拦截器
|
|
271
|
+
* @param predicate 判断是否删除的条件函数
|
|
272
|
+
* @returns 删除的拦截器数量
|
|
273
|
+
*/
|
|
274
|
+
static removeInterceptorByPredicate(
|
|
275
|
+
predicate: (interceptor: StepInterceptor, index: number) => boolean
|
|
276
|
+
): number {
|
|
277
|
+
let removedCount = 0;
|
|
278
|
+
for (let i = this._interceptors.length - 1; i >= 0; i--) {
|
|
279
|
+
if (predicate(this._interceptors[i], i)) {
|
|
280
|
+
this._interceptors.splice(i, 1);
|
|
281
|
+
removedCount++;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return removedCount;
|
|
235
285
|
}
|
|
236
286
|
|
|
237
287
|
/**
|