more-proms 1.9.2 → 1.9.3

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.
@@ -106,6 +106,7 @@ function execQueue(defaultOptions = {
106
106
  const ob = { f, p, skipAble: options.skipAble, cancelVal: options.cancelVal };
107
107
  queue.push(ob);
108
108
  if (cancelPrevIfPossible && running) {
109
+ // todo is this max even needed? Is ob not always the latests here?...
109
110
  wantToCancelUntil = wantToCancelUntil === undefined ? ob : queue[Math.max(queue.indexOf(wantToCancelUntil), queue.indexOf(ob))];
110
111
  if ("cancel" in curFP)
111
112
  curFP.cancel(curCancelVal);
@@ -247,6 +248,10 @@ function mkExt(Prom) {
247
248
  constructor(executor) {
248
249
  let res;
249
250
  let rej;
251
+ let resSettled;
252
+ const onSettled = new Prom((res) => {
253
+ resSettled = res;
254
+ });
250
255
  super((r, rj) => {
251
256
  res = r;
252
257
  rej = rj;
@@ -270,10 +275,7 @@ function mkExt(Prom) {
270
275
  this.settled = false;
271
276
  this.res = res;
272
277
  this.rej = rej;
273
- let resSettled;
274
- this.onSettled = new Prom((res) => {
275
- resSettled = res;
276
- });
278
+ this.onSettled = onSettled;
277
279
  }
278
280
  }
279
281
  class ResablePromise extends SettledPromise {
@@ -284,11 +286,15 @@ function mkExt(Prom) {
284
286
  }
285
287
  class CancelAblePromise extends SettledPromise {
286
288
  constructor(executor, cancelFunc) {
287
- super(executor);
288
- this.cancelFunc = cancelFunc;
289
+ super((res, rej) => {
290
+ const r = executor(res, rej);
291
+ if (cancelFunc === undefined)
292
+ cancelFunc = r;
293
+ });
289
294
  this.cancelled = false;
290
295
  this.onCancel = new ResablePromise(() => { });
291
296
  this.nestedCancels = [];
297
+ this.cancelFunc = cancelFunc;
292
298
  this.cancel = keyIndex.memoize((reason) => {
293
299
  if (this.settled)
294
300
  return;
@@ -103,6 +103,7 @@ export function execQueue(defaultOptions = {
103
103
  const ob = { f, p, skipAble: options.skipAble, cancelVal: options.cancelVal };
104
104
  queue.push(ob);
105
105
  if (cancelPrevIfPossible && running) {
106
+ // todo is this max even needed? Is ob not always the latests here?...
106
107
  wantToCancelUntil = wantToCancelUntil === undefined ? ob : queue[Math.max(queue.indexOf(wantToCancelUntil), queue.indexOf(ob))];
107
108
  if ("cancel" in curFP)
108
109
  curFP.cancel(curCancelVal);
@@ -245,6 +246,10 @@ function mkExt(Prom) {
245
246
  constructor(executor) {
246
247
  let res;
247
248
  let rej;
249
+ let resSettled;
250
+ const onSettled = new Prom((res) => {
251
+ resSettled = res;
252
+ });
248
253
  super(!finallyInit ? (r, rj) => {
249
254
  res = r;
250
255
  rej = rj;
@@ -268,10 +273,7 @@ function mkExt(Prom) {
268
273
  this.settled = false;
269
274
  this.res = res;
270
275
  this.rej = rej;
271
- let resSettled;
272
- this.onSettled = new Prom((res) => {
273
- resSettled = res;
274
- });
276
+ this.onSettled = onSettled;
275
277
  }
276
278
  }
277
279
  class ResablePromise extends SettledPromise {
@@ -282,11 +284,15 @@ function mkExt(Prom) {
282
284
  }
283
285
  class CancelAblePromise extends SettledPromise {
284
286
  constructor(executor, cancelFunc) {
285
- super(executor);
286
- this.cancelFunc = cancelFunc;
287
+ super((res, rej) => {
288
+ const r = executor(res, rej);
289
+ if (cancelFunc === undefined)
290
+ cancelFunc = r;
291
+ });
287
292
  this.cancelled = false;
288
293
  this.onCancel = new ResablePromise(() => { });
289
294
  this.nestedCancels = [];
295
+ this.cancelFunc = cancelFunc;
290
296
  this.cancel = memoize((reason) => {
291
297
  if (this.settled)
292
298
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "more-proms",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "description": "A collection of additional promise extending classes. Including a (from the outside) ResablePromise, CancelAblePromise and a latestLatent utility function.",
5
5
  "main": "./app/dist/esm/moreProms.mjs",
6
6
  "types": "./app/dist/esm/moreProms.d.ts",