@deot/dev-test 2.8.0 → 2.8.1

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/index.cjs CHANGED
@@ -371,6 +371,58 @@ class Launch {
371
371
  }
372
372
  }
373
373
 
374
+ class Scheduler {
375
+ _success;
376
+ _fail;
377
+ _task;
378
+ _finish = false;
379
+ constructor() {
380
+ this.next();
381
+ }
382
+ next = (v) => {
383
+ if (!this._finish) {
384
+ this._success?.(v);
385
+ this._task = new Promise((resolve, reject) => {
386
+ this._success = (value) => {
387
+ this._fail = void 0;
388
+ resolve(value);
389
+ };
390
+ this._fail = (value) => {
391
+ this._success = void 0;
392
+ reject(value);
393
+ };
394
+ });
395
+ }
396
+ return this;
397
+ };
398
+ nextWithError = (v) => {
399
+ if (!this._finish) {
400
+ this._fail?.(v);
401
+ this.next();
402
+ }
403
+ return this;
404
+ };
405
+ finish = (v) => {
406
+ this._success?.(v);
407
+ this._finish = true;
408
+ return this;
409
+ };
410
+ finishWithError = (v) => {
411
+ this._fail?.(v);
412
+ this._finish = true;
413
+ return this;
414
+ };
415
+ then(resolve, reject) {
416
+ return this._task.then(resolve, reject);
417
+ }
418
+ catch(callback) {
419
+ return this._task.catch(callback);
420
+ }
421
+ finally(callback) {
422
+ return this._task.finally(callback);
423
+ }
424
+ }
425
+
374
426
  const TIME_OUT = 60 * 1e3;
375
427
  const impl = () => {
376
428
  const launch = new Launch();
@@ -498,5 +550,6 @@ exports.Command = Command;
498
550
  exports.E2E = e2e;
499
551
  exports.Launch = Launch;
500
552
  exports.Operater = Operater;
553
+ exports.Scheduler = Scheduler;
501
554
  exports.Server = server;
502
555
  exports.Utils = utils;
package/dist/index.d.ts CHANGED
@@ -52,6 +52,8 @@ declare interface ExpectByPollingOptions {
52
52
  to?: string;
53
53
  }
54
54
 
55
+ declare type Func<T> = (_?: T) => void;
56
+
55
57
  declare const host: (force?: boolean) => string;
56
58
 
57
59
  declare const impl: () => Launch;
@@ -94,6 +96,21 @@ export declare class Operater {
94
96
 
95
97
  declare const port: (host$?: string, port$?: number) => Promise<unknown>;
96
98
 
99
+ export declare class Scheduler<T = any> {
100
+ _success?: Func<any>;
101
+ _fail?: Func<any>;
102
+ _task: Promise<any>;
103
+ _finish: boolean;
104
+ constructor();
105
+ next: (v?: T) => this;
106
+ nextWithError: (v?: any) => this;
107
+ finish: (v?: T) => this;
108
+ finishWithError: (v?: T) => this;
109
+ then(resolve: Func<T>, reject: Func<T>): Promise<void>;
110
+ catch(callback?: Func<T>): Promise<any>;
111
+ finally(callback?: Func<void>): Promise<any>;
112
+ }
113
+
97
114
  declare namespace Server {
98
115
  export {
99
116
  host,
package/dist/index.js CHANGED
@@ -346,6 +346,58 @@ class Launch {
346
346
  }
347
347
  }
348
348
 
349
+ class Scheduler {
350
+ _success;
351
+ _fail;
352
+ _task;
353
+ _finish = false;
354
+ constructor() {
355
+ this.next();
356
+ }
357
+ next = (v) => {
358
+ if (!this._finish) {
359
+ this._success?.(v);
360
+ this._task = new Promise((resolve, reject) => {
361
+ this._success = (value) => {
362
+ this._fail = void 0;
363
+ resolve(value);
364
+ };
365
+ this._fail = (value) => {
366
+ this._success = void 0;
367
+ reject(value);
368
+ };
369
+ });
370
+ }
371
+ return this;
372
+ };
373
+ nextWithError = (v) => {
374
+ if (!this._finish) {
375
+ this._fail?.(v);
376
+ this.next();
377
+ }
378
+ return this;
379
+ };
380
+ finish = (v) => {
381
+ this._success?.(v);
382
+ this._finish = true;
383
+ return this;
384
+ };
385
+ finishWithError = (v) => {
386
+ this._fail?.(v);
387
+ this._finish = true;
388
+ return this;
389
+ };
390
+ then(resolve, reject) {
391
+ return this._task.then(resolve, reject);
392
+ }
393
+ catch(callback) {
394
+ return this._task.catch(callback);
395
+ }
396
+ finally(callback) {
397
+ return this._task.finally(callback);
398
+ }
399
+ }
400
+
349
401
  const TIME_OUT = 60 * 1e3;
350
402
  const impl = () => {
351
403
  const launch = new Launch();
@@ -469,4 +521,4 @@ const server = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
469
521
  port
470
522
  }, Symbol.toStringTag, { value: 'Module' }));
471
523
 
472
- export { Command, e2e as E2E, Launch, Operater, server as Server, utils as Utils };
524
+ export { Command, e2e as E2E, Launch, Operater, Scheduler, server as Server, utils as Utils };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deot/dev-test",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",