@nerjs/batchloader
Version:
`BatchLoader` is a tool for batching data requests with support for deduplication, caching, and parallel task management. It is designed to enhance flexibility and performance in scenarios requiring asynchronous data processing. This module was inspired b
41 lines • 1 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Task = exports.InnerTask = void 0;
const defer_1 = require("../utils/defer");
const string_1 = require("../utils/string");
class InnerTask {
#data;
get data() {
return this.#data;
}
constructor(data, task) {
this.task = task;
this.#data = data;
}
get id() {
return this.task.id;
}
get status() {
return this.task.status;
}
get runnedAt() {
return this.task.runnedAt;
}
get createdAt() {
return this.task.createdAt;
}
}
exports.InnerTask = InnerTask;
class Task {
constructor(data) {
this.status = 'pending';
this.createdAt = Date.now();
this.runnedAt = null;
this.defer = new defer_1.Defer();
this.tid = null;
this.id = (0, string_1.randomString)();
this.inner = new InnerTask(data, this);
}
}
exports.Task = Task;
//# sourceMappingURL=task.js.map