You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@leafer/task

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leafer/task - npm Package Compare versions

Comparing version
1.0.0-beta.9
to
1.0.0-beta.10
+4
-4
package.json
{
"name": "@leafer/task",
"version": "1.0.0-beta.9",
"version": "1.0.0-beta.10",
"description": "@leafer/task",

@@ -22,8 +22,8 @@ "author": "Chao (Leafer) Wan",

"dependencies": {
"@leafer/math": "1.0.0-beta.9",
"@leafer/debug": "1.0.0-beta.9"
"@leafer/math": "1.0.0-beta.10",
"@leafer/debug": "1.0.0-beta.10"
},
"devDependencies": {
"@leafer/interface": "1.0.0-beta.9"
"@leafer/interface": "1.0.0-beta.10"
}
}
import { IFunction } from '@leafer/interface'
import { IncrementId } from '@leafer/math'
import { Debug } from '@leafer/debug'

@@ -7,2 +8,3 @@ import { TaskProcessor } from './TaskProcessor'

const debug = Debug.get('TaskProcessor')
export class TaskItem {

@@ -27,4 +29,6 @@

async run(): Promise<void> {
if (this.task && !this.isComplete && this.parent.running) {
await this.task()
try {
if (this.task && !this.isComplete && this.parent.running) await this.task()
} catch (error) {
debug.error(error)
}

@@ -31,0 +35,0 @@ }

import { IFunction, ITaskProcessor, ITaskProcessorConfig } from '@leafer/interface'
import { DataHelper } from '@leafer/data'
import { Debug } from '@leafer/debug'

@@ -8,4 +7,2 @@ import { TaskItem } from './TaskItem'

const debug = Debug.get('TaskProcessor')
export class TaskProcessor implements ITaskProcessor {

@@ -110,10 +107,10 @@

public add(taskCallback: IFunction, taskTime?: number): void {
this.push(new TaskItem(taskCallback), taskTime)
public add(taskCallback: IFunction, taskTime?: number, start?: boolean,): void {
this.push(new TaskItem(taskCallback), taskTime, start)
}
public addParallel(taskCallback: IFunction, taskTime?: number): void {
public addParallel(taskCallback: IFunction, taskTime?: number, start?: boolean): void {
const task = new TaskItem(taskCallback)
task.parallel = true
this.push(task, taskTime)
this.push(task, taskTime, start)
}

@@ -125,6 +122,7 @@

private push(task: TaskItem, taskTime?: number): void {
private push(task: TaskItem, taskTime?: number, start?: boolean): void {
if (taskTime) task.taskTime = taskTime
task.parent = this
this.list.push(task)
if (start && !this.running) this.start()
}

@@ -259,3 +257,2 @@

private onParallelError(error: unknown): void {
debug.error('ParallelError')

@@ -262,0 +259,0 @@ // 并行变串行, 以便下次重试