@ndriadev/futurable 2.1.2 → 2.2.0

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/README.md CHANGED
@@ -41,7 +41,7 @@
41
41
  - [Futurable.any](#futurableanyvalues-t-signal-abortsignal)
42
42
  - [Futurable.race](#futurableracevalues-t-signal-abortsignal)
43
43
  - [Futurable.polling](#futurablepollingvalue--futurable--interval-signal-interval-number-signal-abortsignal)
44
- - [Futurable.builder](#futurablebuildersignal-abortsignal)
44
+ - [Futurable.withResolvers](#futurablewithresolverssignal-abortsignal)
45
45
  - [ToDo](#TODO)
46
46
  - [License](#License)
47
47
 
@@ -137,7 +137,7 @@ They are the following:
137
137
  - [Futurable.any](#futurableanyvalues-t-signal-abortsignal)
138
138
  - [Futurable.race](#futurableracevalues-t-signal-abortsignal)
139
139
  - [Futurable.polling](#futurablepollingvalue--futurable--interval-signal-interval-number-signal-abortsignal)
140
- - [Futurable.builder](#futurablebuildersignal-abortsignal)
140
+ - [Futurable.withResolvers](#futurablewithresolverssignal-abortsignal)
141
141
 
142
142
  ### constructor(executor: FuturableExecutor<T>, signal?: AbortSignal)
143
143
  Futurable is instantiable like a classic Promise.
@@ -359,7 +359,7 @@ async function op() {
359
359
  ```
360
360
  --->
361
361
  ### futurizable(promise: Promise | (val => Promise))
362
- Takes a promise and transforms it into a futurizable. Promise can be also a function that receives value from futurable chaining as parameter.
362
+ Takes a promise and transforms it into a futurable. Promise can be also a function that receives value from futurable chaining as parameter.
363
363
 
364
364
  *Example*
365
365
  ```javascript
@@ -466,7 +466,7 @@ Futurable.futurizable({promise: /*promise to futurizable*/, signal: controller.s
466
466
  ```
467
467
 
468
468
  ### Futurable.all(values: T, signal?: AbortSignal)
469
- Extension of the static method all with cancellation support.
469
+ Extension of the static method _all_ with cancellation support.
470
470
 
471
471
  *Example*
472
472
  ```javascript
@@ -498,7 +498,7 @@ f.cancel();
498
498
  ```
499
499
 
500
500
  ### Futurable.allSettled(values: T, signal?: AbortSignal)
501
- Extension of the static method allSettled with cancellation support.
501
+ Extension of the static method _allSettled_ with cancellation support.
502
502
 
503
503
  *Example*
504
504
  ```javascript
@@ -530,7 +530,7 @@ f.cancel();
530
530
  ```
531
531
 
532
532
  ### Futurable.any(values: T, signal?: AbortSignal)
533
- Extension of the static method any with cancellation support.
533
+ Extension of the static method _any_ with cancellation support.
534
534
 
535
535
  *Example*
536
536
  ```javascript
@@ -561,7 +561,7 @@ f.cancel();
561
561
  ```
562
562
 
563
563
  ### Futurable.race(values: T, signal?: AbortSignal)
564
- Extension of the static method race with cancellation support.
564
+ Extension of the static method _race_ with cancellation support.
565
565
 
566
566
  *Example*
567
567
  ```javascript
@@ -605,24 +605,20 @@ polling.catch(err => console.error(err));
605
605
  polling.cancel();
606
606
  ```
607
607
 
608
- ### Futurable.builder<T>(signal?: AbortSignal)
609
- Creates an object with:
610
- - _build_: function to create a Futurable.
611
- - _resolve_: function to resolve the Futurable created.
612
- - _reject_: function to reject the Futurable created.
613
- - _utils_: object that reflects __utils__ object of Futurabled created.
608
+ ### Futurable.withResolvers<T>(signal?: AbortSignal)
609
+ Extension of static method _withResolvers_ with support of _cancel_ function and _utils_ object of Futurable.
614
610
 
615
611
  *Example*
616
612
  ```javascript
617
613
  //...code
618
- const future = Futurable.buider();
614
+ const {futurable, resolve, reject} = Futurable.withResolvers();
619
615
 
620
616
  //...code
621
617
 
622
- await future.build();
618
+ const result = await futurable;
623
619
 
624
620
  //...code
625
- future.resolve("resolved");
621
+ resolve("resolved");
626
622
  ```
627
623
 
628
624
  # ToDo
@@ -1 +1 @@
1
- "use strict";var T=Object.defineProperty;var C=(w,g,t)=>g in w?T(w,g,{enumerable:!0,configurable:!0,writable:!0,value:t}):w[g]=t;var S=(w,g,t)=>(C(w,typeof g!="symbol"?g+"":g,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i extends Promise{constructor(t,e){const r=e?null:new AbortController,n=e||r.signal,l=[],c=()=>{for(const a of l)clearTimeout(a)};let o;const h={signal:n,cancel:()=>{var a;return(a=this.controller)==null?void 0:a.abort()},onCancel:a=>{o=a},delay:(a,u)=>new i(d=>{l.push(setTimeout(()=>{d(a())},u))},n),sleep:a=>h.delay(()=>{},a),fetch:(a,u)=>new i((d,p)=>{fetch(a,{...u||{},signal:n}).then(y=>d(y)).catch(y=>{y.name!=="AbortError"&&p(y)})},n),futurizable:a=>new i((u,d)=>{a.then(u).catch(d)},n)};let f="pending";const m=new Promise((a,u)=>{if(n.aborted){c(),f==="pending"&&o&&o();return}else{const d=typeof n.onabort=="function"?n.onabort:()=>{};n.onabort=()=>{d(),c(),f==="pending"&&o&&o()},t(j=>{f="fulfilled",a(j)},j=>{f="rejected",u(j)},h)}});super((a,u)=>{m.then(d=>a(d)).catch(u)});S(this,"controller");S(this,"internalSignal");S(this,"idsTimeout");this.controller=r,this.internalSignal=n,this.idsTimeout=l}static get[Symbol.species](){return this}get[Symbol.toStringTag](){return"Futurable"}get signal(){return this.internalSignal}clearTimeout(){for(const t of this.idsTimeout)clearTimeout(t)}then(t,e){let r,n;const l=new i((c,o)=>{r=c,n=o},this.internalSignal);return l.controller=this.controller,super.then(c=>{var o;if((o=this.internalSignal)!=null&&o.aborted){this.clearTimeout();return}try{r(t?t(c):c)}catch(s){n(s)}},c=>{var o;if((o=this.internalSignal)!=null&&o.aborted){this.clearTimeout();return}try{e?r(e(c)):n(c)}catch(s){n(s)}}),l}catch(t){return this.then(null,t)}finally(t){return this.then(e=>(t(),e),e=>{if(t(),e instanceof Error)throw e;return e})}cancel(){var t,e;!((t=this.internalSignal)!=null&&t.aborted)&&((e=this.controller)==null||e.abort())}delay(t,e){let r,n;const l=new i((c,o)=>{r=c,n=o},this.internalSignal);return l.controller=this.controller,this.then(c=>{this.idsTimeout.push(setTimeout(()=>r(t(c)),e))},c=>{n(c)}),l}sleep(t){return this.delay(e=>e,t)}fetch(t,e){let r,n;const l=new i((c,o)=>{r=c,n=o},this.internalSignal);return l.controller=this.controller,this.then(c=>{const o=typeof t=="function"?t(c):t,s={...typeof e=="function"?e(c):e,signal:this.internalSignal};fetch(o,s).then(h=>r(h)).catch(h=>{h.name!=="AbortError"&&n(h)})}),l}onCancel(t){let e,r;const n=new i((l,c,o)=>{o.onCancel(t),e=l,r=c},this.internalSignal);return n.controller=this.controller,this.then(l=>e(l),l=>r(l)),n}futurizable(t){let e,r;const n=new i((l,c)=>{e=l,r=c},this.internalSignal);return n.controller=this.controller,this.then(l=>{(typeof t=="function"?t(l):t).then(e).catch(r)}),n}static resolve(t,e){return t?new i(r=>r(t),e):new i(r=>r(),e)}static reject(t,e){return new i((r,n)=>n(t),e)}static onCancel({cb:t,signal:e}){return new i((r,n,l)=>{l.onCancel(()=>r(t()))},e)}static delay({cb:t,timer:e,signal:r}){return new i((n,l,c)=>{c.delay(t,e).then(n,l)},r)}static sleep({timer:t,signal:e}){return i.delay({cb:()=>{},timer:t,signal:e})}static fetch(t,e){const r=(e==null?void 0:e.signal)||void 0;return e!=null&&e.signal&&delete e.signal,new i((n,l,c)=>{c.fetch(t,e).then(n)},r)}static futurizable({promise:t,signal:e}){return new i((r,n)=>{t.then(r).catch(n)},e)}static handleValues(t,e){const r=[];for(const n in t)t[n]instanceof i?r.push(t[n]):t[n]instanceof Promise?r.push(new i((l,c)=>{t[n].then(o=>l(o)).catch(c)},e)):r.push(new i(l=>l(t[n]),e));return r}static all(t,e){let r,n;const l=new i((o,s,h)=>{r=o,n=s,h.onCancel(()=>{for(const f of c)f.cancel()})},e);e||(e=l.internalSignal);const c=i.handleValues(t,e);return super.all(c).then(o=>r(o)).catch(o=>n(o)),l}static allSettled(t,e){let r;const n=new i((c,o,s)=>{r=c,s.onCancel(()=>{for(const h of l)h.cancel()})},e);e||(e=n.internalSignal);const l=i.handleValues(t,e);return super.allSettled(l).then(c=>r(c)),n}static race(t,e){let r,n;const l=new i((o,s,h)=>{r=o,n=s,h.onCancel(()=>{for(const f of c)f.cancel()})},e);e||(e=l.internalSignal);const c=i.handleValues(t,e);return super.race(c).then(o=>r(o)).catch(o=>n(o)),l}static any(t,e){let r,n;const l=new i((o,s,h)=>{r=o,n=s,h.onCancel(()=>{for(const f of c)f.cancel()})},e);e||(e=l.internalSignal);const c=i.handleValues(t,e);return super.any(c).then(o=>r(o)).catch(o=>n(o)),l}static polling(t,{interval:e,signal:r}){let n,l,c;const o=setInterval(()=>{n&&n.cancel(),n=new i((s,h,f)=>{f.onCancel(()=>{l&&l.cancel()}),l=t().then(()=>s()).catch(m=>c&&c(m))},r)},e);return{cancel:()=>{o&&clearInterval(o),n&&n.cancel()},catch:s=>{c=s}}}static builder(t){return{resolve:null,reject:null,utils:null,build(){return new i((e,r,n)=>{this.resolve=e,this.reject=r,this.utils=n},t)}}}}exports.Futurable=i;
1
+ "use strict";var T=Object.defineProperty;var C=(g,w,t)=>w in g?T(g,w,{enumerable:!0,configurable:!0,writable:!0,value:t}):g[w]=t;var S=(g,w,t)=>(C(g,typeof w!="symbol"?w+"":w,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i extends Promise{constructor(t,e){const r=e?null:new AbortController,n=e||r.signal,o=[],c=()=>{for(const h of o)clearTimeout(h)};let l;const a={signal:n,cancel:()=>{var h;return(h=this.controller)==null?void 0:h.abort()},onCancel:h=>{l=h},delay:(h,u)=>new i(d=>{o.push(setTimeout(()=>{d(h())},u))},n),sleep:h=>a.delay(()=>{},h),fetch:(h,u)=>new i((d,p)=>{fetch(h,{...u||{},signal:n}).then(y=>d(y)).catch(y=>{y.name!=="AbortError"&&p(y)})},n),futurizable:h=>new i((u,d)=>{h.then(u).catch(d)},n)};let f="pending";const m=new Promise((h,u)=>{if(n.aborted){c();return}else{const d=typeof n.onabort=="function"?n.onabort:()=>{};n.onabort=()=>{d(),c(),f==="pending"&&l&&l()},t(j=>{f="fulfilled",h(j)},j=>{f="rejected",u(j)},a)}});super((h,u)=>{m.then(d=>h(d)).catch(u)});S(this,"controller");S(this,"internalSignal");S(this,"idsTimeout");this.controller=r,this.internalSignal=n,this.idsTimeout=o}static get[Symbol.species](){return this}get[Symbol.toStringTag](){return"Futurable"}get signal(){return this.internalSignal}clearTimeout(){for(const t of this.idsTimeout)clearTimeout(t)}then(t,e){let r,n;const o=new i((c,l)=>{r=c,n=l},this.internalSignal);return o.controller=this.controller,super.then(c=>{var l;if((l=this.internalSignal)!=null&&l.aborted){this.clearTimeout();return}try{r(t?t(c):c)}catch(s){n(s)}},c=>{var l;if((l=this.internalSignal)!=null&&l.aborted){this.clearTimeout();return}try{e?r(e(c)):n(c)}catch(s){n(s)}}),o}catch(t){return this.then(null,t)}finally(t){return this.then(e=>(t(),e),e=>{if(t(),e instanceof Error)throw e;return e})}cancel(){var t,e;!((t=this.internalSignal)!=null&&t.aborted)&&((e=this.controller)==null||e.abort())}delay(t,e){let r,n;const o=new i((c,l)=>{r=c,n=l},this.internalSignal);return o.controller=this.controller,this.then(c=>{this.idsTimeout.push(setTimeout(()=>r(t(c)),e))},c=>{n(c)}),o}sleep(t){return this.delay(e=>e,t)}fetch(t,e){let r,n;const o=new i((c,l)=>{r=c,n=l},this.internalSignal);return o.controller=this.controller,this.then(c=>{const l=typeof t=="function"?t(c):t,s={...typeof e=="function"?e(c):e,signal:this.internalSignal};fetch(l,s).then(a=>r(a)).catch(a=>{a.name!=="AbortError"&&n(a)})}),o}onCancel(t){let e,r;const n=new i((o,c,l)=>{l.onCancel(t),e=o,r=c},this.internalSignal);return n.controller=this.controller,this.then(o=>e(o),o=>r(o)),n}futurizable(t){let e,r;const n=new i((o,c)=>{e=o,r=c},this.internalSignal);return n.controller=this.controller,this.then(o=>{(typeof t=="function"?t(o):t).then(e).catch(r)}),n}static resolve(t,e){return t?new i(r=>r(t),e):new i(r=>r(),e)}static reject(t,e){return new i((r,n)=>n(t),e)}static onCancel({cb:t,signal:e}){return new i((r,n,o)=>{o.onCancel(()=>r(t()))},e)}static delay({cb:t,timer:e,signal:r}){return new i((n,o,c)=>{c.delay(t,e).then(n,o)},r)}static sleep({timer:t,signal:e}){return i.delay({cb:()=>{},timer:t,signal:e})}static fetch(t,e){const r=(e==null?void 0:e.signal)||void 0;return e!=null&&e.signal&&delete e.signal,new i((n,o,c)=>{c.fetch(t,e).then(n)},r)}static futurizable({promise:t,signal:e}){return new i((r,n)=>{t.then(r).catch(n)},e)}static handleValues(t,e){const r=[];for(const n in t)t[n]instanceof i?r.push(t[n]):t[n]instanceof Promise?r.push(new i((o,c)=>{t[n].then(l=>o(l)).catch(c)},e)):r.push(new i(o=>o(t[n]),e));return r}static all(t,e){let r,n;const o=new i((l,s,a)=>{r=l,n=s,a.onCancel(()=>{for(const f of c)f.cancel()})},e);e||(e=o.internalSignal);const c=i.handleValues(t,e);return super.all(c).then(l=>r(l)).catch(l=>n(l)),o}static allSettled(t,e){let r;const n=new i((c,l,s)=>{r=c,s.onCancel(()=>{for(const a of o)a.cancel()})},e);e||(e=n.internalSignal);const o=i.handleValues(t,e);return super.allSettled(o).then(c=>r(c)),n}static race(t,e){let r,n;const o=new i((l,s,a)=>{r=l,n=s,a.onCancel(()=>{for(const f of c)f.cancel()})},e);e||(e=o.internalSignal);const c=i.handleValues(t,e);return super.race(c).then(l=>r(l)).catch(l=>n(l)),o}static any(t,e){let r,n;const o=new i((l,s,a)=>{r=l,n=s,a.onCancel(()=>{for(const f of c)f.cancel()})},e);e||(e=o.internalSignal);const c=i.handleValues(t,e);return super.any(c).then(l=>r(l)).catch(l=>n(l)),o}static polling(t,{interval:e,signal:r}){let n,o,c;const l=setInterval(()=>{n&&n.cancel(),n=new i((s,a,f)=>{f.onCancel(()=>{o&&o.cancel()}),o=t().then(()=>s()).catch(m=>c&&c(m))},r)},e);return{cancel:()=>{l&&clearInterval(l),n&&n.cancel()},catch:s=>{c=s}}}static withResolvers(t){let e,r,n;const o=new i((l,s,a)=>{e=l,r=s,n=a},t),c=o.cancel;return{resolve:e,reject:r,utils:n,cancel:c,promise:o}}}exports.Futurable=i;
@@ -1,62 +1,62 @@
1
1
  var T = Object.defineProperty;
2
2
  var C = (g, w, t) => w in g ? T(g, w, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[w] = t;
3
- var S = (g, w, t) => (C(g, typeof w != "symbol" ? w + "" : w, t), t);
3
+ var m = (g, w, t) => (C(g, typeof w != "symbol" ? w + "" : w, t), t);
4
4
  class i extends Promise {
5
5
  constructor(t, e) {
6
- const r = e ? null : new AbortController(), n = e || r.signal, l = [], c = () => {
7
- for (const a of l)
8
- clearTimeout(a);
6
+ const r = e ? null : new AbortController(), n = e || r.signal, o = [], c = () => {
7
+ for (const h of o)
8
+ clearTimeout(h);
9
9
  };
10
- let o;
11
- const h = {
10
+ let l;
11
+ const a = {
12
12
  signal: n,
13
13
  cancel: () => {
14
- var a;
15
- return (a = this.controller) == null ? void 0 : a.abort();
14
+ var h;
15
+ return (h = this.controller) == null ? void 0 : h.abort();
16
16
  },
17
- onCancel: (a) => {
18
- o = a;
17
+ onCancel: (h) => {
18
+ l = h;
19
19
  },
20
- delay: (a, u) => new i((d) => {
21
- l.push(setTimeout(() => {
22
- d(a());
20
+ delay: (h, u) => new i((d) => {
21
+ o.push(setTimeout(() => {
22
+ d(h());
23
23
  }, u));
24
24
  }, n),
25
- sleep: (a) => h.delay(() => {
26
- }, a),
27
- fetch: (a, u) => new i((d, p) => {
28
- fetch(a, { ...u || {}, signal: n }).then((y) => d(y)).catch((y) => {
25
+ sleep: (h) => a.delay(() => {
26
+ }, h),
27
+ fetch: (h, u) => new i((d, p) => {
28
+ fetch(h, { ...u || {}, signal: n }).then((y) => d(y)).catch((y) => {
29
29
  y.name !== "AbortError" && p(y);
30
30
  });
31
31
  }, n),
32
- futurizable: (a) => new i((u, d) => {
33
- a.then(u).catch(d);
32
+ futurizable: (h) => new i((u, d) => {
33
+ h.then(u).catch(d);
34
34
  }, n)
35
35
  };
36
36
  let f = "pending";
37
- const m = new Promise((a, u) => {
37
+ const S = new Promise((h, u) => {
38
38
  if (n.aborted) {
39
- c(), f === "pending" && o && o();
39
+ c();
40
40
  return;
41
41
  } else {
42
42
  const d = typeof n.onabort == "function" ? n.onabort : () => {
43
43
  };
44
44
  n.onabort = () => {
45
- d(), c(), f === "pending" && o && o();
45
+ d(), c(), f === "pending" && l && l();
46
46
  }, t((j) => {
47
- f = "fulfilled", a(j);
47
+ f = "fulfilled", h(j);
48
48
  }, (j) => {
49
49
  f = "rejected", u(j);
50
- }, h);
50
+ }, a);
51
51
  }
52
52
  });
53
- super((a, u) => {
54
- m.then((d) => a(d)).catch(u);
53
+ super((h, u) => {
54
+ S.then((d) => h(d)).catch(u);
55
55
  });
56
- S(this, "controller");
57
- S(this, "internalSignal");
58
- S(this, "idsTimeout");
59
- this.controller = r, this.internalSignal = n, this.idsTimeout = l;
56
+ m(this, "controller");
57
+ m(this, "internalSignal");
58
+ m(this, "idsTimeout");
59
+ this.controller = r, this.internalSignal = n, this.idsTimeout = o;
60
60
  }
61
61
  static get [Symbol.species]() {
62
62
  return this;
@@ -66,6 +66,7 @@ class i extends Promise {
66
66
  }
67
67
  /**
68
68
  * Return internal futurable signal
69
+ * @returns {AbortSignal}
69
70
  */
70
71
  get signal() {
71
72
  return this.internalSignal;
@@ -76,15 +77,18 @@ class i extends Promise {
76
77
  }
77
78
  /**
78
79
  * Attaches callbacks for the resolution and/or rejection of the Futurable.
80
+ * @param {((value: T) => TResult1 | PromiseLike<TResult1> | FuturableLike<TResult1>) | undefined | null} onfulfilled
81
+ * @param {((reason: any) => TResult2 | PromiseLike<TResult2> | FuturableLike<TResult2>) | undefined | null} onrejected
82
+ * @returns {Futurable<TResult1 | TResult2>}
79
83
  */
80
84
  then(t, e) {
81
85
  let r, n;
82
- const l = new i((c, o) => {
83
- r = c, n = o;
86
+ const o = new i((c, l) => {
87
+ r = c, n = l;
84
88
  }, this.internalSignal);
85
- return l.controller = this.controller, super.then((c) => {
86
- var o;
87
- if ((o = this.internalSignal) != null && o.aborted) {
89
+ return o.controller = this.controller, super.then((c) => {
90
+ var l;
91
+ if ((l = this.internalSignal) != null && l.aborted) {
88
92
  this.clearTimeout();
89
93
  return;
90
94
  }
@@ -94,8 +98,8 @@ class i extends Promise {
94
98
  n(s);
95
99
  }
96
100
  }, (c) => {
97
- var o;
98
- if ((o = this.internalSignal) != null && o.aborted) {
101
+ var l;
102
+ if ((l = this.internalSignal) != null && l.aborted) {
99
103
  this.clearTimeout();
100
104
  return;
101
105
  }
@@ -104,10 +108,12 @@ class i extends Promise {
104
108
  } catch (s) {
105
109
  n(s);
106
110
  }
107
- }), l;
111
+ }), o;
108
112
  }
109
113
  /**
110
114
  * Attaches a callback for only the rejection of the Futurable.
115
+ * @param {((reason: any) => TResult2 | PromiseLike<TResult2> | FuturableLike<TResult2>) | undefined | null} onRejected
116
+ * @returns {Futurable<T | TResult2>}
111
117
  */
112
118
  catch(t) {
113
119
  return this.then(null, t);
@@ -115,6 +121,8 @@ class i extends Promise {
115
121
  /**
116
122
  * Attaches a callback that is invoked when the Futurable is settled (fulfilled or rejected).
117
123
  * The resolved value cannot be modified from the callback.
124
+ * @param {() => void | undefined | null} onfinally
125
+ * @returns {Futurable<T>}
118
126
  */
119
127
  finally(t) {
120
128
  return this.then(
@@ -135,111 +143,119 @@ class i extends Promise {
135
143
  }
136
144
  /**
137
145
  * Waits for timer, then executes callback with the futurable value and returns the result obtained from the invocation.
138
- * @param cb: callback executed after timer with futurable chain value as parameter
139
- * @param timer: timer to wait (in milliseconds)
146
+ * @param {(val: T) => TResult1 | PromiseLike<TResult1> | FuturableLike<TResult1>} cb - callback executed after timer with futurable chain value as parameter
147
+ * @param {number} timer - timer to wait (in milliseconds)
140
148
  */
141
149
  delay(t, e) {
142
150
  let r, n;
143
- const l = new i((c, o) => {
144
- r = c, n = o;
151
+ const o = new i((c, l) => {
152
+ r = c, n = l;
145
153
  }, this.internalSignal);
146
- return l.controller = this.controller, this.then(
154
+ return o.controller = this.controller, this.then(
147
155
  (c) => {
148
156
  this.idsTimeout.push(setTimeout(() => r(t(c)), e));
149
157
  },
150
158
  (c) => {
151
159
  n(c);
152
160
  }
153
- ), l;
161
+ ), o;
154
162
  }
155
163
  /**
156
164
  * Waits for timer parameter (in milliseconds) before returning the value.
157
- * @param timer: timer to wait (in milliseconds)
165
+ * @param {number} timer - timer to wait (in milliseconds)
166
+ * @returns {Futurable<T>}
158
167
  */
159
168
  sleep(t) {
160
169
  return this.delay((e) => e, t);
161
170
  }
162
171
  /**
163
172
  * Extension of the fetch API with cancellation support. Url parameter can be a string or a function with receive value from futurable chaining as paremeter.
164
- * @param url: url to fetch or function with futurable chaining value that returns url to fetch
165
- * @param opts: fetch options or function with futurable chaining value that return fetch options
173
+ * @param {string| ((val?:T)=>string)} url - url to fetch or function with futurable chaining value that returns url to fetch
174
+ * @param {object | RequestInit | ((val?: T) => RequestInit)} opts - fetch options or function with futurable chaining value that return fetch options
175
+ * @returns {Futurable<Response>}
166
176
  */
167
177
  fetch(t, e) {
168
178
  let r, n;
169
- const l = new i((c, o) => {
170
- r = c, n = o;
179
+ const o = new i((c, l) => {
180
+ r = c, n = l;
171
181
  }, this.internalSignal);
172
- return l.controller = this.controller, this.then((c) => {
173
- const o = typeof t == "function" ? t(c) : t, s = { ...typeof e == "function" ? e(c) : e, signal: this.internalSignal };
174
- fetch(o, s).then((h) => r(h)).catch((h) => {
175
- h.name !== "AbortError" && n(h);
182
+ return o.controller = this.controller, this.then((c) => {
183
+ const l = typeof t == "function" ? t(c) : t, s = { ...typeof e == "function" ? e(c) : e, signal: this.internalSignal };
184
+ fetch(l, s).then((a) => r(a)).catch((a) => {
185
+ a.name !== "AbortError" && n(a);
176
186
  });
177
- }), l;
187
+ }), o;
178
188
  }
179
189
  /**
180
190
  * Executes the callback passed as a parameter when the futurable is cancelled.
181
- * @param cb: callback
191
+ * @param {()=>void} cb
192
+ * @returns {Futurable<TResult1 | TResult2>}
182
193
  */
183
194
  onCancel(t) {
184
195
  let e, r;
185
- const n = new i((l, c, o) => {
186
- o.onCancel(t), e = l, r = c;
196
+ const n = new i((o, c, l) => {
197
+ l.onCancel(t), e = o, r = c;
187
198
  }, this.internalSignal);
188
199
  return n.controller = this.controller, this.then(
189
- (l) => e(l),
190
- (l) => r(l)
200
+ (o) => e(o),
201
+ (o) => r(o)
191
202
  ), n;
192
203
  }
193
- // promisify<TResult1 = T, TResult2 = never>(): Promise<TResult1 | TResult2> {
194
- // return new Promise((res, rej) => {
195
- // if (this.#signal.aborted) {
196
- // this.#clearTimeout();
197
- // return;
198
- // } else {
199
- // this.then(
200
- // val => res(val),
201
- // reason => rej(reason)
202
- // );
203
- // }
204
- // });
205
- // }
206
204
  /**
207
205
  * Takes a promise and transforms it into a futurizable. Promise can be also a function that receives value from futurable chaining as parameter.
208
- * @param promise: Promise to futurize or function that return promise with futurable chaining value as parameter
206
+ * @param {Promise<TResult1> | ((val?: T) => Promise<TResult1>)} promise - Promise to futurize or function that return promise with futurable chaining value as parameter
207
+ * @returns {Futurable<TResult1 | TResult2>}
209
208
  */
210
209
  futurizable(t) {
211
210
  let e, r;
212
- const n = new i((l, c) => {
213
- e = l, r = c;
211
+ const n = new i((o, c) => {
212
+ e = o, r = c;
214
213
  }, this.internalSignal);
215
- return n.controller = this.controller, this.then((l) => {
216
- (typeof t == "function" ? t(l) : t).then(e).catch(r);
214
+ return n.controller = this.controller, this.then((o) => {
215
+ (typeof t == "function" ? t(o) : t).then(e).catch(r);
217
216
  }), n;
218
217
  }
218
+ /**
219
+ * @param {T | PromiseLike<T> | FuturableLike<T>} [value]
220
+ * @param {AbortSignal} [signal]
221
+ * @returns {Futurable<T|void>}
222
+ */
219
223
  static resolve(t, e) {
220
224
  return t ? new i((r) => r(t), e) : new i((r) => r(), e);
221
225
  }
226
+ /**
227
+ * Creates a new rejected futurable for the provided reason.
228
+ * @param {any} [reason]
229
+ * @param {AbortSignal} [signal]
230
+ * @returns {Futurable<T>}
231
+ */
222
232
  static reject(t, e) {
223
233
  return new i((r, n) => n(t), e);
224
234
  }
225
235
  /**
226
236
  * OnCancel static method. It accepts a callback or a object with cb property and an optional signal.
227
- */
237
+ * @param {{cb: () => T, signal: AbortSignal|undefined}} options
238
+ * @returns {Futurable<T>}
239
+ */
228
240
  static onCancel({ cb: t, signal: e }) {
229
- return new i((r, n, l) => {
230
- l.onCancel(() => r(t()));
241
+ return new i((r, n, o) => {
242
+ o.onCancel(() => r(t()));
231
243
  }, e);
232
244
  }
233
245
  /**
234
246
  * Delay static method. It accepts a object with timer and cb properties and an optional signal property.
247
+ * @param {{cb: () => T, timer: number, signal: AbortSignal|undefined}} options
248
+ * @returns {Futurable<T|TResult2>}
235
249
  */
236
250
  static delay({ cb: t, timer: e, signal: r }) {
237
- return new i((n, l, c) => {
238
- c.delay(t, e).then(n, l);
251
+ return new i((n, o, c) => {
252
+ c.delay(t, e).then(n, o);
239
253
  }, r);
240
254
  }
241
255
  /**
242
256
  * Sleep static method. It accepts a timer or a object with timer property and an optional signal.
257
+ * @param {{timer: number, signal: AbortSignal|undefined}} options
258
+ * @returns {Futurable<void>}
243
259
  */
244
260
  static sleep({ timer: t, signal: e }) {
245
261
  return i.delay({
@@ -251,15 +267,20 @@ class i extends Promise {
251
267
  }
252
268
  /**
253
269
  * Fetch static method.
270
+ * @param {string} url
271
+ * @param {RequestInit} [opts]
272
+ * @returns {Futurable<Response>}
254
273
  */
255
274
  static fetch(t, e) {
256
275
  const r = (e == null ? void 0 : e.signal) || void 0;
257
- return e != null && e.signal && delete e.signal, new i((n, l, c) => {
276
+ return e != null && e.signal && delete e.signal, new i((n, o, c) => {
258
277
  c.fetch(t, e).then(n);
259
278
  }, r);
260
279
  }
261
280
  /**
262
281
  * Futurizable static method.
282
+ * @param {{promise: Promise<TResult1>, signal: AbortSignal|undefined}} options
283
+ * @returns {Futurable<TResult1 | TResult2>}
263
284
  */
264
285
  static futurizable({ promise: t, signal: e }) {
265
286
  return new i((r, n) => {
@@ -271,14 +292,14 @@ class i extends Promise {
271
292
  for (const n in t)
272
293
  t[n] instanceof i ? r.push(t[n]) : t[n] instanceof Promise ? r.push(
273
294
  new i(
274
- (l, c) => {
275
- t[n].then((o) => l(o)).catch(c);
295
+ (o, c) => {
296
+ t[n].then((l) => o(l)).catch(c);
276
297
  },
277
298
  e
278
299
  )
279
300
  ) : r.push(
280
301
  new i(
281
- (l) => l(t[n]),
302
+ (o) => o(t[n]),
282
303
  e
283
304
  )
284
305
  );
@@ -286,82 +307,97 @@ class i extends Promise {
286
307
  }
287
308
  /**
288
309
  * Creates a Futurable with cancellation support that is resolved with an array of results when all of the provided Futurables resolve, or rejected when any Futurable is rejected.
310
+ * @param {T} values
311
+ * @param {AbortSignal} [signal]
312
+ * @returns {Futurable<{ -readonly [P in keyof T]: Awaited<T[P]>; }>}
289
313
  */
290
314
  static all(t, e) {
291
315
  let r, n;
292
- const l = new i((o, s, h) => {
293
- r = o, n = s, h.onCancel(() => {
316
+ const o = new i((l, s, a) => {
317
+ r = l, n = s, a.onCancel(() => {
294
318
  for (const f of c)
295
319
  f.cancel();
296
320
  });
297
321
  }, e);
298
- e || (e = l.internalSignal);
322
+ e || (e = o.internalSignal);
299
323
  const c = i.handleValues(t, e);
300
- return super.all(c).then((o) => r(o)).catch((o) => n(o)), l;
324
+ return super.all(c).then((l) => r(l)).catch((l) => n(l)), o;
301
325
  }
302
326
  /**
303
327
  * Creates a Futurable with cancellation support that is resolved with an array of results when all of the provided Futurables resolve or reject.
328
+ * @param {T} values
329
+ * @param {AbortSignal} [signal]
330
+ * @returns {Futurable<{ -readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>> }>}
304
331
  */
305
332
  static allSettled(t, e) {
306
333
  let r;
307
- const n = new i((c, o, s) => {
334
+ const n = new i((c, l, s) => {
308
335
  r = c, s.onCancel(() => {
309
- for (const h of l)
310
- h.cancel();
336
+ for (const a of o)
337
+ a.cancel();
311
338
  });
312
339
  }, e);
313
340
  e || (e = n.internalSignal);
314
- const l = i.handleValues(t, e);
315
- return super.allSettled(l).then((c) => r(c)), n;
341
+ const o = i.handleValues(t, e);
342
+ return super.allSettled(o).then((c) => r(c)), n;
316
343
  }
317
344
  /**
318
345
  * Creates a Futurable with cancellation support that is resolved or rejected when any of the provided Futurables are resolved or rejected.
346
+ * @param {T} values
347
+ * @param {AbortSignal} [signal]
348
+ * @returns {Futurable<Awaited<T[number]>>}
319
349
  */
320
350
  static race(t, e) {
321
351
  let r, n;
322
- const l = new i((o, s, h) => {
323
- r = o, n = s, h.onCancel(() => {
352
+ const o = new i((l, s, a) => {
353
+ r = l, n = s, a.onCancel(() => {
324
354
  for (const f of c)
325
355
  f.cancel();
326
356
  });
327
357
  }, e);
328
- e || (e = l.internalSignal);
358
+ e || (e = o.internalSignal);
329
359
  const c = i.handleValues(t, e);
330
- return super.race(c).then((o) => r(o)).catch((o) => n(o)), l;
360
+ return super.race(c).then((l) => r(l)).catch((l) => n(l)), o;
331
361
  }
332
362
  /**
333
363
  * The any function returns a futurable with cancellation support that is fulfilled by the first given futurable to be fulfilled,
334
364
  * or rejected with an AggregateError containing an array of rejection reasons if all of the
335
365
  * given futurables are rejected. It resolves all elements of the passed iterable to futurables as
336
366
  * it runs this algorithm.
367
+ * @param {T} values
368
+ * @param {AbortSignal} [signal]
369
+ * @returns {Futurable<Awaited<T[number]>>}
337
370
  */
338
371
  static any(t, e) {
339
372
  let r, n;
340
- const l = new i((o, s, h) => {
341
- r = o, n = s, h.onCancel(() => {
373
+ const o = new i((l, s, a) => {
374
+ r = l, n = s, a.onCancel(() => {
342
375
  for (const f of c)
343
376
  f.cancel();
344
377
  });
345
378
  }, e);
346
- e || (e = l.internalSignal);
379
+ e || (e = o.internalSignal);
347
380
  const c = i.handleValues(t, e);
348
- return super.any(c).then((o) => r(o)).catch((o) => n(o)), l;
381
+ return super.any(c).then((l) => r(l)).catch((l) => n(l)), o;
349
382
  }
350
383
  /**
351
384
  * Creates a polling service with cancellation support and possibility to handle error.
385
+ * @param {()=> Futurable<T>} value
386
+ * @param {{interval: number, signal?: AbortSignal}} options
387
+ * @returns {{cancel: () => void, catch: (onrejected:(reason: unknown)=>void)=>void }}
352
388
  */
353
389
  static polling(t, { interval: e, signal: r }) {
354
- let n, l, c;
355
- const o = setInterval(() => {
356
- n && n.cancel(), n = new i((s, h, f) => {
390
+ let n, o, c;
391
+ const l = setInterval(() => {
392
+ n && n.cancel(), n = new i((s, a, f) => {
357
393
  f.onCancel(() => {
358
- l && l.cancel();
359
- }), l = t().then(() => s()).catch((m) => c && c(m));
394
+ o && o.cancel();
395
+ }), o = t().then(() => s()).catch((S) => c && c(S));
360
396
  }, r);
361
397
  }, e);
362
398
  return {
363
399
  cancel: () => {
364
- o && clearInterval(o), n && n.cancel();
400
+ l && clearInterval(l), n && n.cancel();
365
401
  },
366
402
  catch: (s) => {
367
403
  c = s;
@@ -369,22 +405,21 @@ class i extends Promise {
369
405
  };
370
406
  }
371
407
  /**
372
- * Creates an object with:
373
- * - _build_: function to create a Futurable.
374
- * - _resolve_: function to resolve the Futurable created.
375
- * - _reject_: function to reject the Futurable created.
376
- * - _utils_: object that reflects __utils__ object of Futurabled created.
408
+ * Extension of _Promise.withResolvers_ static method. Creates a new Futurable and returns it in an object, along with its resolve, reject and cancel functions and utils object.
409
+ * @param {AbortSignal} [signal]
410
+ * @returns {{ resolve: null | FuturableResolve<T>, reject: null | FuturableReject, utils: null | FuturableUtils<T>, futurable: Futurable<T>, cancel: null | (() => void) }}
377
411
  */
378
- static builder(t) {
412
+ static withResolvers(t) {
413
+ let e, r, n;
414
+ const o = new i((l, s, a) => {
415
+ e = l, r = s, n = a;
416
+ }, t), c = o.cancel;
379
417
  return {
380
- resolve: null,
381
- reject: null,
382
- utils: null,
383
- build() {
384
- return new i((e, r, n) => {
385
- this.resolve = e, this.reject = r, this.utils = n;
386
- }, t);
387
- }
418
+ resolve: e,
419
+ reject: r,
420
+ utils: n,
421
+ cancel: c,
422
+ promise: o
388
423
  };
389
424
  }
390
425
  }
package/dist/index.d.ts CHANGED
@@ -56,6 +56,13 @@ export type FuturableExecutor<T> = (resolve: FuturableResolve<T>, reject: Futura
56
56
  */
57
57
  utils: FuturableUtils<T>) => void;
58
58
  export type FuturableIterable<T = any> = Iterable<FuturableLike<T> | PromiseLike<T> | T>;
59
+ interface FuturableWithResolvers<T> {
60
+ promise: Futurable<T> | Promise<T>;
61
+ resolve: (value: T | PromiseLike<T> | FuturableLike<T>) => void;
62
+ reject: (reason?: any) => void;
63
+ cancel: () => void;
64
+ utils: FuturableUtils<T>;
65
+ }
59
66
  export declare class Futurable<T> extends Promise<T> {
60
67
  private controller;
61
68
  private internalSignal;
@@ -65,20 +72,28 @@ export declare class Futurable<T> extends Promise<T> {
65
72
  get [Symbol.toStringTag](): string;
66
73
  /**
67
74
  * Return internal futurable signal
75
+ * @returns {AbortSignal}
68
76
  */
69
77
  get signal(): AbortSignal;
70
78
  private clearTimeout;
71
79
  /**
72
80
  * Attaches callbacks for the resolution and/or rejection of the Futurable.
81
+ * @param {((value: T) => TResult1 | PromiseLike<TResult1> | FuturableLike<TResult1>) | undefined | null} onfulfilled
82
+ * @param {((reason: any) => TResult2 | PromiseLike<TResult2> | FuturableLike<TResult2>) | undefined | null} onrejected
83
+ * @returns {Futurable<TResult1 | TResult2>}
73
84
  */
74
85
  then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1> | FuturableLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2> | FuturableLike<TResult2>) | undefined | null): Futurable<TResult1 | TResult2>;
75
86
  /**
76
87
  * Attaches a callback for only the rejection of the Futurable.
88
+ * @param {((reason: any) => TResult2 | PromiseLike<TResult2> | FuturableLike<TResult2>) | undefined | null} onRejected
89
+ * @returns {Futurable<T | TResult2>}
77
90
  */
78
91
  catch<TResult2 = never>(onRejected: ((reason: any) => TResult2 | PromiseLike<TResult2> | FuturableLike<TResult2>) | undefined | null): Futurable<T | TResult2>;
79
92
  /**
80
93
  * Attaches a callback that is invoked when the Futurable is settled (fulfilled or rejected).
81
94
  * The resolved value cannot be modified from the callback.
95
+ * @param {() => void | undefined | null} onfinally
96
+ * @returns {Futurable<T>}
82
97
  */
83
98
  finally(onfinally: () => void | undefined | null): Futurable<T>;
84
99
  /**
@@ -87,43 +102,66 @@ export declare class Futurable<T> extends Promise<T> {
87
102
  cancel(): void;
88
103
  /**
89
104
  * Waits for timer, then executes callback with the futurable value and returns the result obtained from the invocation.
90
- * @param cb: callback executed after timer with futurable chain value as parameter
91
- * @param timer: timer to wait (in milliseconds)
105
+ * @param {(val: T) => TResult1 | PromiseLike<TResult1> | FuturableLike<TResult1>} cb - callback executed after timer with futurable chain value as parameter
106
+ * @param {number} timer - timer to wait (in milliseconds)
92
107
  */
93
108
  delay<TResult1 = T, TResult2 = never>(cb: (val: T) => TResult1 | PromiseLike<TResult1> | FuturableLike<TResult1>, timer: number): Futurable<TResult1 | TResult2>;
94
109
  /**
95
110
  * Waits for timer parameter (in milliseconds) before returning the value.
96
- * @param timer: timer to wait (in milliseconds)
111
+ * @param {number} timer - timer to wait (in milliseconds)
112
+ * @returns {Futurable<T>}
97
113
  */
98
114
  sleep(timer: number): Futurable<T>;
99
115
  /**
100
116
  * Extension of the fetch API with cancellation support. Url parameter can be a string or a function with receive value from futurable chaining as paremeter.
101
- * @param url: url to fetch or function with futurable chaining value that returns url to fetch
102
- * @param opts: fetch options or function with futurable chaining value that return fetch options
117
+ * @param {string| ((val?:T)=>string)} url - url to fetch or function with futurable chaining value that returns url to fetch
118
+ * @param {object | RequestInit | ((val?: T) => RequestInit)} opts - fetch options or function with futurable chaining value that return fetch options
119
+ * @returns {Futurable<Response>}
103
120
  */
104
121
  fetch(url: string | ((val?: T) => string), opts?: object | RequestInit | ((val?: T) => RequestInit)): Futurable<Response>;
105
122
  /**
106
123
  * Executes the callback passed as a parameter when the futurable is cancelled.
107
- * @param cb: callback
124
+ * @param {()=>void} cb
125
+ * @returns {Futurable<TResult1 | TResult2>}
108
126
  */
109
127
  onCancel<TResult1 = void, TResult2 = never>(cb: () => void): Futurable<TResult1 | TResult2>;
110
128
  /**
111
129
  * Takes a promise and transforms it into a futurizable. Promise can be also a function that receives value from futurable chaining as parameter.
112
- * @param promise: Promise to futurize or function that return promise with futurable chaining value as parameter
130
+ * @param {Promise<TResult1> | ((val?: T) => Promise<TResult1>)} promise - Promise to futurize or function that return promise with futurable chaining value as parameter
131
+ * @returns {Futurable<TResult1 | TResult2>}
113
132
  */
114
133
  futurizable<TResult1 = T, TResult2 = never>(promise: Promise<TResult1> | ((val?: T) => Promise<TResult1>)): Futurable<TResult1 | TResult2>;
134
+ /**
135
+ * Creates a new resolved futurable. Creates a new resolved futurable for the provided value.
136
+ * @returns {Futurable<void>}
137
+ */
115
138
  static resolve(): Futurable<void>;
139
+ /**
140
+ * @param {T | PromiseLike<T> | FuturableLike<T>} value
141
+ * @param {AbortSignal} [signal]
142
+ * @returns {Futurable<T>}
143
+ */
116
144
  static resolve<T = any>(value: T | PromiseLike<T> | FuturableLike<T>, signal?: AbortSignal): Futurable<T>;
145
+ /**
146
+ * Creates a new rejected futurable for the provided reason.
147
+ * @param {any} [reason]
148
+ * @param {AbortSignal} [signal]
149
+ * @returns {Futurable<T>}
150
+ */
117
151
  static reject<T = never>(reason?: any, signal?: AbortSignal): Futurable<T>;
118
152
  /**
119
153
  * OnCancel static method. It accepts a callback or a object with cb property and an optional signal.
120
- */
154
+ * @param {{cb: () => T, signal: AbortSignal|undefined}} options
155
+ * @returns {Futurable<T>}
156
+ */
121
157
  static onCancel<T = void>({ cb, signal }: {
122
158
  cb: () => T;
123
159
  signal?: AbortSignal;
124
160
  }): Futurable<T>;
125
161
  /**
126
162
  * Delay static method. It accepts a object with timer and cb properties and an optional signal property.
163
+ * @param {{cb: () => T, timer: number, signal: AbortSignal|undefined}} options
164
+ * @returns {Futurable<T|TResult2>}
127
165
  */
128
166
  static delay<T = any, TResult2 = never>({ cb, timer, signal }: {
129
167
  cb: () => T;
@@ -132,6 +170,8 @@ export declare class Futurable<T> extends Promise<T> {
132
170
  }): Futurable<T | TResult2>;
133
171
  /**
134
172
  * Sleep static method. It accepts a timer or a object with timer property and an optional signal.
173
+ * @param {{timer: number, signal: AbortSignal|undefined}} options
174
+ * @returns {Futurable<void>}
135
175
  */
136
176
  static sleep({ timer, signal }: {
137
177
  timer: number;
@@ -139,10 +179,15 @@ export declare class Futurable<T> extends Promise<T> {
139
179
  }): Futurable<void>;
140
180
  /**
141
181
  * Fetch static method.
182
+ * @param {string} url
183
+ * @param {RequestInit} [opts]
184
+ * @returns {Futurable<Response>}
142
185
  */
143
186
  static fetch(url: string, opts?: RequestInit): Futurable<Response>;
144
187
  /**
145
188
  * Futurizable static method.
189
+ * @param {{promise: Promise<TResult1>, signal: AbortSignal|undefined}} options
190
+ * @returns {Futurable<TResult1 | TResult2>}
146
191
  */
147
192
  static futurizable<TResult1 = any, TResult2 = never>({ promise, signal }: {
148
193
  promise: Promise<TResult1>;
@@ -151,18 +196,27 @@ export declare class Futurable<T> extends Promise<T> {
151
196
  private static handleValues;
152
197
  /**
153
198
  * Creates a Futurable with cancellation support that is resolved with an array of results when all of the provided Futurables resolve, or rejected when any Futurable is rejected.
199
+ * @param {T} values
200
+ * @param {AbortSignal} [signal]
201
+ * @returns {Futurable<{ -readonly [P in keyof T]: Awaited<T[P]>; }>}
154
202
  */
155
203
  static all<T extends readonly unknown[] | []>(values: T, signal?: AbortSignal): Futurable<{
156
204
  -readonly [P in keyof T]: Awaited<T[P]>;
157
205
  }>;
158
206
  /**
159
207
  * Creates a Futurable with cancellation support that is resolved with an array of results when all of the provided Futurables resolve or reject.
208
+ * @param {T} values
209
+ * @param {AbortSignal} [signal]
210
+ * @returns {Futurable<{ -readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>> }>}
160
211
  */
161
212
  static allSettled<T extends readonly unknown[] | []>(values: T, signal?: AbortSignal): Futurable<{
162
213
  -readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>>;
163
214
  }>;
164
215
  /**
165
216
  * Creates a Futurable with cancellation support that is resolved or rejected when any of the provided Futurables are resolved or rejected.
217
+ * @param {T} values
218
+ * @param {AbortSignal} [signal]
219
+ * @returns {Futurable<Awaited<T[number]>>}
166
220
  */
167
221
  static race<T extends readonly unknown[] | []>(values: T, signal?: AbortSignal): Futurable<Awaited<T[number]>>;
168
222
  /**
@@ -170,10 +224,16 @@ export declare class Futurable<T> extends Promise<T> {
170
224
  * or rejected with an AggregateError containing an array of rejection reasons if all of the
171
225
  * given futurables are rejected. It resolves all elements of the passed iterable to futurables as
172
226
  * it runs this algorithm.
227
+ * @param {T} values
228
+ * @param {AbortSignal} [signal]
229
+ * @returns {Futurable<Awaited<T[number]>>}
173
230
  */
174
231
  static any<T extends readonly unknown[] | []>(values: T, signal?: AbortSignal): Futurable<Awaited<T[number]>>;
175
232
  /**
176
233
  * Creates a polling service with cancellation support and possibility to handle error.
234
+ * @param {()=> Futurable<T>} value
235
+ * @param {{interval: number, signal?: AbortSignal}} options
236
+ * @returns {{cancel: () => void, catch: (onrejected:(reason: unknown)=>void)=>void }}
177
237
  */
178
238
  static polling<T>(value: () => Futurable<T>, { interval, signal }: {
179
239
  interval: number;
@@ -183,17 +243,11 @@ export declare class Futurable<T> extends Promise<T> {
183
243
  catch: (onrejected: (reason: unknown) => void) => void;
184
244
  };
185
245
  /**
186
- * Creates an object with:
187
- * - _build_: function to create a Futurable.
188
- * - _resolve_: function to resolve the Futurable created.
189
- * - _reject_: function to reject the Futurable created.
190
- * - _utils_: object that reflects __utils__ object of Futurabled created.
191
- */
192
- static builder<T>(signal?: AbortSignal): {
193
- resolve: null | FuturableResolve<T>;
194
- reject: null | FuturableReject;
195
- utils: null | FuturableUtils<T>;
196
- build: () => Futurable<T>;
197
- };
246
+ * Extension of _Promise.withResolvers_ static method. Creates a new Futurable and returns it in an object, along with its resolve, reject and cancel functions and utils object.
247
+ * @param {AbortSignal} [signal]
248
+ * @returns {{ resolve: null | FuturableResolve<T>, reject: null | FuturableReject, utils: null | FuturableUtils<T>, futurable: Futurable<T>, cancel: null | (() => void) }}
249
+ */
250
+ static withResolvers<T>(signal?: AbortSignal): FuturableWithResolvers<T>;
198
251
  }
252
+ export {};
199
253
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,CAAC,CAAC;IAC/B;;;;;OAKG;IACH,IAAI,CAAC,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,EAClC,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,EAC3G,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAC3G,aAAa,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;CACtC;AACD,MAAM,WAAW,gBAAgB,CAAC,CAAC;IAClC,CAAC,KAAK,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,eAAe;IAC/B,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAChC;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC;IACpB;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;;OAGG;IACH,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IACnC;;;;OAIG;IACH,KAAK,EAAE,CAAC,OAAO,GAAC,CAAC,EAAE,QAAQ,GAAC,KAAK,EAAE,EAAE,EA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I,CAAA;KAAE;IAsBpL;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,sBAAsB,CAAC,CAAC,CAAC;CAkBxE"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@ndriadev/futurable",
3
3
  "description": "Extension Javascript's Promise API with more functionalities",
4
4
  "private": false,
5
- "version": "2.1.2",
5
+ "version": "2.2.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist/",