@ndriadev/futurable 1.1.0 → 1.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
@@ -11,7 +11,7 @@
11
11
  <div align="center">
12
12
 
13
13
  ![Statements](https://img.shields.io/badge/statements-100%25-brightgreen.svg?style=for-the-badge)
14
- ![Branches](https://img.shields.io/badge/branches-96.55%25-brightgreen.svg?style=for-the-badge)
14
+ ![Branches](https://img.shields.io/badge/branches-96.21%25-brightgreen.svg?style=for-the-badge)
15
15
  ![Functions](https://img.shields.io/badge/functions-100%25-brightgreen.svg?style=for-the-badge)
16
16
  ![Lines](https://img.shields.io/badge/lines-100%25-brightgreen.svg?style=for-the-badge)
17
17
  </div>
@@ -1 +1 @@
1
- "use strict";var T=Object.defineProperty;var v=(g,f,e)=>f in g?T(g,f,{enumerable:!0,configurable:!0,writable:!0,value:e}):g[f]=e;var S=(g,f,e)=>(v(g,typeof f!="symbol"?f+"":f,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i extends Promise{constructor(e,t){const r=t?null:new AbortController,n=t||r.signal,o=[],c=()=>{for(const l of o)clearTimeout(l)};let s;const d={signal:n,cancel:()=>{var l;return(l=this.controller)==null?void 0:l.abort()},onCancel:l=>{s=l},delay:(l,a)=>new i(h=>{o.push(setTimeout(()=>{h(l())},a))},n),sleep:l=>d.delay(()=>{},l),fetch:(l,a)=>new i((h,w)=>{fetch(l,{...a||{},signal:n}).then(y=>h(y)).catch(y=>{y.name!=="AbortError"&&w(y)})},n),futurizable:l=>new i((a,h)=>{l.then(a).catch(h)},n)};let m="pending";const p=new Promise((l,a)=>{if(n.aborted){c(),m==="pending"&&s&&s();return}else{const h=typeof n.onabort=="function"?n.onabort:()=>{};n.onabort=()=>{h(),c(),m==="pending"&&s&&s()},e(j=>{m="fulfilled",l(j)},j=>{m="rejected",a(j)},d)}});super((l,a)=>{p.then(h=>l(h)).catch(a)});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 e of this.idsTimeout)clearTimeout(e)}then(e,t){let r,n;const o=new i((c,s)=>{r=c,n=s},this.internalSignal);return o.controller=this.controller,super.then(c=>{var s;if((s=this.internalSignal)!=null&&s.aborted){this.clearTimeout();return}try{r(e?e(c):c)}catch(u){n(u)}},c=>{var s;if((s=this.internalSignal)!=null&&s.aborted){this.clearTimeout();return}try{t?r(t(c)):n(c)}catch(u){n(u)}}),o}catch(e){return this.then(null,e)}finally(e){return this.then(()=>{e()},()=>{e()})}cancel(){var e,t;!((e=this.internalSignal)!=null&&e.aborted)&&((t=this.controller)==null||t.abort())}delay(e,t){let r,n;const o=new i((c,s)=>{r=c,n=s},this.internalSignal);return o.controller=this.controller,this.then(c=>{this.idsTimeout.push(setTimeout(()=>r(e(c)),t))},c=>{n(c)}),o}sleep(e){return this.delay(t=>t,e)}fetch(e,t){let r,n;const o=new i((c,s)=>{r=c,n=s},this.internalSignal);return o.controller=this.controller,this.then(c=>{const s=typeof e=="function"?e(c):e,u={...typeof t=="function"?t(c):t,signal:this.internalSignal};fetch(s,u).then(d=>r(d)).catch(d=>{d.name!=="AbortError"&&n(d)})}),o}onCancel(e){let t,r;const n=new i((o,c,s)=>{s.onCancel(e),t=o,r=c},this.internalSignal);return n.controller=this.controller,this.then(o=>t(o),o=>r(o)),n}futurizable(e){let t,r;const n=new i((o,c)=>{t=o,r=c},this.internalSignal);return n.controller=this.controller,this.then(o=>{(typeof e=="function"?e(o):e).then(t).catch(r)}),n}static resolve(e,t){return new i(r=>r(e),t)}static reject(e,t){return new i((r,n)=>n(e),t)}static onCancel({cb:e,signal:t}){return new i((r,n,o)=>{o.onCancel(()=>r(e()))},t)}static delay({cb:e,timer:t,signal:r}){return new i((n,o,c)=>{c.delay(e,t).then(n)},r)}static sleep({timer:e,signal:t}){return i.delay({cb:()=>{},timer:e,signal:t})}static fetch(e,t){const r=(t==null?void 0:t.signal)||void 0;return t!=null&&t.signal&&delete t.signal,new i((n,o,c)=>{c.fetch(e,t).then(n)},r)}static futurizable({promise:e,signal:t}){return new i((r,n)=>{e.then(r).catch(n)},t)}static handleIterables(e,t){const r={array:[]};r.f=new i((n,o,c)=>{r.resolve=n,r.reject=o,c.onCancel(()=>{for(const s of r.array)s.cancel()})},t),t||(t=r.f.internalSignal);for(const n in e)e[n]instanceof i?r.array.push(e[n]):e[n]instanceof Promise?r.array.push(new i((o,c)=>{e[n].then(u=>o(u)).catch(c)},t)):r.array.push(i.resolve(e[n],t));return r}static all(e,t){const{f:r,resolve:n,reject:o,array:c}=i.handleIterables(e,t);return super.all(c).then(n).catch(o),r}static allSettled(e,t){const{f:r,resolve:n,reject:o,array:c}=i.handleIterables(e,t);return super.allSettled(c).then(n).catch(o),r}static race(e,t){const{f:r,resolve:n,reject:o,array:c}=i.handleIterables(e,t);return super.race(c).then(n).catch(o),r}static any(e,t){const{f:r,resolve:n,reject:o,array:c}=i.handleIterables(e,t);return super.any(c).then(n).catch(o),r}}exports.Futurable=i;
1
+ "use strict";var T=Object.defineProperty;var C=(y,g,t)=>g in y?T(y,g,{enumerable:!0,configurable:!0,writable:!0,value:t}):y[g]=t;var S=(y,g,t)=>(C(y,typeof g!="symbol"?g+"":g,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class l extends Promise{constructor(t,e){const r=e?null:new AbortController,n=e||r.signal,o=[],c=()=>{for(const s of o)clearTimeout(s)};let i;const a={signal:n,cancel:()=>{var s;return(s=this.controller)==null?void 0:s.abort()},onCancel:s=>{i=s},delay:(s,u)=>new l(d=>{o.push(setTimeout(()=>{d(s())},u))},n),sleep:s=>a.delay(()=>{},s),fetch:(s,u)=>new l((d,j)=>{fetch(s,{...u||{},signal:n}).then(w=>d(w)).catch(w=>{w.name!=="AbortError"&&j(w)})},n),futurizable:s=>new l((u,d)=>{s.then(u).catch(d)},n)};let f="pending";const p=new Promise((s,u)=>{if(n.aborted){c(),f==="pending"&&i&&i();return}else{const d=typeof n.onabort=="function"?n.onabort:()=>{};n.onabort=()=>{d(),c(),f==="pending"&&i&&i()},t(m=>{f="fulfilled",s(m)},m=>{f="rejected",u(m)},a)}});super((s,u)=>{p.then(d=>s(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 l((c,i)=>{r=c,n=i},this.internalSignal);return o.controller=this.controller,super.then(c=>{var i;if((i=this.internalSignal)!=null&&i.aborted){this.clearTimeout();return}try{r(t?t(c):c)}catch(h){n(h)}},c=>{var i;if((i=this.internalSignal)!=null&&i.aborted){this.clearTimeout();return}try{e?r(e(c)):n(c)}catch(h){n(h)}}),o}catch(t){return this.then(null,t)}finally(t){return this.then(e=>(t(),e),e=>(t(),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 l((c,i)=>{r=c,n=i},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 l((c,i)=>{r=c,n=i},this.internalSignal);return o.controller=this.controller,this.then(c=>{const i=typeof t=="function"?t(c):t,h={...typeof e=="function"?e(c):e,signal:this.internalSignal};fetch(i,h).then(a=>r(a)).catch(a=>{a.name!=="AbortError"&&n(a)})}),o}onCancel(t){let e,r;const n=new l((o,c,i)=>{i.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 l((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 l(r=>r(t),e):new l(r=>r(),e)}static reject(t,e){return new l((r,n)=>n(t),e)}static onCancel({cb:t,signal:e}){return new l((r,n,o)=>{o.onCancel(()=>r(t()))},e)}static delay({cb:t,timer:e,signal:r}){return new l((n,o,c)=>{c.delay(t,e).then(n,o)},r)}static sleep({timer:t,signal:e}){return l.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 l((n,o,c)=>{c.fetch(t,e).then(n)},r)}static futurizable({promise:t,signal:e}){return new l((r,n)=>{t.then(r).catch(n)},e)}static handleValues(t,e){const r=[];for(const n in t)t[n]instanceof l?r.push(t[n]):t[n]instanceof Promise?r.push(new l((o,c)=>{t[n].then(i=>o(i)).catch(c)},e)):r.push(new l(o=>o(t[n]),e));return r}static all(t,e){let r,n;const o=new l((i,h,a)=>{r=i,n=h,a.onCancel(()=>{for(const f of c)f.cancel()})},e);e||(e=o.internalSignal);const c=l.handleValues(t,e);return super.all(c).then(i=>r(i)).catch(i=>n(i)),o}static allSettled(t,e){let r;const n=new l((c,i,h)=>{r=c,h.onCancel(()=>{for(const a of o)a.cancel()})},e);e||(e=n.internalSignal);const o=l.handleValues(t,e);return super.allSettled(o).then(c=>r(c)),n}static race(t,e){let r,n;const o=new l((i,h,a)=>{r=i,n=h,a.onCancel(()=>{for(const f of c)f.cancel()})},e);e||(e=o.internalSignal);const c=l.handleValues(t,e);return super.race(c).then(i=>r(i)).catch(i=>n(i)),o}static any(t,e){let r,n;const o=new l((i,h,a)=>{r=i,n=h,a.onCancel(()=>{for(const f of c)f.cancel()})},e);e||(e=o.internalSignal);const c=l.handleValues(t,e);return super.any(c).then(i=>r(i)).catch(i=>n(i)),o}}exports.Futurable=l;
@@ -1,61 +1,61 @@
1
1
  var T = Object.defineProperty;
2
- var v = (g, f, e) => f in g ? T(g, f, { enumerable: !0, configurable: !0, writable: !0, value: e }) : g[f] = e;
3
- var w = (g, f, e) => (v(g, typeof f != "symbol" ? f + "" : f, e), e);
4
- class s extends Promise {
5
- constructor(e, t) {
6
- const r = t ? null : new AbortController(), n = t || r.signal, o = [], c = () => {
7
- for (const l of o)
8
- clearTimeout(l);
2
+ var C = (w, g, t) => g in w ? T(w, g, { enumerable: !0, configurable: !0, writable: !0, value: t }) : w[g] = t;
3
+ var S = (w, g, t) => (C(w, typeof g != "symbol" ? g + "" : g, t), t);
4
+ class l extends Promise {
5
+ constructor(t, e) {
6
+ const r = e ? null : new AbortController(), n = e || r.signal, o = [], c = () => {
7
+ for (const s of o)
8
+ clearTimeout(s);
9
9
  };
10
10
  let i;
11
- const d = {
11
+ const a = {
12
12
  signal: n,
13
13
  cancel: () => {
14
- var l;
15
- return (l = this.controller) == null ? void 0 : l.abort();
14
+ var s;
15
+ return (s = this.controller) == null ? void 0 : s.abort();
16
16
  },
17
- onCancel: (l) => {
18
- i = l;
17
+ onCancel: (s) => {
18
+ i = s;
19
19
  },
20
- delay: (l, a) => new s((h) => {
20
+ delay: (s, u) => new l((d) => {
21
21
  o.push(setTimeout(() => {
22
- h(l());
23
- }, a));
22
+ d(s());
23
+ }, u));
24
24
  }, n),
25
- sleep: (l) => d.delay(() => {
26
- }, l),
27
- fetch: (l, a) => new s((h, j) => {
28
- fetch(l, { ...a || {}, signal: n }).then((y) => h(y)).catch((y) => {
29
- y.name !== "AbortError" && j(y);
25
+ sleep: (s) => a.delay(() => {
26
+ }, s),
27
+ fetch: (s, u) => new l((d, p) => {
28
+ fetch(s, { ...u || {}, signal: n }).then((y) => d(y)).catch((y) => {
29
+ y.name !== "AbortError" && p(y);
30
30
  });
31
31
  }, n),
32
- futurizable: (l) => new s((a, h) => {
33
- l.then(a).catch(h);
32
+ futurizable: (s) => new l((u, d) => {
33
+ s.then(u).catch(d);
34
34
  }, n)
35
35
  };
36
- let m = "pending";
37
- const p = new Promise((l, a) => {
36
+ let f = "pending";
37
+ const j = new Promise((s, u) => {
38
38
  if (n.aborted) {
39
- c(), m === "pending" && i && i();
39
+ c(), f === "pending" && i && i();
40
40
  return;
41
41
  } else {
42
- const h = typeof n.onabort == "function" ? n.onabort : () => {
42
+ const d = typeof n.onabort == "function" ? n.onabort : () => {
43
43
  };
44
44
  n.onabort = () => {
45
- h(), c(), m === "pending" && i && i();
46
- }, e((S) => {
47
- m = "fulfilled", l(S);
48
- }, (S) => {
49
- m = "rejected", a(S);
50
- }, d);
45
+ d(), c(), f === "pending" && i && i();
46
+ }, t((m) => {
47
+ f = "fulfilled", s(m);
48
+ }, (m) => {
49
+ f = "rejected", u(m);
50
+ }, a);
51
51
  }
52
52
  });
53
- super((l, a) => {
54
- p.then((h) => l(h)).catch(a);
53
+ super((s, u) => {
54
+ j.then((d) => s(d)).catch(u);
55
55
  });
56
- w(this, "controller");
57
- w(this, "internalSignal");
58
- w(this, "idsTimeout");
56
+ S(this, "controller");
57
+ S(this, "internalSignal");
58
+ S(this, "idsTimeout");
59
59
  this.controller = r, this.internalSignal = n, this.idsTimeout = o;
60
60
  }
61
61
  static get [Symbol.species]() {
@@ -71,15 +71,15 @@ class s extends Promise {
71
71
  return this.internalSignal;
72
72
  }
73
73
  clearTimeout() {
74
- for (const e of this.idsTimeout)
75
- clearTimeout(e);
74
+ for (const t of this.idsTimeout)
75
+ clearTimeout(t);
76
76
  }
77
77
  /**
78
78
  * Attaches callbacks for the resolution and/or rejection of the Futurable.
79
79
  */
80
- then(e, t) {
80
+ then(t, e) {
81
81
  let r, n;
82
- const o = new s((c, i) => {
82
+ const o = new l((c, i) => {
83
83
  r = c, n = i;
84
84
  }, this.internalSignal);
85
85
  return o.controller = this.controller, super.then((c) => {
@@ -89,9 +89,9 @@ class s extends Promise {
89
89
  return;
90
90
  }
91
91
  try {
92
- r(e ? e(c) : c);
93
- } catch (u) {
94
- n(u);
92
+ r(t ? t(c) : c);
93
+ } catch (h) {
94
+ n(h);
95
95
  }
96
96
  }, (c) => {
97
97
  var i;
@@ -100,51 +100,48 @@ class s extends Promise {
100
100
  return;
101
101
  }
102
102
  try {
103
- t ? r(t(c)) : n(c);
104
- } catch (u) {
105
- n(u);
103
+ e ? r(e(c)) : n(c);
104
+ } catch (h) {
105
+ n(h);
106
106
  }
107
107
  }), o;
108
108
  }
109
109
  /**
110
110
  * Attaches a callback for only the rejection of the Futurable.
111
111
  */
112
- catch(e) {
113
- return this.then(null, e);
112
+ catch(t) {
113
+ return this.then(null, t);
114
114
  }
115
115
  /**
116
- * Attaches a callback that is invoked when the Futurable is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.
116
+ * Attaches a callback that is invoked when the Futurable is settled (fulfilled or rejected).
117
+ * The resolved value cannot be modified from the callback.
117
118
  */
118
- finally(e) {
119
+ finally(t) {
119
120
  return this.then(
120
- () => {
121
- e();
122
- },
123
- () => {
124
- e();
125
- }
121
+ (e) => (t(), e),
122
+ (e) => (t(), e)
126
123
  );
127
124
  }
128
125
  /**
129
126
  * Cancel the futurable if it is to be executed or if it is still executing.
130
127
  */
131
128
  cancel() {
132
- var e, t;
133
- !((e = this.internalSignal) != null && e.aborted) && ((t = this.controller) == null || t.abort());
129
+ var t, e;
130
+ !((t = this.internalSignal) != null && t.aborted) && ((e = this.controller) == null || e.abort());
134
131
  }
135
132
  /**
136
133
  * Waits for timer, then executes callback with the futurable value and returns the result obtained from the invocation.
137
134
  * @param cb: callback executed after timer with futurable chain value as parameter
138
135
  * @param timer: timer to wait (in milliseconds)
139
136
  */
140
- delay(e, t) {
137
+ delay(t, e) {
141
138
  let r, n;
142
- const o = new s((c, i) => {
139
+ const o = new l((c, i) => {
143
140
  r = c, n = i;
144
141
  }, this.internalSignal);
145
142
  return o.controller = this.controller, this.then(
146
143
  (c) => {
147
- this.idsTimeout.push(setTimeout(() => r(e(c)), t));
144
+ this.idsTimeout.push(setTimeout(() => r(t(c)), e));
148
145
  },
149
146
  (c) => {
150
147
  n(c);
@@ -155,23 +152,23 @@ class s extends Promise {
155
152
  * Waits for timer parameter (in milliseconds) before returning the value.
156
153
  * @param timer: timer to wait (in milliseconds)
157
154
  */
158
- sleep(e) {
159
- return this.delay((t) => t, e);
155
+ sleep(t) {
156
+ return this.delay((e) => e, t);
160
157
  }
161
158
  /**
162
159
  * 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.
163
160
  * @param url: url to fetch or function with futurable chaining value that returns url to fetch
164
161
  * @param opts: fetch options or function with futurable chaining value that return fetch options
165
162
  */
166
- fetch(e, t) {
163
+ fetch(t, e) {
167
164
  let r, n;
168
- const o = new s((c, i) => {
165
+ const o = new l((c, i) => {
169
166
  r = c, n = i;
170
167
  }, this.internalSignal);
171
168
  return o.controller = this.controller, this.then((c) => {
172
- const i = typeof e == "function" ? e(c) : e, u = { ...typeof t == "function" ? t(c) : t, signal: this.internalSignal };
173
- fetch(i, u).then((d) => r(d)).catch((d) => {
174
- d.name !== "AbortError" && n(d);
169
+ const i = typeof t == "function" ? t(c) : t, h = { ...typeof e == "function" ? e(c) : e, signal: this.internalSignal };
170
+ fetch(i, h).then((a) => r(a)).catch((a) => {
171
+ a.name !== "AbortError" && n(a);
175
172
  });
176
173
  }), o;
177
174
  }
@@ -179,13 +176,13 @@ class s extends Promise {
179
176
  * Executes the callback passed as a parameter when the futurable is cancelled.
180
177
  * @param cb: callback
181
178
  */
182
- onCancel(e) {
183
- let t, r;
184
- const n = new s((o, c, i) => {
185
- i.onCancel(e), t = o, r = c;
179
+ onCancel(t) {
180
+ let e, r;
181
+ const n = new l((o, c, i) => {
182
+ i.onCancel(t), e = o, r = c;
186
183
  }, this.internalSignal);
187
184
  return n.controller = this.controller, this.then(
188
- (o) => t(o),
185
+ (o) => e(o),
189
186
  (o) => r(o)
190
187
  ), n;
191
188
  }
@@ -206,101 +203,127 @@ class s extends Promise {
206
203
  * Takes a promise and transforms it into a futurizable. Promise can be also a function that receives value from futurable chaining as parameter.
207
204
  * @param promise: Promise to futurize or function that return promise with futurable chaining value as parameter
208
205
  */
209
- futurizable(e) {
210
- let t, r;
211
- const n = new s((o, c) => {
212
- t = o, r = c;
206
+ futurizable(t) {
207
+ let e, r;
208
+ const n = new l((o, c) => {
209
+ e = o, r = c;
213
210
  }, this.internalSignal);
214
211
  return n.controller = this.controller, this.then((o) => {
215
- (typeof e == "function" ? e(o) : e).then(t).catch(r);
212
+ (typeof t == "function" ? t(o) : t).then(e).catch(r);
216
213
  }), n;
217
214
  }
218
- static resolve(e, t) {
219
- return new s((r) => r(e), t);
215
+ static resolve(t, e) {
216
+ return t ? new l((r) => r(t), e) : new l((r) => r(), e);
220
217
  }
221
- static reject(e, t) {
222
- return new s((r, n) => n(e), t);
218
+ static reject(t, e) {
219
+ return new l((r, n) => n(t), e);
223
220
  }
224
221
  /**
225
222
  * OnCancel static method. It accepts a callback or a object with cb property and an optional signal.
226
223
  */
227
- static onCancel({ cb: e, signal: t }) {
228
- return new s((r, n, o) => {
229
- o.onCancel(() => r(e()));
230
- }, t);
224
+ static onCancel({ cb: t, signal: e }) {
225
+ return new l((r, n, o) => {
226
+ o.onCancel(() => r(t()));
227
+ }, e);
231
228
  }
232
229
  /**
233
230
  * Delay static method. It accepts a object with timer and cb properties and an optional signal property.
234
231
  */
235
- static delay({ cb: e, timer: t, signal: r }) {
236
- return new s((n, o, c) => {
237
- c.delay(e, t).then(n);
232
+ static delay({ cb: t, timer: e, signal: r }) {
233
+ return new l((n, o, c) => {
234
+ c.delay(t, e).then(n, o);
238
235
  }, r);
239
236
  }
240
237
  /**
241
238
  * Sleep static method. It accepts a timer or a object with timer property and an optional signal.
242
239
  */
243
- static sleep({ timer: e, signal: t }) {
244
- return s.delay({
240
+ static sleep({ timer: t, signal: e }) {
241
+ return l.delay({
245
242
  cb: () => {
246
243
  },
247
- timer: e,
248
- signal: t
244
+ timer: t,
245
+ signal: e
249
246
  });
250
247
  }
251
248
  /**
252
249
  * Fetch static method.
253
250
  */
254
- static fetch(e, t) {
255
- const r = (t == null ? void 0 : t.signal) || void 0;
256
- return t != null && t.signal && delete t.signal, new s((n, o, c) => {
257
- c.fetch(e, t).then(n);
251
+ static fetch(t, e) {
252
+ const r = (e == null ? void 0 : e.signal) || void 0;
253
+ return e != null && e.signal && delete e.signal, new l((n, o, c) => {
254
+ c.fetch(t, e).then(n);
258
255
  }, r);
259
256
  }
260
257
  /**
261
258
  * Futurizable static method.
262
259
  */
263
- static futurizable({ promise: e, signal: t }) {
264
- return new s((r, n) => {
265
- e.then(r).catch(n);
266
- }, t);
260
+ static futurizable({ promise: t, signal: e }) {
261
+ return new l((r, n) => {
262
+ t.then(r).catch(n);
263
+ }, e);
267
264
  }
268
- static handleIterables(e, t) {
269
- const r = {
270
- array: []
271
- };
272
- r.f = new s((n, o, c) => {
273
- r.resolve = n, r.reject = o, c.onCancel(() => {
274
- for (const i of r.array)
275
- i.cancel();
276
- });
277
- }, t), t || (t = r.f.internalSignal);
278
- for (const n in e)
279
- e[n] instanceof s ? r.array.push(e[n]) : e[n] instanceof Promise ? r.array.push(new s((o, c) => {
280
- e[n].then((u) => o(u)).catch(c);
281
- }, t)) : r.array.push(s.resolve(e[n], t));
265
+ static handleValues(t, e) {
266
+ const r = [];
267
+ for (const n in t)
268
+ t[n] instanceof l ? r.push(t[n]) : t[n] instanceof Promise ? r.push(
269
+ new l(
270
+ (o, c) => {
271
+ t[n].then((i) => o(i)).catch(c);
272
+ },
273
+ e
274
+ )
275
+ ) : r.push(
276
+ new l(
277
+ (o) => o(t[n]),
278
+ e
279
+ )
280
+ );
282
281
  return r;
283
282
  }
284
283
  /**
285
284
  * 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.
286
285
  */
287
- static all(e, t) {
288
- const { f: r, resolve: n, reject: o, array: c } = s.handleIterables(e, t);
289
- return super.all(c).then(n).catch(o), r;
286
+ static all(t, e) {
287
+ let r, n;
288
+ const o = new l((i, h, a) => {
289
+ r = i, n = h, a.onCancel(() => {
290
+ for (const f of c)
291
+ f.cancel();
292
+ });
293
+ }, e);
294
+ e || (e = o.internalSignal);
295
+ const c = l.handleValues(t, e);
296
+ return super.all(c).then((i) => r(i)).catch((i) => n(i)), o;
290
297
  }
291
298
  /**
292
299
  * Creates a Futurable with cancellation support that is resolved with an array of results when all of the provided Futurables resolve or reject.
293
300
  */
294
- static allSettled(e, t) {
295
- const { f: r, resolve: n, reject: o, array: c } = s.handleIterables(e, t);
296
- return super.allSettled(c).then(n).catch(o), r;
301
+ static allSettled(t, e) {
302
+ let r;
303
+ const n = new l((c, i, h) => {
304
+ r = c, h.onCancel(() => {
305
+ for (const a of o)
306
+ a.cancel();
307
+ });
308
+ }, e);
309
+ e || (e = n.internalSignal);
310
+ const o = l.handleValues(t, e);
311
+ return super.allSettled(o).then((c) => r(c)), n;
297
312
  }
298
313
  /**
299
314
  * Creates a Futurable with cancellation support that is resolved or rejected when any of the provided Futurables are resolved or rejected.
300
315
  */
301
- static race(e, t) {
302
- const { f: r, resolve: n, reject: o, array: c } = s.handleIterables(e, t);
303
- return super.race(c).then(n).catch(o), r;
316
+ static race(t, e) {
317
+ let r, n;
318
+ const o = new l((i, h, a) => {
319
+ r = i, n = h, a.onCancel(() => {
320
+ for (const f of c)
321
+ f.cancel();
322
+ });
323
+ }, e);
324
+ e || (e = o.internalSignal);
325
+ const c = l.handleValues(t, e);
326
+ return super.race(c).then((i) => r(i)).catch((i) => n(i)), o;
304
327
  }
305
328
  /**
306
329
  * The any function returns a futurable with cancellation support that is fulfilled by the first given futurable to be fulfilled,
@@ -308,11 +331,19 @@ class s extends Promise {
308
331
  * given futurables are rejected. It resolves all elements of the passed iterable to futurables as
309
332
  * it runs this algorithm.
310
333
  */
311
- static any(e, t) {
312
- const { f: r, resolve: n, reject: o, array: c } = s.handleIterables(e, t);
313
- return super.any(c).then(n).catch(o), r;
334
+ static any(t, e) {
335
+ let r, n;
336
+ const o = new l((i, h, a) => {
337
+ r = i, n = h, a.onCancel(() => {
338
+ for (const f of c)
339
+ f.cancel();
340
+ });
341
+ }, e);
342
+ e || (e = o.internalSignal);
343
+ const c = l.handleValues(t, e);
344
+ return super.any(c).then((i) => r(i)).catch((i) => n(i)), o;
314
345
  }
315
346
  }
316
347
  export {
317
- s as Futurable
348
+ l as Futurable
318
349
  };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,14 @@
1
- export type FuturableOnfulfilled<T, TResult2 = never> = ((value: any) => T | TResult2 | FuturableLike<T | TResult2> | PromiseLike<T | TResult2>) | undefined | null;
2
- export type FuturableOnrejected<TResult = never> = ((reason: any) => TResult | FuturableLike<TResult> | PromiseLike<TResult>) | undefined | null;
3
- export type FuturableResolveType<T> = T | FuturableLike<T> | PromiseLike<T>;
1
+ export interface FuturableLike<T> {
2
+ /**
3
+ * Attaches callbacks for the resolution and/or rejection of the Futurable.
4
+ * @param onfulfilled The callback to execute when the Futurable is resolved.
5
+ * @param onrejected The callback to execute when the Futurable is rejected.
6
+ * @returns A Futurable for the completion of which ever callback is executed.
7
+ */
8
+ 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): FuturableLike<TResult1 | TResult2>;
9
+ }
4
10
  export interface FuturableResolve<T> {
5
- (value?: FuturableResolveType<T>): void;
11
+ (value: T | FuturableLike<T> | PromiseLike<T>): void;
6
12
  }
7
13
  export interface FuturableReject {
8
14
  (reason?: any): void;
@@ -26,33 +32,30 @@ export interface FuturableUtils<T> {
26
32
  * @param cb: callback executed after timer
27
33
  * @param timer: timer to wait (in milliseconds)
28
34
  */
29
- delay: (cb: () => any, timer: number) => Futurable<T>;
35
+ delay: <TResult = T, TResult2 = never>(cb: () => TResult, timer: number) => FuturableLike<TResult | TResult2>;
30
36
  /**
31
37
  * Waits for timer parameter (in milliseconds) before returning the value.
32
38
  * @param timer: timer to wait (in milliseconds)
33
39
  */
34
- sleep: (timer: number) => Futurable<T>;
40
+ sleep: (timer: number) => FuturableLike<void>;
35
41
  /**
36
42
  * 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.
37
43
  * @param url: url to fetch
38
44
  * @param opts: fetch options
39
45
  */
40
- fetch: (url: string, opts?: RequestInit) => Futurable<T>;
46
+ fetch: (url: string, opts?: RequestInit) => Futurable<Response>;
41
47
  /**
42
48
  * Takes a promise and transforms it into a futurizable. Promise can be also a function that receives value from futurable chaining as parameter.
43
49
  * @param promise: Promise to futurize
44
50
  */
45
- futurizable: (promise: Promise<T>) => Futurable<T>;
51
+ futurizable: <TResult = any>(promise: Promise<TResult>) => Futurable<TResult>;
46
52
  }
47
53
  export type FuturableExecutor<T> = (resolve: FuturableResolve<T>, reject: FuturableReject,
48
54
  /**
49
55
  * Object containing implemented functionalities.
50
56
  */
51
57
  utils: FuturableUtils<T>) => void;
52
- export type FuturableIterable<T = any> = Futurable<T> | Promise<T> | T;
53
- export interface FuturableLike<T> {
54
- then<TResult1 = T, TResult2 = never>(onfulfilled?: FuturableOnfulfilled<TResult1, TResult2>, onrejected?: FuturableOnrejected<TResult2>): FuturableLike<TResult1 | TResult2>;
55
- }
58
+ export type FuturableIterable<T = any> = Iterable<FuturableLike<T> | PromiseLike<T> | T>;
56
59
  export declare class Futurable<T> extends Promise<T> {
57
60
  private controller;
58
61
  private internalSignal;
@@ -68,15 +71,16 @@ export declare class Futurable<T> extends Promise<T> {
68
71
  /**
69
72
  * Attaches callbacks for the resolution and/or rejection of the Futurable.
70
73
  */
71
- then<TResult1 = T, TResult2 = never>(onFulfilled: FuturableOnfulfilled<TResult1, TResult2>, onRejected?: FuturableOnrejected<TResult2>): Futurable<TResult1 | TResult2>;
74
+ 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>;
72
75
  /**
73
76
  * Attaches a callback for only the rejection of the Futurable.
74
77
  */
75
- catch<TResult = never>(onRejected: FuturableOnrejected<TResult>): Futurable<T | TResult>;
78
+ catch<TResult2 = never>(onRejected: ((reason: any) => TResult2 | PromiseLike<TResult2> | FuturableLike<TResult2>) | undefined | null): Futurable<T | TResult2>;
76
79
  /**
77
- * Attaches a callback that is invoked when the Futurable is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.
80
+ * Attaches a callback that is invoked when the Futurable is settled (fulfilled or rejected).
81
+ * The resolved value cannot be modified from the callback.
78
82
  */
79
- finally(onFinally: () => void): Futurable<void>;
83
+ finally(onfinally: () => void | undefined | null): Futurable<T>;
80
84
  /**
81
85
  * Cancel the futurable if it is to be executed or if it is still executing.
82
86
  */
@@ -86,18 +90,18 @@ export declare class Futurable<T> extends Promise<T> {
86
90
  * @param cb: callback executed after timer with futurable chain value as parameter
87
91
  * @param timer: timer to wait (in milliseconds)
88
92
  */
89
- delay<TResult1 = T, TResult2 = never>(cb: (val?: TResult1) => any, timer: number): Futurable<TResult1 | TResult2>;
93
+ delay<TResult1 = T, TResult2 = never>(cb: (val: T) => TResult1 | PromiseLike<TResult1> | FuturableLike<TResult1>, timer: number): Futurable<TResult1 | TResult2>;
90
94
  /**
91
95
  * Waits for timer parameter (in milliseconds) before returning the value.
92
96
  * @param timer: timer to wait (in milliseconds)
93
97
  */
94
- sleep<TResult1 = T, TResult2 = never>(timer: number): Futurable<TResult1 | TResult2>;
98
+ sleep(timer: number): Futurable<T>;
95
99
  /**
96
100
  * 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.
97
101
  * @param url: url to fetch or function with futurable chaining value that returns url to fetch
98
102
  * @param opts: fetch options or function with futurable chaining value that return fetch options
99
103
  */
100
- fetch<TResult1 = T, TResult2 = never>(url: string | ((val?: TResult1) => string), opts?: object | RequestInit | ((val?: TResult1) => RequestInit)): Futurable<TResult1 | TResult2>;
104
+ fetch(url: string | ((val?: T) => string), opts?: object | RequestInit | ((val?: T) => RequestInit)): Futurable<Response>;
101
105
  /**
102
106
  * Executes the callback passed as a parameter when the futurable is cancelled.
103
107
  * @param cb: callback
@@ -107,9 +111,10 @@ export declare class Futurable<T> extends Promise<T> {
107
111
  * Takes a promise and transforms it into a futurizable. Promise can be also a function that receives value from futurable chaining as parameter.
108
112
  * @param promise: Promise to futurize or function that return promise with futurable chaining value as parameter
109
113
  */
110
- futurizable<TResult1 = any, TResult2 = never>(promise: Promise<TResult1> | ((val?: TResult1) => Promise<TResult1>)): Futurable<TResult1 | TResult2>;
111
- static resolve<T = any, TResult2 = never>(value?: T, signal?: AbortSignal): Futurable<T | TResult2>;
112
- static reject<T = any, TResult2 = never>(reason?: T, signal?: AbortSignal): Futurable<T | TResult2>;
114
+ futurizable<TResult1 = T, TResult2 = never>(promise: Promise<TResult1> | ((val?: T) => Promise<TResult1>)): Futurable<TResult1 | TResult2>;
115
+ static resolve(): Futurable<void>;
116
+ static resolve<T = any>(value: T | PromiseLike<T> | FuturableLike<T>, signal?: AbortSignal): Futurable<T>;
117
+ static reject<T = never>(reason?: any, signal?: AbortSignal): Futurable<T>;
113
118
  /**
114
119
  * OnCancel static method. It accepts a callback or a object with cb property and an optional signal.
115
120
  */
@@ -128,14 +133,14 @@ export declare class Futurable<T> extends Promise<T> {
128
133
  /**
129
134
  * Sleep static method. It accepts a timer or a object with timer property and an optional signal.
130
135
  */
131
- static sleep<T = any, TResult2 = never>({ timer, signal }: {
136
+ static sleep({ timer, signal }: {
132
137
  timer: number;
133
138
  signal?: AbortSignal;
134
- }): Futurable<T | TResult2>;
139
+ }): Futurable<void>;
135
140
  /**
136
141
  * Fetch static method.
137
142
  */
138
- static fetch<T = any, TResult2 = never>(url: string, opts?: RequestInit): Futurable<T | TResult2>;
143
+ static fetch(url: string, opts?: RequestInit): Futurable<Response>;
139
144
  /**
140
145
  * Futurizable static method.
141
146
  */
@@ -143,33 +148,29 @@ export declare class Futurable<T> extends Promise<T> {
143
148
  promise: Promise<TResult1>;
144
149
  signal?: AbortSignal;
145
150
  }): Futurable<TResult1 | TResult2>;
146
- private static handleIterables;
151
+ private static handleValues;
147
152
  /**
148
153
  * 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.
149
154
  */
150
- static all<T extends readonly unknown[] | []>(iterables: FuturableIterable[], signal?: AbortSignal): Futurable<{
155
+ static all<T extends readonly unknown[] | []>(values: T, signal?: AbortSignal): Futurable<{
151
156
  -readonly [P in keyof T]: Awaited<T[P]>;
152
157
  }>;
153
158
  /**
154
159
  * Creates a Futurable with cancellation support that is resolved with an array of results when all of the provided Futurables resolve or reject.
155
160
  */
156
- static allSettled<T extends readonly unknown[] | []>(iterables: FuturableIterable[], signal?: AbortSignal): Futurable<{
157
- -readonly [P in keyof T]: Awaited<T[P]>;
161
+ static allSettled<T extends readonly unknown[] | []>(values: T, signal?: AbortSignal): Futurable<{
162
+ -readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>>;
158
163
  }>;
159
164
  /**
160
165
  * Creates a Futurable with cancellation support that is resolved or rejected when any of the provided Futurables are resolved or rejected.
161
166
  */
162
- static race<T extends readonly unknown[] | []>(iterables: FuturableIterable[], signal?: AbortSignal): Futurable<{
163
- -readonly [P in keyof T]: Awaited<T[P]>;
164
- }>;
167
+ static race<T extends readonly unknown[] | []>(values: T, signal?: AbortSignal): Futurable<Awaited<T[number]>>;
165
168
  /**
166
169
  * The any function returns a futurable with cancellation support that is fulfilled by the first given futurable to be fulfilled,
167
170
  * or rejected with an AggregateError containing an array of rejection reasons if all of the
168
171
  * given futurables are rejected. It resolves all elements of the passed iterable to futurables as
169
172
  * it runs this algorithm.
170
173
  */
171
- static any<T extends readonly unknown[] | []>(iterables: FuturableIterable[], signal?: AbortSignal): Futurable<{
172
- -readonly [P in keyof T]: Awaited<T[P]>;
173
- }>;
174
+ static any<T extends readonly unknown[] | []>(value: T, signal?: AbortSignal): Futurable<Awaited<T[number]>>;
174
175
  }
175
176
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,CAAC,CAAC,EAAE,QAAQ,GAAG,KAAK,IAAI,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,GAAG,QAAQ,GAAG,aAAa,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,WAAW,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;AAEpK,MAAM,MAAM,mBAAmB,CAAC,OAAO,GAAG,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;AAEjJ,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAE5E,MAAM,WAAW,gBAAgB,CAAC,CAAC;IAClC,CAAC,KAAK,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CACxC;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,EAAE,EAAE,MAAM,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC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E,WAAW,CAAA;KAAE,GAAG,SAAS,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAQ3J,OAAO,CAAC,MAAM,CAAC,YAAY;IA+B3B;;OAEG;IACH,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;QAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAAG,CAAC;IAmBvI;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;QAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAAE,CAAC;IAkBnK;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAmB9G;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;CAkB5G"}
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": "1.1.0",
5
+ "version": "1.2.0",
6
6
  "type": "module",
7
7
  "engines": {
8
8
  "node": ">=16.13.2"