UNPKG

async-scheduler

Version:

![CI](https://github.com/kremi151/async-scheduler/workflows/CI/badge.svg) ![NPM](https://img.shields.io/npm/v/async-scheduler?color=green)

42 lines (41 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Builder { constructor(task, scheduler) { this._meta = undefined; this._task = task; this._scheduler = scheduler; } withDescriptor(descriptor) { this._descriptor = descriptor; return this; } withMutex(mutex) { this._mutex = mutex; return this; } withMeta(meta) { this._meta = meta; return this; } runBeforeExecuting(what) { this._onPreExecute = what; return this; } handleCollisions(handler) { this._onTaskCollision = handler; return this; } execute(priority) { return this._scheduler.enqueue({ priority: priority, mutex: this._mutex, descriptor: this._descriptor, meta: this._meta, execute: this._task, onPreExecute: this._onPreExecute, onTaskCollision: this._onTaskCollision, }); } } exports.default = Builder;