diff --git a/package-lock.json b/package-lock.json index 9919d7a..5e67a27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,54 +1,36 @@ { - "name": "queue", + "name": "@typescript-package/queue", "version": "2.0.0-beta", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "queue", + "name": "@typescript-package/queue", "version": "2.0.0-beta", - "dependencies": { - "tslib": "^2.3.0" - }, - "peerDependencies": { - "@angular/common": "^19.0.0", - "@angular/core": "^19.0.0", - "@typescript-package/state": "^2.0.0" - } - }, - "node_modules/@angular/common": { - "version": "19.0.5", - "resolved": "https://registry.npmjs.org/@angular/common/-/common-19.0.5.tgz", - "integrity": "sha512-fFK+euCj1AjBHBCpj9VnduMSeqoMRhZZHbhPYiND7tucRRJ8vwGU0sYK2KI/Ko+fsrNIXL/0O4F36jVPl09Smg==", + "funding": [ + { + "type": "individual", + "url": "https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29" + } + ], "license": "MIT", - "peer": true, - "dependencies": { - "tslib": "^2.3.0" - }, - "engines": { - "node": "^18.19.1 || ^20.11.1 || >=22.0.0" - }, "peerDependencies": { - "@angular/core": "19.0.5", - "rxjs": "^6.5.3 || ^7.4.0" + "@typedly/callback": "^1.0.0-beta.2", + "@typescript-package/state": "^2.0.0" } }, - "node_modules/@angular/core": { - "version": "19.0.5", - "resolved": "https://registry.npmjs.org/@angular/core/-/core-19.0.5.tgz", - "integrity": "sha512-Ywc6sPO6G/Y1stfk3y/MallV/h0yzQ0vdOHRWueLrk5kD1DTdbolV4X03Cs3PuVvravgcSVE3nnuuHFuH32emQ==", + "node_modules/@typedly/callback": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@typedly/callback/-/callback-1.0.0-beta.2.tgz", + "integrity": "sha512-s6p+SEfgSN1nmrm2K4xkCNSwhsc6MCZ1VxuRM4RcAPGBjzGEt9iyYVdl4jbGhl5IrAxGjTbAhVzzz1SIJv5GcA==", + "funding": [ + { + "type": "individual", + "url": "https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29" + } + ], "license": "MIT", - "peer": true, - "dependencies": { - "tslib": "^2.3.0" - }, - "engines": { - "node": "^18.19.1 || ^20.11.1 || >=22.0.0" - }, - "peerDependencies": { - "rxjs": "^6.5.3 || ^7.4.0", - "zone.js": "~0.15.0" - } + "peer": true }, "node_modules/@typescript-package/state": { "version": "2.0.0", @@ -62,29 +44,6 @@ ], "license": "MIT", "peer": true - }, - "node_modules/rxjs": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", - "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", - "license": "Apache-2.0", - "peer": true, - "dependencies": { - "tslib": "^2.1.0" - } - }, - "node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "license": "0BSD" - }, - "node_modules/zone.js": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.15.0.tgz", - "integrity": "sha512-9oxn0IIjbCZkJ67L+LkhYWRyAy7axphb3VgE2MBDlOqnmHMPWGYMxJxBYFueFq/JGY2GMwS0rU+UCLunEmy5UA==", - "license": "MIT", - "peer": true } } } diff --git a/package.json b/package.json index 93d90d3..8de4bbd 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "registry": "https://registry.npmjs.org" }, "peerDependencies": { + "@typedly/callback": "^1.0.0-beta.2", "@typescript-package/state": "^2.0.0" }, "repository": { diff --git a/src/enum/processed.enum.ts b/src/enum/processed.enum.ts new file mode 100644 index 0000000..4028367 --- /dev/null +++ b/src/enum/processed.enum.ts @@ -0,0 +1,4 @@ +export enum Processed { + Success = "Success", + Failure = "Failure", +} diff --git a/src/lib/processing.class.ts b/src/lib/processing.class.ts index d402c2b..14af02d 100644 --- a/src/lib/processing.class.ts +++ b/src/lib/processing.class.ts @@ -47,6 +47,15 @@ export class Processing extends State>> { return Array.from(super.state)[super.state.size - 1]; } + /** + * @description Display the console debug on debug state `true`. + * @readonly + * @type {*} + */ + get #console() { + return this.#debug.isTrue() ? console : undefined; + } + /** * @description * @type {*} @@ -69,7 +78,7 @@ export class Processing extends State>> { */ public add(promise: Promise, remove: boolean = true): this { super.state.add(promise); - this.#consoleDebug("`Promise` added to processing state", { active: this.active, activeCount: this.activeCount }); + this.#console?.debug("`Promise` added to processing state", { active: this.active, activeCount: this.activeCount }); remove === true && promise.finally(() => this.delete(promise)); return this; } @@ -81,12 +90,12 @@ export class Processing extends State>> { * @returns {Promise} */ public async complete(): Promise { - this.#consoleDebug("Invoked `Processing.complete()` to wait for all processes from the state ", { activeCount: this.activeCount }) + this.#console?.debug("Invoked `Processing.complete()` to wait for all processes from the state ", { activeCount: this.activeCount }) const promise = Promise.all(super.state); await promise; if (this.#debug.isTrue()) { promise.finally(() => - this.#consoleDebug("`Processing.complete()` finally method invoked.", { activeCount: this.activeCount }) + this.#console?.debug("`Processing.complete()` finally method invoked.", { activeCount: this.activeCount }) ); } } @@ -107,9 +116,9 @@ export class Processing extends State>> { * @returns {this} */ public delete(promise: Promise = this.first): this { - this.#consoleDebug("`activeCount` state before removing the `Promise`", { activeCount: this.activeCount }) + this.#console?.debug("`activeCount` state before removing the `Promise`", { activeCount: this.activeCount }) super.state.delete(promise); - this.#consoleDebug("`Promise` removed from processing state", { activeCount: this.activeCount }); + this.#console?.debug("`Promise` removed from processing state", { activeCount: this.activeCount }); return this; } @@ -131,15 +140,4 @@ export class Processing extends State>> { this.#debug.false(); return this; } - - /** - * @description Display the console debug on debug state `true`. - * @param {string} message - * @param {?*} [data] - * @returns {this} - */ - #consoleDebug(message: string, data?: any): this { - this.#debug.isTrue() && console.debug(message, data || ''); - return this; - } } diff --git a/src/lib/task-queue.class.ts b/src/lib/task-queue.class.ts index 0ee698f..ed90611 100644 --- a/src/lib/task-queue.class.ts +++ b/src/lib/task-queue.class.ts @@ -4,21 +4,23 @@ import { Queue } from "./queue.abstract"; import { Processing } from "./processing.class"; import { Tasks } from "./tasks.class"; // Type. -import { ErrorCallback, ProcessCallback } from "../type"; +import { ErrorCallback, FailureCallback, ProcessCallback, SuccessCallback } from "@typedly/callback"; +// Enum. +import { Processed } from "../enum/processed.enum"; /** * @description A task queue that processes elements concurrently with a specified concurrency limit. * @export * @class TaskQueue - * @template Type + * @template Element * @template {number} [Concurrency=number] * @template {number} [Size=number] - * @extends {Queue} + * @extends {Queue} */ export class TaskQueue< - Type, + Element, Concurrency extends number = number, Size extends number = number -> extends Queue { +> extends Queue { /** * @description The maximum number of elements that can be processed concurrently. * @public @@ -33,9 +35,9 @@ export class TaskQueue< * @description Returns the processed elements. * @public * @readonly - * @type {Set} + * @type {Set} */ - public get processed(): Set { + public get processed(): Set { return this.#tasks.processed; } @@ -43,7 +45,7 @@ export class TaskQueue< * @description Returns the `Processing` object that contains active tasks. * @public * @readonly - * @type {Processing} + * @type {Processing} */ public get processing(): Processing { return this.#tasks.processing; @@ -51,7 +53,7 @@ export class TaskQueue< /** * @description The `Tasks` object to handle the processing. - * @type {Tasks} + * @type {Tasks} */ #tasks; @@ -60,15 +62,15 @@ export class TaskQueue< * @constructor * @param {Concurrency} [concurrency=1 as Concurrency] * @param {Size} [size=Infinity as Size] - * @param {...Type[]} elements + * @param {...Element[]} elements */ constructor( concurrency: Concurrency = 1 as Concurrency, size: Size = Infinity as Size, - ...elements: Type[] + ...elements: Element[] ) { super(size, ...elements); - this.#tasks = new Tasks(true, concurrency); + this.#tasks = new Tasks(true, concurrency); } /** @@ -85,10 +87,10 @@ export class TaskQueue< * @description Waits for all elements in the queue to be processed and returns the set of processed elements. * @public * @async - * @returns {Promise>} + * @returns {Promise>} */ - public async onCompleted(): Promise> { - return new Promise>((resolve, reject) => { + public async onCompleted(): Promise> { + return new Promise>((resolve, reject) => { const interval = setInterval(() => this.#tasks.processing.isActive() ? super.length === 0 && resolve([] as any) // TODO: this.#tasks.processed @@ -101,20 +103,24 @@ export class TaskQueue< * @description Starts asynchronous processing queue elements with concurrency control. * @public * @async - * @param {ProcessCallback} callbackFn The function to process each element. - * @param {?ErrorCallback} [onError] An optional error handler. - * @returns {Promise>} + * @param {ProcessCallback | Processed>} callbackFn The function to process each element. + * @param {?SuccessCallback} [onSuccess] An optional success handler. + * @param {?FailureCallback} [onFailure] An optional failure handler. + * @param {?ErrorCallback} [onError] An optional error handler. + * @returns {Promise>} */ public async asyncRun( - callbackFn: ProcessCallback, - onError?: ErrorCallback, - ): Promise> { + callbackFn: ProcessCallback | Processed>, + onSuccess?: SuccessCallback, + onFailure?: FailureCallback, + onError?: ErrorCallback, + ): Promise> { const process = async () => { while (this.#tasks.processing.activeCount < this.#tasks.concurrency && super.length > 0) { const element = this.dequeue(); if (element) { const task = this.#tasks - .asyncProcess(element, callbackFn, onError) + .asyncProcess(element, callbackFn, onSuccess, onFailure, onError) .finally(() => (this.#tasks.processing.delete(task), process())); this.#tasks.processing.add(task, false); } @@ -130,13 +136,20 @@ export class TaskQueue< /** * @description Starts processing elements in the queue using the provided callback function. * @public - * @param {(element: Type) => void} callbackFn A function to process each element in the queue. - * @param {?(element: Type, error: unknown) => void} [onError] An optional function to handle the error. + * @param {ProcessCallback | Processed>} callbackFn A function to process each element in the queue. + * @param {?SuccessCallback} [onSuccess] An optional function to handle the success. + * @param {?FailureCallback} [onFailure] An optional function to handle the failure. + * @param {?ErrorCallback} [onError] An optional function to handle the error. * @returns {void) => void} */ - public run(callbackFn: (element: Type) => void, onError?: (element: Type, error: unknown) => void) { + public run( + callbackFn: ProcessCallback | Processed>, + onSuccess?: SuccessCallback, + onFailure?: FailureCallback, + onError?: ErrorCallback, + ): void { while (super.length > 0) { - this.#tasks.process(this.dequeue(), callbackFn, onError); + this.#tasks.process(this.dequeue(), callbackFn, onSuccess, onFailure, onError); } } } diff --git a/src/lib/tasks.class.ts b/src/lib/tasks.class.ts index 3968630..6327660 100644 --- a/src/lib/tasks.class.ts +++ b/src/lib/tasks.class.ts @@ -2,15 +2,17 @@ import { Ability as Processable, Boolean as Active, Boolean as Debug } from "@typescript-package/state"; import { Processing } from "./processing.class"; // Type. -import { ErrorCallback, ProcessCallback } from "../type"; +import { ErrorCallback, FailureCallback, ProcessCallback, SuccessCallback } from '@typedly/callback'; +// Enum. +import { Processed } from "../enum/processed.enum"; /** * @description A class designed to manage and execute a collection of asynchronous tasks with concurrently control or synchronous tasks. * @export * @class Tasks - * @template Type + * @template Element * @extends {Processable} */ -export class Tasks extends Processable { +export class Tasks extends Processable { /** * @description The maximum number of elements that can be processed concurrently. * @public @@ -25,9 +27,9 @@ export class Tasks extends Proc * @description Returns the processed elements. * @public * @readonly - * @type {Set} + * @type {Set} */ - public get processed(): Set { + public get processed(): Set { return this.#processed; } @@ -35,12 +37,21 @@ export class Tasks extends Proc * @description Returns the `Processing` object that contains active tasks. * @public * @readonly - * @type {Processing} + * @type {Processing} */ public get processing(): Processing { return this.#processing; } + /** + * @description Console debug the important steps of the `Tasks` functionality on debug state `true`. + * @readonly + * @type {Console | undefined} + */ + get #console() { + return this.#debug.isTrue() ? console : undefined; + } + /** * @description Active state for synchronous processing. * @type {Active} @@ -61,9 +72,9 @@ export class Tasks extends Proc /** * @description A set of processed elements. - * @type {Set} + * @type {Set} */ - #processed: Set = new Set(); + #processed: Set = new Set(); /** * @description Privately stored `Processing` object that contains active tasks. @@ -103,33 +114,38 @@ export class Tasks extends Proc * @description Runs asynchronous single processing on the `element`. * @public * @async - * @param {Type} element The element to process. - * @param {ProcessCallback} callbackFn The callback function to process the element. - * @param {ErrorCallback} [onError] An optional error handler. + * @param {Element} element The element to process. + * @param {ProcessCallback | Processed>} callbackFn The callback function to process the element. + * @param {SuccessCallback} [onSuccess] An optional success handler. + * @param {FailureCallback} [onFailure] An optional failure handler. + * @param {ErrorCallback} [onError] An optional error handler. * @returns {Promise} */ public async asyncProcess( - element: Type, - callbackFn: ProcessCallback, - onError?: ErrorCallback, - onProcessed?: ProcessCallback + element: Element, + callbackFn: ProcessCallback | Processed>, + onSuccess?: SuccessCallback, + onFailure?: FailureCallback, + onError?: ErrorCallback, ): Promise { if (this.isDisabled()) { throw new Error(`Enable the functionality to use the \`asyncProcess()\` method.`); } - this.#consoleDebug("asyncProcess started", { element }); + this.#console?.debug("asyncProcess started", { element }); // Create a promise. const task = (async () => { + let processed: void | Promise | Processed = Processed.Success; + try { - this.#consoleDebug("Processing element:", element); - await callbackFn(element); + this.#console?.debug("Processing element:", element); + processed = await callbackFn(element); } catch (error) { - this.#consoleDebug("Error occurred during processing:", { element, error }); - onError?.(element, error); + this.#console?.debug("Error occurred during processing:", { element, error }); + onError?.(element); } finally { - onProcessed?.(element); // What to do with the processed + (processed === Processed.Failure) ? onFailure?.(element) : onSuccess?.(element); this.#processed.add(element); - this.#consoleDebug("Element processed:", { element, processed: this.#processed.size }); + this.#console?.debug("Element processed:", { element, processed: this.#processed.size }); } })(); // Add the task to the processing state. @@ -140,46 +156,49 @@ export class Tasks extends Proc * @description Starts asynchronous processing elements with concurrency control. * @public * @async - * @param {Iterable} elements The elements to process. - * @param {ProcessCallback} callbackFn The function to process each element. - * @param {?ErrorCallback} [onError] An optional error handler. + * @param {Iterable} elements The elements to process. + * @param {ProcessCallback | Processed>} processFn The function to process each element. + * @param {?SuccessCallback} [onSuccess] An optional on success handler. + * @param {?FailureCallback} [onFailure] An optional on failure handler. + * @param {?ErrorCallback} [onError] An optional on error handler. * @param {('default' | 'race')} [method='default'] * @returns {Promise} */ public async asyncRun( - elements: Iterable, - callbackFn: ProcessCallback, - onError?: ErrorCallback, - onProcessed?: ProcessCallback, + elements: Iterable, + processFn: ProcessCallback | Processed>, + onSuccess?: SuccessCallback, + onFailure?: FailureCallback, + onError?: ErrorCallback, method: 'all' | 'default' | 'race' = 'default' - ): Promise> { + ): Promise> { if (this.isDisabled()) { throw new Error(`Enable the functionality to use the \`asyncRun()\` method.`); } - this.#consoleDebug("asyncRun started", { method, concurrency: this.#concurrency }); + this.#console?.debug("asyncRun started", { method, concurrency: this.#concurrency }); switch(method) { case 'race': - this.#consoleDebug("Using 'race' method"); + this.#console?.debug("Using 'race' method"); for (const element of elements) { - this.#consoleDebug("Processing element with 'race'", { element, activeCount: this.#processing.activeCount }); + this.#console?.debug("Processing element with 'race'", { element, activeCount: this.#processing.activeCount }); this.#processing.activeCount >= this.#concurrency && await Promise.race(this.#processing.state); - this.asyncProcess(element, callbackFn, onError, onProcessed); + this.asyncProcess(element, processFn, onSuccess, onFailure, onError); } break case 'all': default: - this.#consoleDebug("Using the 'default' / 'all' method"); + this.#console?.debug("Using the 'default' / 'all' method"); const iterator = elements[Symbol.iterator](); // Create the async process for the task. const process = async (): Promise => { while (this.#processing.activeCount < this.#concurrency) { const { value: element, done } = iterator.next(); if (done) break; - this.#consoleDebug("Processing element with default", { element, concurrency: this.#concurrency, activeCount: this.#processing.activeCount }); + this.#console?.debug("Processing element with default", { element, concurrency: this.#concurrency, activeCount: this.#processing.activeCount }); const task = this - .asyncProcess(element, callbackFn, onError, onProcessed) + .asyncProcess(element, processFn, onSuccess, onFailure, onError) .finally(() => (this.#processing.delete(task), process())); - this.#consoleDebug("Add the processed task to the processing.", {element, task}); + this.#console?.debug("Add the processed task to the processing.", {element, task}); this.#processing.add(task, false); } // Wait for the tasks to finish. @@ -188,7 +207,7 @@ export class Tasks extends Proc await process(); break; } - this.#consoleDebug("asyncRun completed"); + this.#console?.debug("asyncRun completed"); await this.#processing.complete(); return this.#processed; } @@ -196,37 +215,42 @@ export class Tasks extends Proc /** * @description Runs a synchronous processing on the provided `element` using the `callbackFn`. * If an `onError` callback is provided, it will handle any errors encountered during processing. - * @param {(Type | undefined)} element The element to be processed. - * @param {ProcessCallback} callbackFn A function that processes the element synchronously. - * @param {?ErrorCallback} [onError] An optional callback function to handle errors during processing. + * @public + * @param {(Element | undefined)} element The element to be processed. + * @param {ProcessCallback | Processed>} callbackFn A function that processes the element synchronously. + * @param {?SuccessCallback} [onSuccess] An optional callback function to handle success element being processed. + * @param {?FailureCallback} [onFailure] An optional callback function to handle failure element being processed. + * @param {?ErrorCallback} [onError] An optional callback function to handle errors during processing. * @returns {this} The current instance for method chaining. */ public process( - element: Type | undefined, - callbackFn: ProcessCallback, - onError?: ErrorCallback, - onProcessed?: ProcessCallback + element: Element | undefined, + callbackFn: ProcessCallback | void | Promise | Processed>, + onSuccess?: SuccessCallback, + onFailure?: FailureCallback, + onError?: ErrorCallback, ): this { if (this.isDisabled()) { throw new Error(`Enable the functionality to use the \`process()\` method.`); } - this.#consoleDebug("process started", { element }); + this.#console?.debug("process started", { element }); this.#active.isFalse() && this.#active.true(); - this.#consoleDebug("Processing state activated", { active: this.#active.state }); + this.#console?.debug("Processing state activated", { active: this.#active.state }); if (element) { + let processed: void | Promise | Processed = Processed.Success; try { - this.#consoleDebug("Processing element", { element }); - callbackFn(element); + this.#console?.debug("Processing element", { element }); + processed = callbackFn(element); } catch(error) { - this.#consoleDebug("Error during processing", { error, element }); - onError?.(element, error); + this.#console?.debug("Error during processing", { error, element }); + onError?.(element); } finally { - onProcessed?.(element); + (processed === Processed.Failure) ? onFailure?.(element) : onSuccess?.(element); // Add to the processed. this.#processed.add(element); - this.#consoleDebug("Element processed", { element, processedCount: this.#processed.size }); + this.#console?.debug("Element processed", { element, processedCount: this.#processed.size }); this.#active.false(); - this.#consoleDebug("Processing state deactivated", { active: this.#active.state }); + this.#console?.debug("Processing state deactivated", { active: this.#active.state }); } } return this; @@ -236,25 +260,28 @@ export class Tasks extends Proc * @description Runs the provided `callbackFn` synchronously on each element in the `elements` iterable. * If an `onError` callback is provided, it will handle errors encountered during processing. * @public - * @param {Iterable} elements An iterable collection of elements to be processed. - * @param {ProcessCallback} callbackFn A function that will process each element synchronously. - * @param {?ErrorCallback} [onError] Optional callback for handling errors that occur during processing. + * @param {Iterable} elements An iterable collection of elements to be processed. + * @param {ProcessCallback | Processed>} processFn A function that will process each element synchronously. + * @param {?SuccessCallback} [onSuccess] Optional callback for success processed element. + * @param {?FailureCallback} [onFailure] Optional callback for failure of processed element. + * @param {?ErrorCallback} [onError] Optional callback for handling errors that occur during processing. */ public run( - elements: Iterable, - callbackFn: ProcessCallback, - onError?: ErrorCallback, - onProcessed?: ProcessCallback + elements: Iterable, + processFn: ProcessCallback | Processed>, + onSuccess?: SuccessCallback, + onFailure?: FailureCallback, + onError?: ErrorCallback, ) { if (this.isDisabled()) { throw new Error(`Enable the functionality to use the \`run()\` method.`); } - this.#consoleDebug("run started", { elements }); + this.#console?.debug("run started", { elements }); for (const element of elements) { - this.#consoleDebug("Processing element synchronously", { element }); - this.process(element, callbackFn, onError, onProcessed); + this.#console?.debug("Processing element synchronously", { element }); + this.process(element, processFn, onSuccess, onFailure, onError); } - this.#consoleDebug("run completed"); + this.#console?.debug("run completed"); } /** @@ -266,15 +293,4 @@ export class Tasks extends Proc this.#processing.unDebug(); return this; } - - /** - * @description Console debug the important steps of the `Tasks` functionality on debug state `true`. - * @param {string} message - * @param {?*} [data] - * @returns {this} - */ - #consoleDebug(message: string, data?: any): this { - this.#debug.isTrue() && console.debug(message, data || ''); - return this; - } } diff --git a/src/test/tasks.spec.ts b/src/test/tasks.spec.ts index bc426bf..8bc4ccc 100644 --- a/src/test/tasks.spec.ts +++ b/src/test/tasks.spec.ts @@ -1,3 +1,4 @@ +import { Processed } from '../enum/processed.enum'; import { Tasks } from '../lib/tasks.class'; console.group(`Tasks`); @@ -6,9 +7,16 @@ let tasks = new Tasks(true, 3); tasks.debug().asyncRun( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], - element => {}, - () => {}, - element => {}, + element => { + console.debug(`Processing, `, element); + if (element === 5) { + return Processed.Failure; + } + return Processed.Success; + }, + element => console.debug(`Processed success, `, element), + element => console.debug(`Processed failure, `, element), + (context, payload, message, type) => {}, 'default' ).then(processed => { console.log(`----------> Tasks then()`, processed); diff --git a/src/type/error-callback.type.ts b/src/type/error-callback.type.ts deleted file mode 100644 index cf58112..0000000 --- a/src/type/error-callback.type.ts +++ /dev/null @@ -1 +0,0 @@ -export type ErrorCallback = (element: Type, error: unknown) => void; diff --git a/src/type/index.ts b/src/type/index.ts deleted file mode 100644 index a4406d3..0000000 --- a/src/type/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { ErrorCallback } from './error-callback.type'; -export type { ProcessCallback } from './process-callback.type'; diff --git a/src/type/process-callback.type.ts b/src/type/process-callback.type.ts deleted file mode 100644 index 3dce4f4..0000000 --- a/src/type/process-callback.type.ts +++ /dev/null @@ -1 +0,0 @@ -export type ProcessCallback = (element: Type) => void | Promise;