fix(core): update

This commit is contained in:
Philipp Kunz 2023-08-02 00:07:21 +02:00
parent 493cd83dda
commit b5981d67cf
7 changed files with 1309 additions and 1055 deletions

View File

@ -30,20 +30,20 @@
"homepage": "https://gitlab.com/pushrocks/taskbuffer#readme", "homepage": "https://gitlab.com/pushrocks/taskbuffer#readme",
"dependencies": { "dependencies": {
"@push.rocks/isounique": "^1.0.5", "@push.rocks/isounique": "^1.0.5",
"@push.rocks/lik": "^6.0.0", "@push.rocks/lik": "^6.0.3",
"@push.rocks/smartdelay": "^3.0.5", "@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartlog": "^3.0.1", "@push.rocks/smartlog": "^3.0.3",
"@push.rocks/smartpromise": "^4.0.3", "@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartrx": "^3.0.0", "@push.rocks/smartrx": "^3.0.6",
"@push.rocks/smarttime": "^4.0.1" "@push.rocks/smarttime": "^4.0.4"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.63", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsbundle": "^2.0.6", "@gitzone/tsbundle": "^2.0.8",
"@gitzone/tsrun": "^1.2.39", "@gitzone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.72", "@gitzone/tstest": "^1.0.77",
"@push.rocks/tapbundle": "^5.0.4", "@push.rocks/tapbundle": "^5.0.12",
"@types/node": "^18.11.18" "@types/node": "^20.4.5"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

2306
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/taskbuffer', name: '@push.rocks/taskbuffer',
version: '3.0.11', version: '3.0.12',
description: 'flexible task management. TypeScript ready!' description: 'flexible task management. TypeScript ready!'
} }

View File

@ -2,8 +2,9 @@ import { Task } from './taskbuffer.classes.task.js';
export class BufferRunner { export class BufferRunner {
public task: Task; public task: Task;
// initialze by default // initialize by default
public bufferCounter: number = 0; public bufferCounter: number = 0;
constructor(taskArg: Task) { constructor(taskArg: Task) {
this.task = taskArg; this.task = taskArg;
} }
@ -13,7 +14,7 @@ export class BufferRunner {
this.bufferCounter++; this.bufferCounter++;
} }
const returnPromise: Promise<any> = this.task.cycleCounter.getPromiseForCycle( const returnPromise: Promise<any> = this.task.cycleCounter.getPromiseForCycle(
this.bufferCounter + 1 this.bufferCounter
); );
if (!this.task.running) { if (!this.task.running) {
this._run(x); this._run(x);
@ -21,19 +22,13 @@ export class BufferRunner {
return returnPromise; return returnPromise;
} }
private _run(x: any) { private async _run(x: any) {
const recursiveBufferRunner = (x: any) => {
if (this.bufferCounter >= 0) {
this.task.running = true; this.task.running = true;
Task.runTask(this.task, { x: x }).then((x) => { while (this.bufferCounter > 0) {
this.bufferCounter--; // this.bufferCounter drops below 0, the recursion stops. const result = await Task.runTask(this.task, { x: x });
this.task.cycleCounter.informOfCycle(x); this.bufferCounter--;
recursiveBufferRunner(x); this.task.cycleCounter.informOfCycle(result);
}); }
} else {
this.task.running = false; this.task.running = false;
} }
};
recursiveBufferRunner(x);
}
} }

View File

@ -1,6 +1,6 @@
import * as plugins from './taskbuffer.plugins.js'; import * as plugins from './taskbuffer.plugins.js';
import { Task, ITaskFunction } from './taskbuffer.classes.task.js'; import { Task, type ITaskFunction } from './taskbuffer.classes.task.js';
export class TaskDebounced<T = unknown> extends Task { export class TaskDebounced<T = unknown> extends Task {
private _debouncedTaskFunction: ITaskFunction; private _debouncedTaskFunction: ITaskFunction;

View File

@ -1,6 +1,6 @@
import * as plugins from './taskbuffer.plugins.js'; import * as plugins from './taskbuffer.plugins.js';
import { Task, ITaskFunction } from './taskbuffer.classes.task.js'; import { Task, type ITaskFunction } from './taskbuffer.classes.task.js';
/** /**
* TaskOnce is run exactly once, no matter how often it is triggered * TaskOnce is run exactly once, no matter how often it is triggered

View File

@ -5,6 +5,7 @@
"target": "ES2022", "target": "ES2022",
"module": "ES2022", "module": "ES2022",
"moduleResolution": "nodenext", "moduleResolution": "nodenext",
"esModuleInterop": true "esModuleInterop": true,
"verbatimModuleSyntax": true,
} }
} }