@push.rocks/taskbuffer 3.1.7 → 3.1.9

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/readme.md CHANGED
@@ -1,61 +1,508 @@
1
- # @push.rocks/taskbuffer
2
- flexible task management. TypeScript ready!
1
+ # @push.rocks/taskbuffer 🚀
3
2
 
4
- ## Availabililty and Links
5
- * [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/taskbuffer)
6
- * [gitlab.com (source)](https://gitlab.com/push.rocks/taskbuffer)
7
- * [github.com (source mirror)](https://github.com/push.rocks/taskbuffer)
8
- * [docs (typedoc)](https://push.rocks.gitlab.io/taskbuffer/)
3
+ A **powerful**, **flexible**, and **TypeScript-first** task management library for orchestrating asynchronous operations with style. From simple task execution to complex distributed workflows, taskbuffer has got you covered.
9
4
 
10
- ## Status for master
5
+ ## Install 📦
11
6
 
12
- Status Category | Status Badge
13
- -- | --
14
- GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/taskbuffer/badges/master/pipeline.svg)](https://lossless.cloud)
15
- GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/taskbuffer/badges/master/coverage.svg)](https://lossless.cloud)
16
- npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/taskbuffer)](https://lossless.cloud)
17
- Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/taskbuffer)](https://lossless.cloud)
18
- TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
19
- node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
20
- Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
21
- PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/taskbuffer)](https://lossless.cloud)
22
- PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/taskbuffer)](https://lossless.cloud)
23
- BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/taskbuffer)](https://lossless.cloud)
7
+ ```bash
8
+ npm install @push.rocks/taskbuffer --save
9
+ ```
10
+
11
+ Or with **pnpm** (recommended):
12
+
13
+ ```bash
14
+ pnpm add @push.rocks/taskbuffer
15
+ ```
16
+
17
+ ## Why taskbuffer? 🤔
18
+
19
+ In the modern JavaScript ecosystem, managing asynchronous tasks efficiently is crucial. Whether you're building a data pipeline, managing API rate limits, or orchestrating complex workflows, **@push.rocks/taskbuffer** provides the tools you need:
20
+
21
+ - **🎯 TypeScript-first**: Built with TypeScript for TypeScript - enjoy complete type safety and excellent IDE support
22
+ - **⚡ Flexible execution**: From simple tasks to complex parallel workflows with dependencies
23
+ - **🔄 Smart buffering**: Control concurrent executions with intelligent buffer management
24
+ - **⏰ Built-in scheduling**: Cron-based task scheduling without additional dependencies
25
+ - **🎭 Multiple paradigms**: Support for debounced, throttled, and one-time execution patterns
26
+ - **🔌 Extensible**: Clean architecture that's easy to extend and customize
27
+ - **🏃 Zero dependencies on external schedulers**: Everything you need is included
28
+
29
+ ## Core Concepts 🎓
30
+
31
+ ### Task
32
+
33
+ The fundamental unit of work. A task wraps an asynchronous function and provides powerful execution control.
34
+
35
+ ### Taskchain
36
+
37
+ Sequential task execution - tasks run one after another, with results passed along the chain.
38
+
39
+ ### Taskparallel
40
+
41
+ Parallel task execution - multiple tasks run simultaneously for maximum performance.
42
+
43
+ ### TaskManager
44
+
45
+ Centralized task scheduling and management using cron expressions.
46
+
47
+ ### TaskDebounced
48
+
49
+ Debounced task execution - prevents rapid repeated executions, only running after a quiet period.
50
+
51
+ ### TaskOnce
52
+
53
+ Singleton task execution - ensures a task runs exactly once, perfect for initialization routines.
54
+
55
+ ## Quick Start 🏁
56
+
57
+ ### Basic Task Execution
58
+
59
+ ```typescript
60
+ import { Task } from '@push.rocks/taskbuffer';
61
+
62
+ // Create a simple task
63
+ const myTask = new Task({
64
+ name: 'DataProcessor',
65
+ taskFunction: async () => {
66
+ const data = await fetchData();
67
+ return processData(data);
68
+ },
69
+ });
70
+
71
+ // Execute the task
72
+ const result = await myTask.trigger();
73
+ ```
74
+
75
+ ### Buffered Execution (Rate Limiting)
76
+
77
+ Perfect for API calls or database operations that need throttling:
78
+
79
+ ```typescript
80
+ const apiTask = new Task({
81
+ name: 'APICall',
82
+ taskFunction: async (endpoint: string) => {
83
+ return await fetch(endpoint);
84
+ },
85
+ buffered: true,
86
+ bufferMax: 3, // Maximum 3 concurrent executions
87
+ execDelay: 1000, // Wait 1 second between executions
88
+ });
89
+
90
+ // These will be automatically throttled
91
+ for (let i = 0; i < 10; i++) {
92
+ apiTask.trigger(`/api/data/${i}`);
93
+ }
94
+ ```
95
+
96
+ ### Task Chains - Sequential Workflows
97
+
98
+ Build complex workflows where each step depends on the previous:
99
+
100
+ ```typescript
101
+ import { Task, Taskchain } from '@push.rocks/taskbuffer';
102
+
103
+ const fetchTask = new Task({
104
+ name: 'FetchData',
105
+ taskFunction: async () => {
106
+ const response = await fetch('/api/data');
107
+ return response.json();
108
+ },
109
+ });
110
+
111
+ const transformTask = new Task({
112
+ name: 'TransformData',
113
+ taskFunction: async (data) => {
114
+ return data.map((item) => ({
115
+ ...item,
116
+ processed: true,
117
+ timestamp: Date.now(),
118
+ }));
119
+ },
120
+ });
121
+
122
+ const saveTask = new Task({
123
+ name: 'SaveData',
124
+ taskFunction: async (transformedData) => {
125
+ await database.bulkInsert(transformedData);
126
+ return { saved: transformedData.length };
127
+ },
128
+ });
129
+
130
+ const workflow = new Taskchain({
131
+ name: 'DataPipeline',
132
+ taskArray: [fetchTask, transformTask, saveTask],
133
+ });
134
+
135
+ // Execute the entire chain
136
+ const result = await workflow.trigger();
137
+ console.log(`Processed ${result.saved} items`);
138
+ ```
139
+
140
+ ### Parallel Execution - Maximum Performance
141
+
142
+ Execute multiple independent tasks simultaneously:
143
+
144
+ ```typescript
145
+ import { Task, Taskparallel } from '@push.rocks/taskbuffer';
146
+
147
+ const tasks = ['user', 'posts', 'comments'].map(
148
+ (resource) =>
149
+ new Task({
150
+ name: `Fetch${resource}`,
151
+ taskFunction: async () => {
152
+ const data = await fetch(`/api/${resource}`);
153
+ return data.json();
154
+ },
155
+ }),
156
+ );
157
+
158
+ const parallelFetch = new Taskparallel({
159
+ taskArray: tasks,
160
+ });
161
+
162
+ // All tasks execute simultaneously
163
+ const [users, posts, comments] = await parallelFetch.trigger();
164
+ ```
165
+
166
+ ### Scheduled Tasks with TaskManager
167
+
168
+ Run tasks on a schedule using cron expressions:
169
+
170
+ ```typescript
171
+ import { Task, TaskManager } from '@push.rocks/taskbuffer';
172
+
173
+ const backupTask = new Task({
174
+ name: 'DatabaseBackup',
175
+ taskFunction: async () => {
176
+ await performBackup();
177
+ console.log(`Backup completed at ${new Date().toISOString()}`);
178
+ },
179
+ });
180
+
181
+ const manager = new TaskManager();
182
+
183
+ // Add and schedule tasks
184
+ manager.addAndScheduleTask(backupTask, '0 0 * * *'); // Daily at midnight
185
+ manager.addAndScheduleTask(healthCheck, '*/5 * * * *'); // Every 5 minutes
186
+
187
+ // Start the scheduler
188
+ manager.start();
189
+
190
+ // Later... stop if needed
191
+ manager.stop();
192
+ ```
193
+
194
+ ### Debounced Tasks - Smart Throttling
195
+
196
+ Prevent task spam with intelligent debouncing:
197
+
198
+ ```typescript
199
+ import { TaskDebounced } from '@push.rocks/taskbuffer';
200
+
201
+ const saveTask = new TaskDebounced({
202
+ name: 'AutoSave',
203
+ taskFunction: async (content: string) => {
204
+ await saveToDatabase(content);
205
+ console.log('Content saved');
206
+ },
207
+ debounceTimeInMillis: 2000, // Wait 2 seconds of inactivity
208
+ });
209
+
210
+ // Rapid calls will be debounced
211
+ input.addEventListener('input', (e) => {
212
+ saveTask.trigger(e.target.value);
213
+ });
214
+ ```
215
+
216
+ ### One-Time Tasks - Initialize Once
217
+
218
+ Ensure initialization code runs exactly once:
24
219
 
25
- ## Usage
220
+ ```typescript
221
+ import { TaskOnce } from '@push.rocks/taskbuffer';
26
222
 
27
- We highly recommend TypeScript as this module supports **TypeScript intellisense**.
223
+ const initTask = new TaskOnce({
224
+ name: 'SystemInitialization',
225
+ taskFunction: async () => {
226
+ await database.connect();
227
+ await cache.initialize();
228
+ await loadConfiguration();
229
+ console.log('System initialized');
230
+ },
231
+ });
28
232
 
29
- ```javascript
30
- import * as taskbuffer from "taskbuffer";
233
+ // Safe to call multiple times - only runs once
234
+ await initTask.trigger();
235
+ await initTask.trigger(); // This won't run again
236
+ ```
237
+
238
+ ## Advanced Features 🔥
239
+
240
+ ### Task Dependencies with Pre/Post Hooks
241
+
242
+ Create sophisticated task relationships:
243
+
244
+ ```typescript
245
+ const validationTask = new Task({
246
+ name: 'ValidateInput',
247
+ taskFunction: async (data) => {
248
+ if (!isValid(data)) {
249
+ throw new Error('Validation failed');
250
+ }
251
+ return data;
252
+ },
253
+ });
254
+
255
+ const mainTask = new Task({
256
+ name: 'ProcessData',
257
+ taskFunction: async (data) => {
258
+ return await complexProcessing(data);
259
+ },
260
+ preTask: validationTask, // Runs before main task
261
+ afterTask: cleanupTask, // Runs after main task
262
+ });
263
+ ```
264
+
265
+ ### Task Runners - Distributed Execution
266
+
267
+ The TaskRunner system enables distributed task execution across multiple workers:
268
+
269
+ ```typescript
270
+ import { TaskRunner } from '@push.rocks/taskbuffer';
271
+
272
+ const runner = new TaskRunner({
273
+ name: 'WorkerNode1',
274
+ maxConcurrentTasks: 5,
275
+ });
276
+
277
+ // Register tasks this runner can handle
278
+ runner.registerTask(dataProcessingTask);
279
+ runner.registerTask(imageResizeTask);
280
+
281
+ // Start processing
282
+ runner.start();
283
+ ```
284
+
285
+ ### Buffer Management Strategies
286
+
287
+ Fine-tune concurrent execution behavior:
288
+
289
+ ```typescript
290
+ const task = new Task({
291
+ name: 'ResourceIntensive',
292
+ taskFunction: async () => {
293
+ /* ... */
294
+ },
295
+ buffered: true,
296
+ bufferMax: 5, // Max 5 concurrent
297
+ execDelay: 100, // 100ms between starts
298
+ timeout: 30000, // 30 second timeout
299
+ });
300
+ ```
301
+
302
+ ### Cycle Detection and Prevention
303
+
304
+ TaskBuffer automatically detects and prevents circular dependencies:
305
+
306
+ ```typescript
307
+ const taskA = new Task({
308
+ name: 'TaskA',
309
+ taskFunction: async () => {
310
+ /* ... */
311
+ },
312
+ preTask: taskB, // This would create a cycle
313
+ });
314
+
315
+ const taskB = new Task({
316
+ name: 'TaskB',
317
+ taskFunction: async () => {
318
+ /* ... */
319
+ },
320
+ preTask: taskA, // Circular dependency detected!
321
+ });
322
+ ```
323
+
324
+ ### Dynamic Task Creation
325
+
326
+ Create tasks on-the-fly based on runtime conditions:
327
+
328
+ ```typescript
329
+ const dynamicWorkflow = async (config: Config) => {
330
+ const tasks = config.steps.map(
331
+ (step) =>
332
+ new Task({
333
+ name: step.name,
334
+ taskFunction: async (input) => {
335
+ return await processStep(step, input);
336
+ },
337
+ }),
338
+ );
339
+
340
+ const chain = new Taskchain({
341
+ name: 'DynamicWorkflow',
342
+ taskArray: tasks,
343
+ });
344
+
345
+ return await chain.trigger();
346
+ };
347
+ ```
348
+
349
+ ## API Reference 📚
350
+
351
+ ### Task Options
352
+
353
+ | Option | Type | Description |
354
+ | -------------- | ---------- | ------------------------------ |
355
+ | `name` | `string` | Unique identifier for the task |
356
+ | `taskFunction` | `Function` | Async function to execute |
357
+ | `buffered` | `boolean` | Enable buffer management |
358
+ | `bufferMax` | `number` | Maximum concurrent executions |
359
+ | `execDelay` | `number` | Delay between executions (ms) |
360
+ | `timeout` | `number` | Task timeout (ms) |
361
+ | `preTask` | `Task` | Task to run before |
362
+ | `afterTask` | `Task` | Task to run after |
31
363
 
32
- myTask = new taskbuffer.Task({
33
- preTask: someOtherTask // optional, don't worry loops are prevented
34
- afterTask: someOtherTask // optional, don't worry loops are prevented
35
- name:"myTask1",
36
- buffered: true, // optional
37
- bufferMax: 3, // optional, call qeues greater than this are truncated
38
- execDelay: 1000, // optional, time in ms to wait before executing task call
39
- taskFunction:() => {
40
- // do some stuff and return promise
41
- // pass on any data through promise resolution
42
- // Use TypeScript for better understanding and code completion
43
- }
44
- })
364
+ ### TaskManager Methods
365
+
366
+ | Method | Description |
367
+ | ------------------------------- | ------------------------ |
368
+ | `addTask(task, cronExpression)` | Add and schedule a task |
369
+ | `removeTask(taskName)` | Remove a scheduled task |
370
+ | `start()` | Start the scheduler |
371
+ | `stop()` | Stop the scheduler |
372
+ | `getStats()` | Get execution statistics |
373
+
374
+ ### Taskchain Methods
375
+
376
+ | Method | Description |
377
+ | ----------------------- | ---------------------- |
378
+ | `addTask(task)` | Add task to chain |
379
+ | `removeTask(taskName)` | Remove task from chain |
380
+ | `trigger(initialValue)` | Execute the chain |
381
+ | `reset()` | Reset chain state |
382
+
383
+ ## Performance Tips 🏎️
384
+
385
+ 1. **Use buffering for I/O operations**: Prevents overwhelming external services
386
+ 2. **Leverage parallel execution**: When tasks are independent, run them simultaneously
387
+ 3. **Implement proper error handling**: Use try-catch in task functions
388
+ 4. **Monitor task execution**: Use the built-in stats and logging
389
+ 5. **Set appropriate timeouts**: Prevent hanging tasks from blocking your system
390
+
391
+ ## Error Handling 🛡️
392
+
393
+ ```typescript
394
+ const robustTask = new Task({
395
+ name: 'RobustOperation',
396
+ taskFunction: async (input) => {
397
+ try {
398
+ return await riskyOperation(input);
399
+ } catch (error) {
400
+ // Log error
401
+ console.error(`Task failed: ${error.message}`);
402
+
403
+ // Optionally retry
404
+ if (error.retryable) {
405
+ return await riskyOperation(input);
406
+ }
407
+
408
+ // Or return default value
409
+ return defaultValue;
410
+ }
411
+ },
412
+ timeout: 5000, // Fail if takes longer than 5 seconds
413
+ });
414
+ ```
415
+
416
+ ## Real-World Examples 🌍
417
+
418
+ ### API Rate Limiting
419
+
420
+ ```typescript
421
+ const apiClient = new Task({
422
+ name: 'RateLimitedAPI',
423
+ taskFunction: async (endpoint: string) => {
424
+ return await fetch(`https://api.example.com${endpoint}`);
425
+ },
426
+ buffered: true,
427
+ bufferMax: 10, // 10 requests
428
+ execDelay: 100, // Per 100ms = 100 req/s max
429
+ });
430
+ ```
431
+
432
+ ### Database Migration Pipeline
433
+
434
+ ```typescript
435
+ const migrationChain = new Taskchain({
436
+ name: 'DatabaseMigration',
437
+ taskArray: [
438
+ backupTask,
439
+ schemaUpdateTask,
440
+ dataTransformTask,
441
+ validationTask,
442
+ cleanupTask,
443
+ ],
444
+ });
45
445
  ```
46
446
 
47
- For further information read the linked docs at the top of this README.
447
+ ### Microservice Health Monitoring
448
+
449
+ ```typescript
450
+ const healthMonitor = new TaskManager();
451
+
452
+ services.forEach((service) => {
453
+ const healthCheck = new Task({
454
+ name: `HealthCheck:${service.name}`,
455
+ taskFunction: async () => {
456
+ const healthy = await checkHealth(service.url);
457
+ if (!healthy) {
458
+ await alertOps(service);
459
+ }
460
+ },
461
+ });
462
+
463
+ healthMonitor.addAndScheduleTask(healthCheck, '*/1 * * * *'); // Every minute
464
+ });
465
+ ```
466
+
467
+ ## Testing 🧪
468
+
469
+ ```typescript
470
+ import { expect, tap } from '@git.zone/tstest';
471
+ import { Task } from '@push.rocks/taskbuffer';
472
+
473
+ tap.test('should execute task successfully', async () => {
474
+ const result = await myTask.trigger();
475
+ expect(result).toEqual(expectedValue);
476
+ });
477
+
478
+ tap.start();
479
+ ```
480
+
481
+ ## Contributing 🤝
482
+
483
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
484
+
485
+ ## Support 💬
486
+
487
+ - 📧 Email: [hello@task.vc](mailto:hello@task.vc)
488
+ - 🐛 Issues: [GitHub Issues](https://github.com/push-rocks/taskbuffer/issues)
489
+ - 📖 Docs: [Documentation](https://code.foss.global/push.rocks/taskbuffer)
490
+
491
+ ## License and Legal Information
492
+
493
+ This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
494
+
495
+ **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
48
496
 
49
- > MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
497
+ ### Trademarks
50
498
 
51
- [![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
499
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
52
500
 
53
- ## Contribution
501
+ ### Company Information
54
502
 
55
- We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
503
+ Task Venture Capital GmbH
504
+ Registered at District court Bremen HRB 35230 HB, Germany
56
505
 
57
- For further information read the linked docs at the top of this readme.
506
+ For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
58
507
 
59
- ## Legal
60
- > MIT licensed | **&copy;** [Task Venture Capital GmbH](https://task.vc)
61
- | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
508
+ By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
@@ -1,8 +1,8 @@
1
1
  /**
2
- * autocreated commitinfo by @pushrocks/commitinfo
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/taskbuffer',
6
- version: '3.1.7',
7
- description: 'flexible task management. TypeScript ready!'
6
+ version: '3.1.9',
7
+ description: 'A flexible task management library supporting TypeScript, allowing for task buffering, scheduling, and execution with dependency management.'
8
8
  }
@@ -13,9 +13,8 @@ export class BufferRunner {
13
13
  if (!(this.bufferCounter >= this.task.bufferMax)) {
14
14
  this.bufferCounter++;
15
15
  }
16
- const returnPromise: Promise<any> = this.task.cycleCounter.getPromiseForCycle(
17
- this.bufferCounter
18
- );
16
+ const returnPromise: Promise<any> =
17
+ this.task.cycleCounter.getPromiseForCycle(this.bufferCounter);
19
18
  if (!this.task.running) {
20
19
  this._run(x);
21
20
  }
@@ -26,11 +26,11 @@ export interface IDistributedTaskRequestResult {
26
26
 
27
27
  export abstract class AbstractDistributedCoordinator {
28
28
  public abstract fireDistributedTaskRequest(
29
- infoBasis: IDistributedTaskRequest
29
+ infoBasis: IDistributedTaskRequest,
30
30
  ): Promise<IDistributedTaskRequestResult>;
31
31
 
32
32
  public abstract updateDistributedTaskRequest(
33
- infoBasis: IDistributedTaskRequest
33
+ infoBasis: IDistributedTaskRequest,
34
34
  ): Promise<void>;
35
35
 
36
36
  public abstract start(): Promise<void>;
@@ -16,7 +16,7 @@ export type TPreOrAfterTaskFunction = () => Task<any>;
16
16
 
17
17
  export class Task<T = undefined> {
18
18
  public static extractTask<T = undefined>(
19
- preOrAfterTaskArg: Task<T> | TPreOrAfterTaskFunction
19
+ preOrAfterTaskArg: Task<T> | TPreOrAfterTaskFunction,
20
20
  ): Task<T> {
21
21
  switch (true) {
22
22
  case !preOrAfterTaskArg:
@@ -47,7 +47,7 @@ export class Task<T = undefined> {
47
47
 
48
48
  public static isTaskTouched<T = undefined>(
49
49
  taskArg: Task<T> | TPreOrAfterTaskFunction,
50
- touchedTasksArray: Task<T>[]
50
+ touchedTasksArray: Task<T>[],
51
51
  ): boolean {
52
52
  const taskToCheck = Task.extractTask(taskArg);
53
53
  let result = false;
@@ -61,7 +61,7 @@ export class Task<T = undefined> {
61
61
 
62
62
  public static runTask = async <T>(
63
63
  taskArg: Task<T> | TPreOrAfterTaskFunction,
64
- optionsArg: { x?: any; touchedTasksArray?: Task<T>[] }
64
+ optionsArg: { x?: any; touchedTasksArray?: Task<T>[] },
65
65
  ) => {
66
66
  const taskToRun = Task.extractTask(taskArg);
67
67
  const done = plugins.smartpromise.defer();
@@ -105,7 +105,10 @@ export class Task<T = undefined> {
105
105
  const localDeferred = plugins.smartpromise.defer();
106
106
  localDeferred.promise
107
107
  .then(() => {
108
- if (taskToRun.preTask && !Task.isTaskTouched(taskToRun.preTask, touchedTasksArray)) {
108
+ if (
109
+ taskToRun.preTask &&
110
+ !Task.isTaskTouched(taskToRun.preTask, touchedTasksArray)
111
+ ) {
109
112
  return Task.runTask(taskToRun.preTask, { x, touchedTasksArray });
110
113
  } else {
111
114
  const done2 = plugins.smartpromise.defer();
@@ -121,8 +124,14 @@ export class Task<T = undefined> {
121
124
  }
122
125
  })
123
126
  .then((x) => {
124
- if (taskToRun.afterTask && !Task.isTaskTouched(taskToRun.afterTask, touchedTasksArray)) {
125
- return Task.runTask(taskToRun.afterTask, { x: x, touchedTasksArray: touchedTasksArray });
127
+ if (
128
+ taskToRun.afterTask &&
129
+ !Task.isTaskTouched(taskToRun.afterTask, touchedTasksArray)
130
+ ) {
131
+ return Task.runTask(taskToRun.afterTask, {
132
+ x: x,
133
+ touchedTasksArray: touchedTasksArray,
134
+ });
126
135
  } else {
127
136
  const done2 = plugins.smartpromise.defer();
128
137
  done2.resolve(x);
@@ -27,14 +27,18 @@ export class Taskchain extends Task {
27
27
  let taskCounter = 0; // counter for iterating async over the taskArray
28
28
  const iterateTasks = (x: any) => {
29
29
  if (typeof this.taskArray[taskCounter] !== 'undefined') {
30
- console.log(this.name + ' running: Task' + this.taskArray[taskCounter].name);
30
+ console.log(
31
+ this.name + ' running: Task' + this.taskArray[taskCounter].name,
32
+ );
31
33
  this.taskArray[taskCounter].trigger(x).then((x) => {
32
34
  logger.log('info', this.taskArray[taskCounter].name);
33
35
  taskCounter++;
34
36
  iterateTasks(x);
35
37
  });
36
38
  } else {
37
- console.log('Taskchain "' + this.name + '" completed successfully');
39
+ console.log(
40
+ 'Taskchain "' + this.name + '" completed successfully',
41
+ );
38
42
  done.resolve(x);
39
43
  }
40
44
  };
@@ -19,7 +19,9 @@ export class TaskDebounced<T = unknown> extends Task {
19
19
  });
20
20
  this.taskFunction = optionsArg.taskFunction;
21
21
  this._observableIntake.observable
22
- .pipe(plugins.smartrx.rxjs.ops.debounceTime(optionsArg.debounceTimeInMillis))
22
+ .pipe(
23
+ plugins.smartrx.rxjs.ops.debounceTime(optionsArg.debounceTimeInMillis),
24
+ )
23
25
  .subscribe((x) => {
24
26
  this.taskFunction(x);
25
27
  });