datainout
Version:
Import and reports data
83 lines (81 loc) • 2.35 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/common/core/QueueData.ts
var QueueData_exports = {};
__export(QueueData_exports, {
QueueData: () => QueueData
});
module.exports = __toCommonJS(QueueData_exports);
var QueueData = class {
constructor(size = 50) {
this.cells = [];
this.resolveFunc = () => {
};
this.size = size;
this.waitingFunc = this.createWaiter();
}
createWaiter() {
return new Promise((resolve) => {
this.resolveFunc = resolve;
});
}
waiting() {
return __async(this, null, function* () {
if (this.cells.length < this.size) return;
yield this.waitingFunc;
});
}
shift() {
const data = this.cells.shift();
if (this.cells.length === this.size - 1) {
this.resolveFunc();
}
return data;
}
add(data) {
this.cells.push(data);
if (this.cells.length === this.size) {
this.waitingFunc = this.createWaiter();
}
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
QueueData
});