@cldmv/holdmytask 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hold-my-task.mjs
CHANGED
|
@@ -529,15 +529,47 @@ export class HoldMyTask extends EventEmitter {
|
|
|
529
529
|
item.reject = reject;
|
|
530
530
|
});
|
|
531
531
|
|
|
532
|
-
//
|
|
533
|
-
|
|
532
|
+
// Store promise reference on item so we can update properties when task completes
|
|
533
|
+
item.promise = promise;
|
|
534
|
+
|
|
535
|
+
// Attach task handle properties to the promise with cached fallback getters
|
|
534
536
|
Object.defineProperty(promise, "id", { value: id, enumerable: true });
|
|
535
537
|
Object.defineProperty(promise, "cancel", { value: (reason) => this.cancel(id, reason), enumerable: true });
|
|
536
|
-
Object.defineProperty(promise, "status", {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
538
|
+
Object.defineProperty(promise, "status", {
|
|
539
|
+
value: () => {
|
|
540
|
+
const currentItem = this.tasks.get(id);
|
|
541
|
+
return currentItem ? currentItem.status : (promise._status ?? "canceled");
|
|
542
|
+
},
|
|
543
|
+
enumerable: true
|
|
544
|
+
});
|
|
545
|
+
Object.defineProperty(promise, "startedAt", {
|
|
546
|
+
get: () => {
|
|
547
|
+
const currentItem = this.tasks.get(id);
|
|
548
|
+
return currentItem ? currentItem.startedAt : promise._startedAt;
|
|
549
|
+
},
|
|
550
|
+
enumerable: true
|
|
551
|
+
});
|
|
552
|
+
Object.defineProperty(promise, "finishedAt", {
|
|
553
|
+
get: () => {
|
|
554
|
+
const currentItem = this.tasks.get(id);
|
|
555
|
+
return currentItem ? currentItem.finishedAt : promise._finishedAt;
|
|
556
|
+
},
|
|
557
|
+
enumerable: true
|
|
558
|
+
});
|
|
559
|
+
Object.defineProperty(promise, "result", {
|
|
560
|
+
get: () => {
|
|
561
|
+
const currentItem = this.tasks.get(id);
|
|
562
|
+
return currentItem ? currentItem.result : promise._result;
|
|
563
|
+
},
|
|
564
|
+
enumerable: true
|
|
565
|
+
});
|
|
566
|
+
Object.defineProperty(promise, "error", {
|
|
567
|
+
get: () => {
|
|
568
|
+
const currentItem = this.tasks.get(id);
|
|
569
|
+
return currentItem ? currentItem.error : promise._error;
|
|
570
|
+
},
|
|
571
|
+
enumerable: true
|
|
572
|
+
});
|
|
541
573
|
|
|
542
574
|
return promise;
|
|
543
575
|
}
|
|
@@ -1088,14 +1120,29 @@ export class HoldMyTask extends EventEmitter {
|
|
|
1088
1120
|
item.reject = reject;
|
|
1089
1121
|
});
|
|
1090
1122
|
|
|
1123
|
+
// Store promise reference on item so we can update properties when task completes
|
|
1124
|
+
item.promise = promise;
|
|
1125
|
+
|
|
1091
1126
|
// Attach task handle properties to the promise
|
|
1092
1127
|
Object.defineProperty(promise, "id", { value: item.id, enumerable: true });
|
|
1093
1128
|
Object.defineProperty(promise, "cancel", { value: taskHandle.cancel, enumerable: true });
|
|
1094
1129
|
Object.defineProperty(promise, "status", { value: taskHandle.status, enumerable: true });
|
|
1095
|
-
Object.defineProperty(promise, "startedAt", {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1130
|
+
Object.defineProperty(promise, "startedAt", {
|
|
1131
|
+
get: () => (promise._startedAt !== undefined ? promise._startedAt : item.startedAt),
|
|
1132
|
+
enumerable: true
|
|
1133
|
+
});
|
|
1134
|
+
Object.defineProperty(promise, "finishedAt", {
|
|
1135
|
+
get: () => (promise._finishedAt !== undefined ? promise._finishedAt : item.finishedAt),
|
|
1136
|
+
enumerable: true
|
|
1137
|
+
});
|
|
1138
|
+
Object.defineProperty(promise, "result", {
|
|
1139
|
+
get: () => (promise._result !== undefined ? promise._result : item.result),
|
|
1140
|
+
enumerable: true
|
|
1141
|
+
});
|
|
1142
|
+
Object.defineProperty(promise, "error", {
|
|
1143
|
+
get: () => (promise._error !== undefined ? promise._error : item.error),
|
|
1144
|
+
enumerable: true
|
|
1145
|
+
});
|
|
1099
1146
|
|
|
1100
1147
|
return promise;
|
|
1101
1148
|
}
|
|
@@ -1523,6 +1570,16 @@ export class HoldMyTask extends EventEmitter {
|
|
|
1523
1570
|
|
|
1524
1571
|
this.emit("success", item);
|
|
1525
1572
|
|
|
1573
|
+
// Store final values on promise handle before resolving (for promise API)
|
|
1574
|
+
if (item.promise) {
|
|
1575
|
+
// Store final values so getters can access them after task deletion
|
|
1576
|
+
item.promise._result = item.result;
|
|
1577
|
+
item.promise._error = item.error;
|
|
1578
|
+
item.promise._startedAt = item.startedAt;
|
|
1579
|
+
item.promise._finishedAt = item.finishedAt;
|
|
1580
|
+
item.promise._status = item.status;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1526
1583
|
// Call completion callback or resolve promise
|
|
1527
1584
|
if (item.callback) {
|
|
1528
1585
|
try {
|
|
@@ -1548,6 +1605,16 @@ export class HoldMyTask extends EventEmitter {
|
|
|
1548
1605
|
this.emit("error", item);
|
|
1549
1606
|
}
|
|
1550
1607
|
|
|
1608
|
+
// Store final values on promise handle before rejecting (for promise API)
|
|
1609
|
+
if (item.promise) {
|
|
1610
|
+
// Store final values so getters can access them after task deletion
|
|
1611
|
+
item.promise._result = item.result;
|
|
1612
|
+
item.promise._error = item.error;
|
|
1613
|
+
item.promise._startedAt = item.startedAt;
|
|
1614
|
+
item.promise._finishedAt = item.finishedAt;
|
|
1615
|
+
item.promise._status = item.status;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1551
1618
|
// Call completion callback or reject promise
|
|
1552
1619
|
if (item.callback) {
|
|
1553
1620
|
try {
|
|
@@ -1572,9 +1639,9 @@ export class HoldMyTask extends EventEmitter {
|
|
|
1572
1639
|
}
|
|
1573
1640
|
|
|
1574
1641
|
this.running.delete(item);
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1642
|
+
|
|
1643
|
+
// Clean up all finished tasks (completed, failed, canceled)
|
|
1644
|
+
this.tasks.delete(item.id);
|
|
1578
1645
|
|
|
1579
1646
|
// Update delay tracking after task completion
|
|
1580
1647
|
const completedPriority = item.priority;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hold-my-task.d.mts","sourceRoot":"","sources":["../../dist/hold-my-task.mjs"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6DG;IAEH;;;;;;;;OAQG;IACH,yCAwCC;IAwND;;;;;;;;;OASG;IACH,uBAGC;IAnOD,0BAaC;IAED;;;;OAIG;IACH,wBAGC;IAFA,mBAAqB;IAItB;;;;;OAKG;IACH,yBAUC;IAED;;;;OAIG;IACH,0BAoKC;IA1DA,aAuBC;IAGD,qBAA+D;IAC/D,mBAIE;IAEF,kBAAwB;IACxB,qBAAsB;IACtB,eAAe;IACf,mBAAmB;IACnB,kBAAqB;IACrB,mBAAsB;IACtB,2BAAiC;IACjC,uBAA0B;IAG1B,iCAA4B;IAC5B,gCAA2B;IAC3B,yBAAyB;IAGzB,2BAAsB;IAGtB,gCAAiC;IACjC,yCAA0C;IAC1C,oBAAoB;IAsBrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,4CA1CW,cAAe,YAEvB;QAAgC,EAAE,GAA1B,MAAM,GAAC,MAAM;QACI,QAAQ,GAAzB,MAAM;QACW,SAAS,GAA1B,MAAM;QACW,KAAK,GAAtB,MAAM;QACgB,MAAM,GAA5B,WAAW;QACM,OAAO,GAAxB,MAAM;QACW,MAAM,GAAvB,MAAM;QACW,KAAK,GAAtB,MAAM;QACY,WAAW,GAA7B,OAAO;QACU,aAAa,GAA9B,MAAM;QACW,wBAAwB,GAAzC,MAAM;QACW,kBAAkB,GAAnC,MAAM;QACY,2BAA2B,GAA7C,OAAO;QACW,4BAA4B,GAA9C,OAAO;QACK,QAAQ,GAApB,GAAC;KACT,GAAU,kBAAc,CA+
|
|
1
|
+
{"version":3,"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