@ndriadev/futurable 3.0.0 → 3.0.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/CHANGELOG.md +36 -29
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,65 +1,72 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [3.0.
|
|
3
|
+
## [3.0.1](https://github.com/nDriaDev/futurable/releases/tag/v3.0.1) - 2026-02-19
|
|
4
|
+
|
|
5
|
+
### Chores
|
|
6
|
+
|
|
7
|
+
- update dependencies ([df89035](https://github.com/nDriaDev/futurable/commit/df89035))
|
|
8
|
+
- update automated scripts ([e27d4a1](https://github.com/nDriaDev/futurable/commit/e27d4a1))
|
|
9
|
+
|
|
10
|
+
## [3.0.0](https://github.com/nDriaDev/futurable/releases/tag/v3.0.0) - 2026-02-16
|
|
4
11
|
|
|
5
12
|
### Features
|
|
6
13
|
|
|
7
|
-
- safe method implementation ([992ad49](https://github.com/nDriaDev/
|
|
8
|
-
- lazy futurable implementation ([d75f0d2](https://github.com/nDriaDev/
|
|
14
|
+
- safe method implementation ([992ad49](https://github.com/nDriaDev/futurable/commit/992ad49))
|
|
15
|
+
- lazy futurable implementation ([d75f0d2](https://github.com/nDriaDev/futurable/commit/d75f0d2))
|
|
9
16
|
|
|
10
17
|
### Bug Fixes
|
|
11
18
|
|
|
12
|
-
- futurable task test ([1868b39](https://github.com/nDriaDev/
|
|
13
|
-
- lint ([01bec2e](https://github.com/nDriaDev/
|
|
14
|
-
- futurable constructor ([bcc5b61](https://github.com/nDriaDev/
|
|
15
|
-
- internal signal handling ([1cd035c](https://github.com/nDriaDev/
|
|
16
|
-
- withResolvers cancel binding ([62ad1b8](https://github.com/nDriaDev/
|
|
17
|
-
- polling error handler ([67f3712](https://github.com/nDriaDev/
|
|
19
|
+
- futurable task test ([1868b39](https://github.com/nDriaDev/futurable/commit/1868b39))
|
|
20
|
+
- lint ([01bec2e](https://github.com/nDriaDev/futurable/commit/01bec2e))
|
|
21
|
+
- futurable constructor ([bcc5b61](https://github.com/nDriaDev/futurable/commit/bcc5b61))
|
|
22
|
+
- internal signal handling ([1cd035c](https://github.com/nDriaDev/futurable/commit/1cd035c))
|
|
23
|
+
- withResolvers cancel binding ([62ad1b8](https://github.com/nDriaDev/futurable/commit/62ad1b8))
|
|
24
|
+
- polling error handler ([67f3712](https://github.com/nDriaDev/futurable/commit/67f3712))
|
|
18
25
|
|
|
19
26
|
### Performance Improvements
|
|
20
27
|
|
|
21
|
-
- performance improvements ([8262198](https://github.com/nDriaDev/
|
|
28
|
+
- performance improvements ([8262198](https://github.com/nDriaDev/futurable/commit/8262198))
|
|
22
29
|
|
|
23
30
|
### Code Refactoring
|
|
24
31
|
|
|
25
|
-
- riorganize code ([613bef7](https://github.com/nDriaDev/
|
|
26
|
-
- doc e code refacotring ([0a4f15c](https://github.com/nDriaDev/
|
|
32
|
+
- riorganize code ([613bef7](https://github.com/nDriaDev/futurable/commit/613bef7))
|
|
33
|
+
- doc e code refacotring ([0a4f15c](https://github.com/nDriaDev/futurable/commit/0a4f15c))
|
|
27
34
|
|
|
28
35
|
### Documentation
|
|
29
36
|
|
|
30
|
-
- update README ([dac71e8](https://github.com/nDriaDev/
|
|
31
|
-
- add futurableTask documentation pages ([eacd451](https://github.com/nDriaDev/
|
|
32
|
-
- add futurableTask documentation pages ([aa53577](https://github.com/nDriaDev/
|
|
33
|
-
- fix documentation ([fda9ba7](https://github.com/nDriaDev/
|
|
37
|
+
- update README ([dac71e8](https://github.com/nDriaDev/futurable/commit/dac71e8))
|
|
38
|
+
- add futurableTask documentation pages ([eacd451](https://github.com/nDriaDev/futurable/commit/eacd451))
|
|
39
|
+
- add futurableTask documentation pages ([aa53577](https://github.com/nDriaDev/futurable/commit/aa53577))
|
|
40
|
+
- fix documentation ([fda9ba7](https://github.com/nDriaDev/futurable/commit/fda9ba7))
|
|
34
41
|
|
|
35
42
|
### Tests
|
|
36
43
|
|
|
37
|
-
- replace jest with vitest ([864cc5e](https://github.com/nDriaDev/
|
|
38
|
-
- futurabletask test ([9317ad0](https://github.com/nDriaDev/
|
|
44
|
+
- replace jest with vitest ([864cc5e](https://github.com/nDriaDev/futurable/commit/864cc5e))
|
|
45
|
+
- futurabletask test ([9317ad0](https://github.com/nDriaDev/futurable/commit/9317ad0))
|
|
39
46
|
|
|
40
47
|
### Chores
|
|
41
48
|
|
|
42
|
-
- update dependencies ([f229da8](https://github.com/nDriaDev/
|
|
43
|
-
- update tsconfig ([e71f059](https://github.com/nDriaDev/
|
|
44
|
-
- update build configuration ([65891a2](https://github.com/nDriaDev/
|
|
49
|
+
- update dependencies ([f229da8](https://github.com/nDriaDev/futurable/commit/f229da8))
|
|
50
|
+
- update tsconfig ([e71f059](https://github.com/nDriaDev/futurable/commit/e71f059))
|
|
51
|
+
- update build configuration ([65891a2](https://github.com/nDriaDev/futurable/commit/65891a2))
|
|
45
52
|
|
|
46
|
-
## [2.3.5](https://github.com/nDriaDev/
|
|
53
|
+
## [2.3.5](https://github.com/nDriaDev/futurable/releases/tag/v2.3.5) - 2026-02-06
|
|
47
54
|
|
|
48
55
|
- Initial release
|
|
49
56
|
|
|
50
|
-
## [2.3.4](https://github.com/nDriaDev/
|
|
57
|
+
## [2.3.4](https://github.com/nDriaDev/futurable/releases/tag/v2.3.4) - 2026-02-06
|
|
51
58
|
|
|
52
59
|
### Bug Fixes
|
|
53
60
|
|
|
54
|
-
- gitignore ([11759fe](https://github.com/nDriaDev/
|
|
55
|
-
- [FIX] docs ([4b80d05](https://github.com/nDriaDev/
|
|
61
|
+
- gitignore ([11759fe](https://github.com/nDriaDev/futurable/commit/11759fe))
|
|
62
|
+
- [FIX] docs ([4b80d05](https://github.com/nDriaDev/futurable/commit/4b80d05))
|
|
56
63
|
|
|
57
64
|
### Chores
|
|
58
65
|
|
|
59
|
-
- update dependencies ([f90aadb](https://github.com/nDriaDev/
|
|
60
|
-
- update dependencies ([16e1592](https://github.com/nDriaDev/
|
|
61
|
-
- update dependencies ([cd4df57](https://github.com/nDriaDev/
|
|
62
|
-
- refactor library ([7623ed9](https://github.com/nDriaDev/
|
|
66
|
+
- update dependencies ([f90aadb](https://github.com/nDriaDev/futurable/commit/f90aadb))
|
|
67
|
+
- update dependencies ([16e1592](https://github.com/nDriaDev/futurable/commit/16e1592))
|
|
68
|
+
- update dependencies ([cd4df57](https://github.com/nDriaDev/futurable/commit/cd4df57))
|
|
69
|
+
- refactor library ([7623ed9](https://github.com/nDriaDev/futurable/commit/7623ed9))
|
|
63
70
|
|
|
64
71
|
## [Unreleased]
|
|
65
72
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";class Futurable extends Promise{controller;internalSignal;idsTimeout;constructor(t,n){const e=new AbortController,i=e.signal,s=[];n&&(n.aborted?e.abort():n.addEventListener("abort",()=>e.abort(),{once:!0}));let c=[];const r=o=>{c.push(o)},a=()=>{for(const o of s)clearTimeout(o);s.length=0},l={signal:i,cancel:()=>e.abort(),onCancel:r,delay:(o,f)=>new Futurable(h=>{s.push(setTimeout(()=>{h(o())},f))},i),sleep:o=>l.delay(()=>{},o),fetch:(o,f)=>new Futurable((h,u)=>{fetch(o,{...f||{},signal:i}).then(g=>h(g)).catch(g=>{g.name!=="AbortError"&&u(g)})},i),futurizable:o=>new Futurable((f,h)=>{o.then(f).catch(h)},i)},d=new Promise((o,f)=>{if(i.aborted){a();return}else{const h=()=>{a(),c.forEach(g=>g()),c=[]},u=()=>{i.removeEventListener("abort",h)};i.addEventListener("abort",h,{once:!0}),t(g=>{u(),o(g)},g=>{u(),f(g)},l)}});super((o,f)=>{d.then(h=>o(h)).catch(f)}),this.controller=e,this.internalSignal=i,this.idsTimeout=s}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);this.idsTimeout.length=0}then(t,n){let e,i;const s=new Futurable((c,r)=>{e=c,i=r},this.internalSignal);return s.controller=this.controller,super.then(c=>{var r;if((r=this.internalSignal)!=null&&r.aborted){this.clearTimeout();return}try{e(t?t(c):c)}catch(a){i(a)}},c=>{var r;if((r=this.internalSignal)!=null&&r.aborted){this.clearTimeout();return}try{n?e(n(c)):i(c)}catch(a){i(a)}}),s}catch(t){return this.then(null,t)}finally(t){return this.then(n=>(t(),n),n=>{if(t(),n instanceof Error)throw n;return n})}cancel(){var t;!((t=this.internalSignal)!=null&&t.aborted)&&this.controller.abort()}delay(t,n){return this.then(e=>new Futurable(i=>{this.idsTimeout.push(setTimeout(()=>i(t(e)),n))},this.internalSignal))}sleep(t){return this.delay(n=>n,t)}fetch(t,n){return this.then(e=>{const i=typeof t=="function"?t(e):t,s={...typeof n=="function"?n(e):n,signal:this.internalSignal};return new Futurable((c,r)=>{fetch(i,s).then(c).catch(a=>{a.name!=="AbortError"&&r(a)})})})}onCancel(t){const n=new Futurable((e,i,s)=>{s.onCancel(t),this.then(c=>e(c),c=>i(c))},this.internalSignal);return n.controller=this.controller,n}futurizable(t){return this.then(n=>{const e=typeof t=="function"?t(n):t;return new Futurable((i,s)=>{e.then(i).catch(s)},this.internalSignal)})}safe(){return this.then(t=>({success:!0,data:t,error:null}),t=>({success:!1,data:null,error:t}))}static resolve(t,n){return t?new Futurable(e=>e(t),n):new Futurable(e=>e(),n)}static reject(t,n){return new Futurable((e,i)=>i(t),n)}static onCancel({cb:t,signal:n}){return new Futurable((e,i,s)=>{s.onCancel(()=>e(t()))},n)}static delay({cb:t,timer:n,signal:e}){return new Futurable((i,s,c)=>{c.delay(t,n).then(i,s)},e)}static sleep({timer:t,signal:n}){return Futurable.delay({cb:()=>{},timer:t,signal:n})}static fetch(t,n){const e=(n==null?void 0:n.signal)||void 0;return n!=null&&n.signal&&delete n.signal,new Futurable((i,s,c)=>{c.fetch(t,n).then(i).catch(s)},e)}static futurizable({promise:t,signal:n}){return new Futurable((e,i)=>{t.then(e).catch(i)},n)}static handleValues(t,n){const e=[];for(const i of t)i instanceof Futurable?e.push(i):i instanceof Promise?e.push(new Futurable((s,c)=>{i.then(r=>s(r)).catch(c)},n)):e.push(new Futurable(s=>s(i),n));return e}static all(t,n){let e,i;const s=new Futurable((r,a,l)=>{e=r,i=a,l.onCancel(()=>{for(const d of c)d.cancel()})},n);n||=s.internalSignal;const c=Futurable.handleValues(t,n);return super.all(c).then(r=>e(r)).catch(r=>i(r)),s}static allSettled(t,n){let e;const i=new Futurable((c,r,a)=>{e=c,a.onCancel(()=>{for(const l of s)l.cancel()})},n);n||=i.internalSignal;const s=Futurable.handleValues(t,n);return super.allSettled(s).then(c=>e(c)),i}static race(t,n){let e,i;const s=new Futurable((r,a,l)=>{e=r,i=a,l.onCancel(()=>{for(const d of c)d.cancel()})},n);n||=s.internalSignal;const c=Futurable.handleValues(t,n);return super.race(c).then(r=>e(r)).catch(r=>i(r)),s}static any(t,n){let e,i;const s=new Futurable((r,a,l)=>{e=r,i=a,l.onCancel(()=>{for(const d of c)d.cancel()})},n);n||=s.internalSignal;const c=Futurable.handleValues(t,n);return super.any(c).then(r=>e(r)).catch(r=>i(r)),s}static polling(t,{interval:n,signal:e,immediate:i}){let s,c;const r=[];let a=o=>{r.push(o)};const l=()=>{s&&s.cancel(),s=new Futurable((o,f,h)=>{h.onCancel(()=>{c&&c instanceof Futurable&&c.cancel()});try{const u=t();u instanceof Futurable||u instanceof Promise?c=u.then(()=>o()).catch(g=>{a(g)}):o()}catch(u){a(u)}},e)};i&&l();const d=setInterval(l,n);return{cancel:()=>{d&&clearInterval(d),s&&s.cancel(),c&&c instanceof Futurable&&c.cancel()},catch:o=>{a=o,r.length>0&&(r.forEach(f=>o(f)),r.length=0)}}}static withResolvers(t){let n,e,i;const s=new Futurable((r,a,l)=>{n=r,e=a,i=l},t),c=s.cancel.bind(s);return{resolve:n,reject:e,utils:i,cancel:c,promise:s}}static safe(t,n){return new Futurable(t,n).safe()}}class FuturableTask{constructor(t,n){this.executor=t,this.controller=new AbortController,this.controller.signal.addEventListener("abort",()=>{this.cancelCallbacks.forEach(e=>e())},{once:!0}),n&&(n.aborted?this.controller.abort():n.addEventListener("abort",()=>this.controller.abort(),{once:!0}))}controller;cancelCallbacks=[];memoizeOptions={enabled:!1,catchErrors:!1};sourceTask;get signal(){return this.controller.signal}cancel(){this.controller.signal.aborted||this.controller.abort()}onCancel(t){return this.cancelCallbacks.push(t),this}run(t){if(this.memoizeOptions.enabled&&this.memoizeOptions.instance)if(this.memoizeOptions.instance.signal.aborted)delete this.memoizeOptions.instance;else return this.memoizeOptions.instance;const n=new AbortController;this.signal.aborted?n.abort():this.signal.addEventListener("abort",()=>n.abort(),{once:!0}),t&&(t.aborted?n.abort():t.addEventListener("abort",()=>n.abort(),{once:!0}));const e=new Futurable(this.executor,n.signal);return this.memoizeOptions.enabled&&(this.memoizeOptions.instance=e,this.memoizeOptions.catchErrors||e.catch(()=>{delete this.memoizeOptions.instance})),e}runSafe(t){return this.run(t).safe()}memoize(t){const n=new FuturableTask(this.executor,this.signal);return n.memoizeOptions.enabled=!0,n.memoizeOptions.catchErrors=t,n}map(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(s=>n(t(s,i.signal))).catch(e)},this.signal)}flatMap(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(s=>{t(s).run(i.signal).then(n).catch(e)}).catch(e)},this.signal)}andThen(t){return this.flatMap(()=>t)}tap(t){return this.map(async n=>(await t(n),n))}tapError(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(n).catch(async s=>{try{await t(s)}catch(c){console.error("tapError callback failed: ",c)}e(s)})},this.signal)}catchError(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(n).catch(s=>{t(s).run(i.signal).then(n).catch(e)})},this.signal)}orElse(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(n).catch(s=>{t(s).run(i.signal).then(n).catch(e)})},this.signal)}fallbackTo(t){return this.orElse(()=>FuturableTask.resolve(t))}ifElse(t,n,e){return new FuturableTask((i,s,c)=>{this.run(c.signal).then(async r=>{(await t(r)?n(r):e(r)).run(c.signal).then(i).catch(s)}).catch(s)},this.signal)}fold(t,n){return new FuturableTask((e,i,s)=>{this.run(s.signal).then(c=>{n(c).run(s.signal).then(e).catch(i)}).catch(c=>{t(c).run(s.signal).then(e).catch(i)})},this.signal)}finally(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(async s=>{await t(),n(s)}).catch(async s=>{await t(),e(s)})},this.signal)}timeout(t,n="TimeoutExceeded"){return new FuturableTask((e,i,s)=>{const c=setTimeout(()=>{r.cancel(),i(n)},t),r=this.run(s.signal);s.onCancel(()=>{clearTimeout(c)}),r.then(a=>{clearTimeout(c),e(a)}).catch(a=>{clearTimeout(c),i(a)})},this.signal)}delay(t){return new FuturableTask(async(n,e,i)=>{await i.sleep(t),this.run(i.signal).then(n).catch(e)},this.signal)}retry(t,n=0){return new FuturableTask(async(e,i,s)=>{let c;for(let r=0;r<=t;r++){if(s.signal.aborted)return;try{return e(await this.run(s.signal))}catch(a){c=a,r<t&&!s.signal.aborted&&n>0&&await s.sleep(n)}}i(c)},this.signal)}debounce(t){const n=this.sourceTask??this;let e=null;const i=new FuturableTask((s,c,r)=>{r.onCancel(()=>{e&&clearTimeout(e),e=null}),e&&clearTimeout(e),e=setTimeout(()=>{n.run(r.signal).then(s).catch(c).finally(()=>{e=null})},t)},this.signal);return i.sourceTask=n,i}throttle(t){let n=0,e;return new FuturableTask((i,s,c)=>{const r=Date.now();r-n>=t||!e?(n=r,e=this.run(c.signal),e.then(i).catch(s)):e&&e.then(i).catch(s)},this.signal)}zip(t){return new FuturableTask((n,e,i)=>{Futurable.all([this.run(i.signal),t.run(i.signal)],i.signal).then(([s,c])=>n([s,c])).catch(e)},this.signal)}zipWith(t,n){return this.zip(t).map(([e,i])=>n(e,i))}bimap(t,n){return new FuturableTask((e,i,s)=>{this.run(s.signal).then(c=>e(t(c))).catch(c=>i(n(c)))},this.signal)}repeat(t){return FuturableTask.times(t,()=>this)}pipe(...t){return t.reduce((n,e)=>e(n),this)}fetch(t,n){return new FuturableTask((e,i,s)=>{this.run(s.signal).then(c=>{const r=typeof t=="function"?t(c):t,a={...typeof n=="function"?n(c):n,signal:s.signal};s.fetch(r,a).then(e).catch(i)}).catch(i)},this.signal)}static of(t,n){return typeof t=="function"?new FuturableTask(async(e,i,s)=>{try{e(await t(s))}catch(c){i(c)}},n):new FuturableTask(e=>e(t),n)}static resolve(t,n){return FuturableTask.of(t,n)}static reject(t,n){return new FuturableTask((e,i)=>i(t),n)}static all(t,n){return new FuturableTask((e,i,s)=>{Futurable.all(t.map(c=>c.run(s.signal)),s.signal).then(e).catch(i)},n)}static allSettled(t,n){return new FuturableTask((e,i,s)=>{Futurable.allSettled(t.map(c=>c.run(s.signal)),s.signal).then(e).catch(i)},n)}static race(t,n){return new FuturableTask((e,i,s)=>{Futurable.race(t.map(c=>c.run(s.signal)),s.signal).then(e).catch(i)},n)}static any(t,n){return new FuturableTask((e,i,s)=>{Futurable.any(t.map(c=>c.run(s.signal)),s.signal).then(e).catch(i)},n)}static delay(t,n){return new FuturableTask((e,i,s)=>{s.sleep(t).then(e).catch(i)},n)}static fromEvent(t,n,e,i){return new FuturableTask((s,c,r)=>{r.onCancel(()=>t.removeEventListener(n,a));const a=l=>{!(e!=null&&e.once)&&t.removeEventListener(n,a),s(l)};t.addEventListener(n,a,e)},i)}static sequence(t,n){return new FuturableTask(async(e,i,s)=>{const c=[];try{for(const r of t){if(s.signal.aborted)return;c.push(await r.run(s.signal))}e(c)}catch(r){i(r)}},n)}static parallel(t,n=5,e){return new FuturableTask(async(i,s,c)=>{const r=new Array(t.length),a=[];let l=0,d=0,o=0;c.onCancel(()=>{a.forEach(h=>h.cancel())});const f=(h,u)=>{if(d===t.length)return h(r);for(;l<n&&o<t.length;){const g=o++;l++;const w=t[g].run(c.signal);a.push(w),w.then(p=>{r[g]=p,l--,d++;const m=a.indexOf(w);m!==-1&&a.splice(m,1),f(h,u)}).catch(p=>{a.forEach(m=>m.cancel()),u(p)})}};f(i,s)},e)}static createLimiter(t,n={},e){let i=0;const s=[],c=()=>{for(var a;i<t&&s.length>0;){const l=s.shift();l&&l()}i===0&&s.length===0&&((a=n.onIdle)==null||a.call(n))},r=a=>new FuturableTask((l,d,o)=>{let f=!1;const h=()=>{var u;f=!1,i++,(u=n.onActive)==null||u.call(n,a),a.run(o.signal).then(g=>{var w;(w=n.onCompleted)==null||w.call(n,g),l(g)}).catch(g=>{var w;(w=n.onError)==null||w.call(n,g),d(g)}).finally(()=>{i--,c()})};o.onCancel(()=>{if(f){const u=s.indexOf(h);u!==-1&&s.splice(u,1),c()}}),i<t?h():(f=!0,s.push(h))},e);return Object.defineProperties(r,{activeCount:{get:()=>i},pendingCount:{get:()=>s.length},concurrency:{get:()=>t}}),r}static compose(t,...n){return n.reduce((e,i)=>i(e),t)}static filter(t,n,e){return new FuturableTask(async(i,s,c)=>{const r=[];try{for(const a of t){if(c.signal.aborted)return;const l=await a.run(c.signal);await n(l)&&r.push(l)}i(r)}catch(a){s(a)}},e)}static reduce(t,n,e,i){return new FuturableTask(async(s,c,r)=>{let a=e;try{for(let l=0;l<t.length;l++){if(r.signal.aborted)return;const d=await t[l].run(r.signal);a=await n(a,d,l)}s(a)}catch(l){c(l)}},i)}static whilst(t,n,e){return new FuturableTask(async(i,s,c)=>{const r=[];try{for(;await t();){if(c.signal.aborted)return;r.push(await n.run(c.signal))}i(r)}catch(a){s(a)}},e)}static until(t,n,e){return FuturableTask.whilst(async()=>!await t(),n,e)}static times(t,n,e){return new FuturableTask(async(i,s,c)=>{const r=[];try{for(let a=0;a<t;a++){if(c.signal.aborted)return;r.push(await n(a).run(c.signal))}i(r)}catch(a){s(a)}},e)}static traverse(t,n,e){return FuturableTask.sequence(t.map((i,s)=>n(i,s)),e)}static fetch(t,n,e){return new FuturableTask((i,s,c)=>{const r={...n,signal:c.signal};c.fetch(t,r).then(i).catch(s)},e)}}exports.Futurable=Futurable;exports.FuturableTask=FuturableTask;
|
|
1
|
+
"use strict";class Futurable extends Promise{controller;internalSignal;idsTimeout;constructor(t,n){const e=new AbortController,i=e.signal,r=[];n&&(n.aborted?e.abort():n.addEventListener("abort",()=>e.abort(),{once:!0}));let s=[];const c=o=>{s.push(o)},a=()=>{for(const o of r)clearTimeout(o);r.length=0},l={signal:i,cancel:()=>e.abort(),onCancel:c,delay:(o,f)=>new Futurable(h=>{r.push(setTimeout(()=>{h(o())},f))},i),sleep:o=>l.delay(()=>{},o),fetch:(o,f)=>new Futurable((h,u)=>{fetch(o,{...f||{},signal:i}).then(g=>h(g)).catch(g=>{g.name!=="AbortError"&&u(g)})},i),futurizable:o=>new Futurable((f,h)=>{o.then(f).catch(h)},i)},d=new Promise((o,f)=>{if(i.aborted){a();return}else{const h=()=>{a(),s.forEach(g=>g()),s=[]},u=()=>{i.removeEventListener("abort",h)};i.addEventListener("abort",h,{once:!0}),t(g=>{u(),o(g)},g=>{u(),f(g)},l)}});super((o,f)=>{d.then(h=>o(h)).catch(f)}),this.controller=e,this.internalSignal=i,this.idsTimeout=r}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);this.idsTimeout.length=0}then(t,n){let e,i;const r=new Futurable((s,c)=>{e=s,i=c},this.internalSignal);return r.controller=this.controller,super.then(s=>{var c;if((c=this.internalSignal)!=null&&c.aborted){this.clearTimeout();return}try{e(t?t(s):s)}catch(a){i(a)}},s=>{var c;if((c=this.internalSignal)!=null&&c.aborted){this.clearTimeout();return}try{n?e(n(s)):i(s)}catch(a){i(a)}}),r}catch(t){return this.then(null,t)}finally(t){return this.then(n=>(t(),n),n=>{if(t(),n instanceof Error)throw n;return n})}cancel(){var t;!((t=this.internalSignal)!=null&&t.aborted)&&this.controller.abort()}delay(t,n){return this.then(e=>new Futurable(i=>{this.idsTimeout.push(setTimeout(()=>i(t(e)),n))},this.internalSignal))}sleep(t){return this.delay(n=>n,t)}fetch(t,n){return this.then(e=>{const i=typeof t=="function"?t(e):t,r={...typeof n=="function"?n(e):n,signal:this.internalSignal};return new Futurable((s,c)=>{fetch(i,r).then(s).catch(a=>{a.name!=="AbortError"&&c(a)})})})}onCancel(t){const n=new Futurable((e,i,r)=>{r.onCancel(t),this.then(s=>e(s),s=>i(s))},this.internalSignal);return n.controller=this.controller,n}futurizable(t){return this.then(n=>{const e=typeof t=="function"?t(n):t;return new Futurable((i,r)=>{e.then(i).catch(r)},this.internalSignal)})}safe(){return this.then(t=>({success:!0,data:t,error:null}),t=>({success:!1,data:null,error:t}))}static resolve(t,n){return t?new Futurable(e=>e(t),n):new Futurable(e=>e(),n)}static reject(t,n){return new Futurable((e,i)=>i(t),n)}static onCancel({cb:t,signal:n}){return new Futurable((e,i,r)=>{r.onCancel(()=>e(t()))},n)}static delay({cb:t,timer:n,signal:e}){return new Futurable((i,r,s)=>{s.delay(t,n).then(i,r)},e)}static sleep({timer:t,signal:n}){return Futurable.delay({cb:()=>{},timer:t,signal:n})}static fetch(t,n){const e=(n==null?void 0:n.signal)||void 0;return n!=null&&n.signal&&delete n.signal,new Futurable((i,r,s)=>{s.fetch(t,n).then(i).catch(r)},e)}static futurizable({promise:t,signal:n}){return new Futurable((e,i)=>{t.then(e).catch(i)},n)}static handleValues(t,n){const e=[];for(const i of t)i instanceof Futurable?e.push(i):i instanceof Promise?e.push(new Futurable((r,s)=>{i.then(c=>r(c)).catch(s)},n)):e.push(new Futurable(r=>r(i),n));return e}static all(t,n){let e,i;const r=new Futurable((c,a,l)=>{e=c,i=a,l.onCancel(()=>{for(const d of s)d.cancel()})},n);n||=r.internalSignal;const s=Futurable.handleValues(t,n);return super.all(s).then(c=>e(c)).catch(c=>i(c)),r}static allSettled(t,n){let e;const i=new Futurable((s,c,a)=>{e=s,a.onCancel(()=>{for(const l of r)l.cancel()})},n);n||=i.internalSignal;const r=Futurable.handleValues(t,n);return super.allSettled(r).then(s=>e(s)),i}static race(t,n){let e,i;const r=new Futurable((c,a,l)=>{e=c,i=a,l.onCancel(()=>{for(const d of s)d.cancel()})},n);n||=r.internalSignal;const s=Futurable.handleValues(t,n);return super.race(s).then(c=>e(c)).catch(c=>i(c)),r}static any(t,n){let e,i;const r=new Futurable((c,a,l)=>{e=c,i=a,l.onCancel(()=>{for(const d of s)d.cancel()})},n);n||=r.internalSignal;const s=Futurable.handleValues(t,n);return super.any(s).then(c=>e(c)).catch(c=>i(c)),r}static polling(t,{interval:n,signal:e,immediate:i}){let r,s;const c=[];let a=o=>{c.push(o)};const l=()=>{r&&r.cancel(),r=new Futurable((o,f,h)=>{h.onCancel(()=>{s&&s instanceof Futurable&&s.cancel()});try{const u=t();u instanceof Futurable||u instanceof Promise?s=u.then(()=>o()).catch(g=>{a(g)}):o()}catch(u){a(u)}},e)};i&&l();const d=setInterval(l,n);return{cancel:()=>{d&&clearInterval(d),r&&r.cancel(),s&&s instanceof Futurable&&s.cancel()},catch:o=>{a=o,c.length>0&&(c.forEach(f=>o(f)),c.length=0)}}}static withResolvers(t){let n,e,i;const r=new Futurable((c,a,l)=>{n=c,e=a,i=l},t),s=r.cancel.bind(r);return{resolve:n,reject:e,utils:i,cancel:s,promise:r}}static safe(t,n){return new Futurable(t,n).safe()}}class FuturableTask{constructor(t,n){this.executor=t,this.controller=new AbortController,this.controller.signal.addEventListener("abort",()=>{this.cancelCallbacks.forEach(e=>e())},{once:!0}),n&&(n.aborted?this.controller.abort():n.addEventListener("abort",()=>this.controller.abort(),{once:!0}))}controller;cancelCallbacks=[];memoizeOptions={enabled:!1,catchErrors:!1};sourceTask;get signal(){return this.controller.signal}cancel(){this.controller.signal.aborted||this.controller.abort()}onCancel(t){return this.cancelCallbacks.push(t),this}run(t){if(this.memoizeOptions.enabled&&this.memoizeOptions.instance)if(this.memoizeOptions.instance.signal.aborted)delete this.memoizeOptions.instance;else return this.memoizeOptions.instance;const n=new AbortController;this.signal.aborted?n.abort():this.signal.addEventListener("abort",()=>n.abort(),{once:!0}),t&&(t.aborted?n.abort():t.addEventListener("abort",()=>n.abort(),{once:!0}));const e=new Futurable(this.executor,n.signal);return this.memoizeOptions.enabled&&(this.memoizeOptions.instance=e,this.memoizeOptions.catchErrors||e.catch(()=>{delete this.memoizeOptions.instance})),e}runSafe(t){return this.run(t).safe()}memoize(t){const n=new FuturableTask(this.executor,this.signal);return n.memoizeOptions.enabled=!0,n.memoizeOptions.catchErrors=t,n}map(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(r=>n(t(r,i.signal))).catch(e)},this.signal)}flatMap(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(r=>{t(r).run(i.signal).then(n).catch(e)}).catch(e)},this.signal)}andThen(t){return this.flatMap(()=>t)}tap(t){return this.map(async n=>(await t(n),n))}tapError(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(n).catch(async r=>{try{await t(r)}catch(s){console.error("tapError callback failed: ",s)}e(r)})},this.signal)}catchError(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(n).catch(r=>{t(r).run(i.signal).then(n).catch(e)})},this.signal)}orElse(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(n).catch(r=>{t(r).run(i.signal).then(n).catch(e)})},this.signal)}fallbackTo(t){return this.orElse(()=>FuturableTask.resolve(t))}ifElse(t,n,e){return new FuturableTask((i,r,s)=>{this.run(s.signal).then(async c=>{(await t(c)?n(c):e(c)).run(s.signal).then(i).catch(r)}).catch(r)},this.signal)}fold(t,n){return new FuturableTask((e,i,r)=>{this.run(r.signal).then(s=>{n(s).run(r.signal).then(e).catch(i)}).catch(s=>{t(s).run(r.signal).then(e).catch(i)})},this.signal)}finally(t){return new FuturableTask((n,e,i)=>{this.run(i.signal).then(async r=>{await t(),n(r)}).catch(async r=>{await t(),e(r)})},this.signal)}timeout(t,n="TimeoutExceeded"){return new FuturableTask((e,i,r)=>{const s=setTimeout(()=>{c.cancel(),i(n)},t),c=this.run(r.signal);r.onCancel(()=>{clearTimeout(s)}),c.then(a=>{clearTimeout(s),e(a)}).catch(a=>{clearTimeout(s),i(a)})},this.signal)}delay(t){return new FuturableTask(async(n,e,i)=>{await i.sleep(t),this.run(i.signal).then(n).catch(e)},this.signal)}retry(t,n=0){return new FuturableTask(async(e,i,r)=>{let s;for(let c=0;c<=t;c++){if(r.signal.aborted)return;try{return e(await this.run(r.signal))}catch(a){s=a,c<t&&!r.signal.aborted&&n>0&&await r.sleep(n)}}i(s)},this.signal)}debounce(t){const n=this.sourceTask??this;let e=null;const i=new FuturableTask((r,s,c)=>{c.onCancel(()=>{e&&clearTimeout(e),e=null}),e&&clearTimeout(e),e=setTimeout(()=>{n.run(c.signal).then(r).catch(s).finally(()=>{e=null})},t)},this.signal);return i.sourceTask=n,i}throttle(t){let n=0,e;return new FuturableTask((i,r,s)=>{const c=Date.now();c-n>=t||!e?(n=c,e=this.run(s.signal),e.then(i).catch(r)):e&&e.then(i).catch(r)},this.signal)}zip(t){return new FuturableTask((n,e,i)=>{Futurable.all([this.run(i.signal),t.run(i.signal)],i.signal).then(([r,s])=>n([r,s])).catch(e)},this.signal)}zipWith(t,n){return this.zip(t).map(([e,i])=>n(e,i))}bimap(t,n){return new FuturableTask((e,i,r)=>{this.run(r.signal).then(s=>e(t(s))).catch(s=>i(n(s)))},this.signal)}repeat(t){return FuturableTask.times(t,()=>this)}pipe(...t){return t.reduce((n,e)=>e(n),this)}fetch(t,n){return new FuturableTask((e,i,r)=>{this.run(r.signal).then(s=>{const c=typeof t=="function"?t(s):t,a={...typeof n=="function"?n(s):n,signal:r.signal};r.fetch(c,a).then(e).catch(i)}).catch(i)},this.signal)}static of(t,n){return typeof t=="function"?new FuturableTask(async(e,i,r)=>{try{e(await t(r))}catch(s){i(s)}},n):new FuturableTask(e=>e(t),n)}static resolve(t,n){return FuturableTask.of(t,n)}static reject(t,n){return new FuturableTask((e,i)=>i(t),n)}static all(t,n){return new FuturableTask((e,i,r)=>{Futurable.all(t.map(s=>s.run(r.signal)),r.signal).then(e).catch(i)},n)}static allSettled(t,n){return new FuturableTask((e,i,r)=>{Futurable.allSettled(t.map(s=>s.run(r.signal)),r.signal).then(e).catch(i)},n)}static race(t,n){return new FuturableTask((e,i,r)=>{Futurable.race(t.map(s=>s.run(r.signal)),r.signal).then(e).catch(i)},n)}static any(t,n){return new FuturableTask((e,i,r)=>{Futurable.any(t.map(s=>s.run(r.signal)),r.signal).then(e).catch(i)},n)}static delay(t,n){return new FuturableTask((e,i,r)=>{r.sleep(t).then(e).catch(i)},n)}static fromEvent(t,n,e,i){return new FuturableTask((r,s,c)=>{c.onCancel(()=>t.removeEventListener(n,a));const a=l=>{!(e!=null&&e.once)&&t.removeEventListener(n,a),r(l)};t.addEventListener(n,a,e)},i)}static sequence(t,n){return new FuturableTask(async(e,i,r)=>{const s=[];try{for(const c of t){if(r.signal.aborted)return;s.push(await c.run(r.signal))}e(s)}catch(c){i(c)}},n)}static parallel(t,n=5,e){return new FuturableTask(async(i,r,s)=>{const c=new Array(t.length),a=[];let l=0,d=0,o=0;s.onCancel(()=>{a.forEach(h=>h.cancel())});const f=(h,u)=>{if(d===t.length)return h(c);for(;l<n&&o<t.length;){const g=o++;l++;const w=t[g].run(s.signal);a.push(w),w.then(p=>{c[g]=p,l--,d++;const m=a.indexOf(w);m!==-1&&a.splice(m,1),f(h,u)}).catch(p=>{a.forEach(m=>m.cancel()),u(p)})}};f(i,r)},e)}static createLimiter(t,n={},e){let i=0;const r=[],s=()=>{for(var a;i<t&&r.length>0;){const l=r.shift();l&&l()}i===0&&r.length===0&&((a=n.onIdle)==null||a.call(n))},c=a=>new FuturableTask((l,d,o)=>{let f=!1;const h=()=>{var u;f=!1,i++,(u=n.onActive)==null||u.call(n,a),a.run(o.signal).then(g=>{var w;(w=n.onCompleted)==null||w.call(n,g),l(g)}).catch(g=>{var w;(w=n.onError)==null||w.call(n,g),d(g)}).finally(()=>{i--,s()})};o.onCancel(()=>{if(f){const u=r.indexOf(h);u!==-1&&r.splice(u,1),s()}}),i<t?h():(f=!0,r.push(h))},e);return Object.defineProperties(c,{activeCount:{get:()=>i},pendingCount:{get:()=>r.length},concurrency:{get:()=>t}}),c}static compose(t,...n){return n.reduce((e,i)=>i(e),t)}static filter(t,n,e){return new FuturableTask(async(i,r,s)=>{const c=[];try{for(const a of t){if(s.signal.aborted)return;const l=await a.run(s.signal);await n(l)&&c.push(l)}i(c)}catch(a){r(a)}},e)}static reduce(t,n,e,i){return new FuturableTask(async(r,s,c)=>{let a=e;try{for(let l=0;l<t.length;l++){if(c.signal.aborted)return;const d=await t[l].run(c.signal);a=await n(a,d,l)}r(a)}catch(l){s(l)}},i)}static whilst(t,n,e){return new FuturableTask(async(i,r,s)=>{const c=[];try{for(;await t();){if(s.signal.aborted)return;c.push(await n.run(s.signal))}i(c)}catch(a){r(a)}},e)}static until(t,n,e){return FuturableTask.whilst(async()=>!await t(),n,e)}static times(t,n,e){return new FuturableTask(async(i,r,s)=>{const c=[];try{for(let a=0;a<t;a++){if(s.signal.aborted)return;c.push(await n(a).run(s.signal))}i(c)}catch(a){r(a)}},e)}static traverse(t,n,e){return FuturableTask.sequence(t.map((i,r)=>n(i,r)),e)}static fetch(t,n,e){return new FuturableTask((i,r,s)=>{const c={...n,signal:s.signal};s.fetch(t,c).then(i).catch(r)},e)}}exports.Futurable=Futurable;exports.FuturableTask=FuturableTask;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class o extends Promise{controller;internalSignal;idsTimeout;constructor(t,n){const e=new AbortController,i=e.signal,c=[];n&&(n.aborted?e.abort():n.addEventListener("abort",()=>e.abort(),{once:!0}));let s=[];const r=g=>{s.push(g)},a=()=>{for(const g of c)clearTimeout(g);c.length=0},h={signal:i,cancel:()=>e.abort(),onCancel:r,delay:(g,w)=>new o(f=>{c.push(setTimeout(()=>{f(g())},w))},i),sleep:g=>h.delay(()=>{},g),fetch:(g,w)=>new o((f,u)=>{fetch(g,{...w||{},signal:i}).then(d=>f(d)).catch(d=>{d.name!=="AbortError"&&u(d)})},i),futurizable:g=>new o((w,f)=>{g.then(w).catch(f)},i)},m=new Promise((g,w)=>{if(i.aborted){a();return}else{const f=()=>{a(),s.forEach(d=>d()),s=[]},u=()=>{i.removeEventListener("abort",f)};i.addEventListener("abort",f,{once:!0}),t(d=>{u(),g(d)},d=>{u(),w(d)},h)}});super((g,w)=>{m.then(f=>g(f)).catch(w)}),this.controller=e,this.internalSignal=i,this.idsTimeout=c}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);this.idsTimeout.length=0}then(t,n){let e,i;const c=new o((s,r)=>{e=s,i=r},this.internalSignal);return c.controller=this.controller,super.then(s=>{var r;if((r=this.internalSignal)!=null&&r.aborted){this.clearTimeout();return}try{e(t?t(s):s)}catch(a){i(a)}},s=>{var r;if((r=this.internalSignal)!=null&&r.aborted){this.clearTimeout();return}try{n?e(n(s)):i(s)}catch(a){i(a)}}),c}catch(t){return this.then(null,t)}finally(t){return this.then(n=>(t(),n),n=>{if(t(),n instanceof Error)throw n;return n})}cancel(){var t;!((t=this.internalSignal)!=null&&t.aborted)&&this.controller.abort()}delay(t,n){return this.then(e=>new o(i=>{this.idsTimeout.push(setTimeout(()=>i(t(e)),n))},this.internalSignal))}sleep(t){return this.delay(n=>n,t)}fetch(t,n){return this.then(e=>{const i=typeof t=="function"?t(e):t,c={...typeof n=="function"?n(e):n,signal:this.internalSignal};return new o((s,r)=>{fetch(i,c).then(s).catch(a=>{a.name!=="AbortError"&&r(a)})})})}onCancel(t){const n=new o((e,i,c)=>{c.onCancel(t),this.then(s=>e(s),s=>i(s))},this.internalSignal);return n.controller=this.controller,n}futurizable(t){return this.then(n=>{const e=typeof t=="function"?t(n):t;return new o((i,c)=>{e.then(i).catch(c)},this.internalSignal)})}safe(){return this.then(t=>({success:!0,data:t,error:null}),t=>({success:!1,data:null,error:t}))}static resolve(t,n){return t?new o(e=>e(t),n):new o(e=>e(),n)}static reject(t,n){return new o((e,i)=>i(t),n)}static onCancel({cb:t,signal:n}){return new o((e,i,c)=>{c.onCancel(()=>e(t()))},n)}static delay({cb:t,timer:n,signal:e}){return new o((i,c,s)=>{s.delay(t,n).then(i,c)},e)}static sleep({timer:t,signal:n}){return o.delay({cb:()=>{},timer:t,signal:n})}static fetch(t,n){const e=(n==null?void 0:n.signal)||void 0;return n!=null&&n.signal&&delete n.signal,new o((i,c,s)=>{s.fetch(t,n).then(i).catch(c)},e)}static futurizable({promise:t,signal:n}){return new o((e,i)=>{t.then(e).catch(i)},n)}static handleValues(t,n){const e=[];for(const i of t)i instanceof o?e.push(i):i instanceof Promise?e.push(new o((c,s)=>{i.then(r=>c(r)).catch(s)},n)):e.push(new o(c=>c(i),n));return e}static all(t,n){let e,i;const c=new o((r,a,h)=>{e=r,i=a,h.onCancel(()=>{for(const m of s)m.cancel()})},n);n||=c.internalSignal;const s=o.handleValues(t,n);return super.all(s).then(r=>e(r)).catch(r=>i(r)),c}static allSettled(t,n){let e;const i=new o((s,r,a)=>{e=s,a.onCancel(()=>{for(const h of c)h.cancel()})},n);n||=i.internalSignal;const c=o.handleValues(t,n);return super.allSettled(c).then(s=>e(s)),i}static race(t,n){let e,i;const c=new o((r,a,h)=>{e=r,i=a,h.onCancel(()=>{for(const m of s)m.cancel()})},n);n||=c.internalSignal;const s=o.handleValues(t,n);return super.race(s).then(r=>e(r)).catch(r=>i(r)),c}static any(t,n){let e,i;const c=new o((r,a,h)=>{e=r,i=a,h.onCancel(()=>{for(const m of s)m.cancel()})},n);n||=c.internalSignal;const s=o.handleValues(t,n);return super.any(s).then(r=>e(r)).catch(r=>i(r)),c}static polling(t,{interval:n,signal:e,immediate:i}){let c,s;const r=[];let a=g=>{r.push(g)};const h=()=>{c&&c.cancel(),c=new o((g,w,f)=>{f.onCancel(()=>{s&&s instanceof o&&s.cancel()});try{const u=t();u instanceof o||u instanceof Promise?s=u.then(()=>g()).catch(d=>{a(d)}):g()}catch(u){a(u)}},e)};i&&h();const m=setInterval(h,n);return{cancel:()=>{m&&clearInterval(m),c&&c.cancel(),s&&s instanceof o&&s.cancel()},catch:g=>{a=g,r.length>0&&(r.forEach(w=>g(w)),r.length=0)}}}static withResolvers(t){let n,e,i;const c=new o((r,a,h)=>{n=r,e=a,i=h},t),s=c.cancel.bind(c);return{resolve:n,reject:e,utils:i,cancel:s,promise:c}}static safe(t,n){return new o(t,n).safe()}}class l{constructor(t,n){this.executor=t,this.controller=new AbortController,this.controller.signal.addEventListener("abort",()=>{this.cancelCallbacks.forEach(e=>e())},{once:!0}),n&&(n.aborted?this.controller.abort():n.addEventListener("abort",()=>this.controller.abort(),{once:!0}))}controller;cancelCallbacks=[];memoizeOptions={enabled:!1,catchErrors:!1};sourceTask;get signal(){return this.controller.signal}cancel(){this.controller.signal.aborted||this.controller.abort()}onCancel(t){return this.cancelCallbacks.push(t),this}run(t){if(this.memoizeOptions.enabled&&this.memoizeOptions.instance)if(this.memoizeOptions.instance.signal.aborted)delete this.memoizeOptions.instance;else return this.memoizeOptions.instance;const n=new AbortController;this.signal.aborted?n.abort():this.signal.addEventListener("abort",()=>n.abort(),{once:!0}),t&&(t.aborted?n.abort():t.addEventListener("abort",()=>n.abort(),{once:!0}));const e=new o(this.executor,n.signal);return this.memoizeOptions.enabled&&(this.memoizeOptions.instance=e,this.memoizeOptions.catchErrors||e.catch(()=>{delete this.memoizeOptions.instance})),e}runSafe(t){return this.run(t).safe()}memoize(t){const n=new l(this.executor,this.signal);return n.memoizeOptions.enabled=!0,n.memoizeOptions.catchErrors=t,n}map(t){return new l((n,e,i)=>{this.run(i.signal).then(c=>n(t(c,i.signal))).catch(e)},this.signal)}flatMap(t){return new l((n,e,i)=>{this.run(i.signal).then(c=>{t(c).run(i.signal).then(n).catch(e)}).catch(e)},this.signal)}andThen(t){return this.flatMap(()=>t)}tap(t){return this.map(async n=>(await t(n),n))}tapError(t){return new l((n,e,i)=>{this.run(i.signal).then(n).catch(async c=>{try{await t(c)}catch(s){console.error("tapError callback failed: ",s)}e(c)})},this.signal)}catchError(t){return new l((n,e,i)=>{this.run(i.signal).then(n).catch(c=>{t(c).run(i.signal).then(n).catch(e)})},this.signal)}orElse(t){return new l((n,e,i)=>{this.run(i.signal).then(n).catch(c=>{t(c).run(i.signal).then(n).catch(e)})},this.signal)}fallbackTo(t){return this.orElse(()=>l.resolve(t))}ifElse(t,n,e){return new l((i,c,s)=>{this.run(s.signal).then(async r=>{(await t(r)?n(r):e(r)).run(s.signal).then(i).catch(c)}).catch(c)},this.signal)}fold(t,n){return new l((e,i,c)=>{this.run(c.signal).then(s=>{n(s).run(c.signal).then(e).catch(i)}).catch(s=>{t(s).run(c.signal).then(e).catch(i)})},this.signal)}finally(t){return new l((n,e,i)=>{this.run(i.signal).then(async c=>{await t(),n(c)}).catch(async c=>{await t(),e(c)})},this.signal)}timeout(t,n="TimeoutExceeded"){return new l((e,i,c)=>{const s=setTimeout(()=>{r.cancel(),i(n)},t),r=this.run(c.signal);c.onCancel(()=>{clearTimeout(s)}),r.then(a=>{clearTimeout(s),e(a)}).catch(a=>{clearTimeout(s),i(a)})},this.signal)}delay(t){return new l(async(n,e,i)=>{await i.sleep(t),this.run(i.signal).then(n).catch(e)},this.signal)}retry(t,n=0){return new l(async(e,i,c)=>{let s;for(let r=0;r<=t;r++){if(c.signal.aborted)return;try{return e(await this.run(c.signal))}catch(a){s=a,r<t&&!c.signal.aborted&&n>0&&await c.sleep(n)}}i(s)},this.signal)}debounce(t){const n=this.sourceTask??this;let e=null;const i=new l((c,s,r)=>{r.onCancel(()=>{e&&clearTimeout(e),e=null}),e&&clearTimeout(e),e=setTimeout(()=>{n.run(r.signal).then(c).catch(s).finally(()=>{e=null})},t)},this.signal);return i.sourceTask=n,i}throttle(t){let n=0,e;return new l((i,c,s)=>{const r=Date.now();r-n>=t||!e?(n=r,e=this.run(s.signal),e.then(i).catch(c)):e&&e.then(i).catch(c)},this.signal)}zip(t){return new l((n,e,i)=>{o.all([this.run(i.signal),t.run(i.signal)],i.signal).then(([c,s])=>n([c,s])).catch(e)},this.signal)}zipWith(t,n){return this.zip(t).map(([e,i])=>n(e,i))}bimap(t,n){return new l((e,i,c)=>{this.run(c.signal).then(s=>e(t(s))).catch(s=>i(n(s)))},this.signal)}repeat(t){return l.times(t,()=>this)}pipe(...t){return t.reduce((n,e)=>e(n),this)}fetch(t,n){return new l((e,i,c)=>{this.run(c.signal).then(s=>{const r=typeof t=="function"?t(s):t,a={...typeof n=="function"?n(s):n,signal:c.signal};c.fetch(r,a).then(e).catch(i)}).catch(i)},this.signal)}static of(t,n){return typeof t=="function"?new l(async(e,i,c)=>{try{e(await t(c))}catch(s){i(s)}},n):new l(e=>e(t),n)}static resolve(t,n){return l.of(t,n)}static reject(t,n){return new l((e,i)=>i(t),n)}static all(t,n){return new l((e,i,c)=>{o.all(t.map(s=>s.run(c.signal)),c.signal).then(e).catch(i)},n)}static allSettled(t,n){return new l((e,i,c)=>{o.allSettled(t.map(s=>s.run(c.signal)),c.signal).then(e).catch(i)},n)}static race(t,n){return new l((e,i,c)=>{o.race(t.map(s=>s.run(c.signal)),c.signal).then(e).catch(i)},n)}static any(t,n){return new l((e,i,c)=>{o.any(t.map(s=>s.run(c.signal)),c.signal).then(e).catch(i)},n)}static delay(t,n){return new l((e,i,c)=>{c.sleep(t).then(e).catch(i)},n)}static fromEvent(t,n,e,i){return new l((c,s,r)=>{r.onCancel(()=>t.removeEventListener(n,a));const a=h=>{!(e!=null&&e.once)&&t.removeEventListener(n,a),c(h)};t.addEventListener(n,a,e)},i)}static sequence(t,n){return new l(async(e,i,c)=>{const s=[];try{for(const r of t){if(c.signal.aborted)return;s.push(await r.run(c.signal))}e(s)}catch(r){i(r)}},n)}static parallel(t,n=5,e){return new l(async(i,c,s)=>{const r=new Array(t.length),a=[];let h=0,m=0,g=0;s.onCancel(()=>{a.forEach(f=>f.cancel())});const w=(f,u)=>{if(m===t.length)return f(r);for(;h<n&&g<t.length;){const d=g++;h++;const p=t[d].run(s.signal);a.push(p),p.then(v=>{r[d]=v,h--,m++;const y=a.indexOf(p);y!==-1&&a.splice(y,1),w(f,u)}).catch(v=>{a.forEach(y=>y.cancel()),u(v)})}};w(i,c)},e)}static createLimiter(t,n={},e){let i=0;const c=[],s=()=>{for(var a;i<t&&c.length>0;){const h=c.shift();h&&h()}i===0&&c.length===0&&((a=n.onIdle)==null||a.call(n))},r=a=>new l((h,m,g)=>{let w=!1;const f=()=>{var u;w=!1,i++,(u=n.onActive)==null||u.call(n,a),a.run(g.signal).then(d=>{var p;(p=n.onCompleted)==null||p.call(n,d),h(d)}).catch(d=>{var p;(p=n.onError)==null||p.call(n,d),m(d)}).finally(()=>{i--,s()})};g.onCancel(()=>{if(w){const u=c.indexOf(f);u!==-1&&c.splice(u,1),s()}}),i<t?f():(w=!0,c.push(f))},e);return Object.defineProperties(r,{activeCount:{get:()=>i},pendingCount:{get:()=>c.length},concurrency:{get:()=>t}}),r}static compose(t,...n){return n.reduce((e,i)=>i(e),t)}static filter(t,n,e){return new l(async(i,c,s)=>{const r=[];try{for(const a of t){if(s.signal.aborted)return;const h=await a.run(s.signal);await n(h)&&r.push(h)}i(r)}catch(a){c(a)}},e)}static reduce(t,n,e,i){return new l(async(c,s,r)=>{let a=e;try{for(let h=0;h<t.length;h++){if(r.signal.aborted)return;const m=await t[h].run(r.signal);a=await n(a,m,h)}c(a)}catch(h){s(h)}},i)}static whilst(t,n,e){return new l(async(i,c,s)=>{const r=[];try{for(;await t();){if(s.signal.aborted)return;r.push(await n.run(s.signal))}i(r)}catch(a){c(a)}},e)}static until(t,n,e){return l.whilst(async()=>!await t(),n,e)}static times(t,n,e){return new l(async(i,c,s)=>{const r=[];try{for(let a=0;a<t;a++){if(s.signal.aborted)return;r.push(await n(a).run(s.signal))}i(r)}catch(a){c(a)}},e)}static traverse(t,n,e){return l.sequence(t.map((i,c)=>n(i,c)),e)}static fetch(t,n,e){return new l((i,c,s)=>{const r={...n,signal:s.signal};s.fetch(t,r).then(i).catch(c)},e)}}export{o as Futurable,l as FuturableTask};
|
|
1
|
+
class o extends Promise{controller;internalSignal;idsTimeout;constructor(t,n){const e=new AbortController,i=e.signal,r=[];n&&(n.aborted?e.abort():n.addEventListener("abort",()=>e.abort(),{once:!0}));let s=[];const c=g=>{s.push(g)},a=()=>{for(const g of r)clearTimeout(g);r.length=0},h={signal:i,cancel:()=>e.abort(),onCancel:c,delay:(g,d)=>new o(f=>{r.push(setTimeout(()=>{f(g())},d))},i),sleep:g=>h.delay(()=>{},g),fetch:(g,d)=>new o((f,w)=>{fetch(g,{...d||{},signal:i}).then(u=>f(u)).catch(u=>{u.name!=="AbortError"&&w(u)})},i),futurizable:g=>new o((d,f)=>{g.then(d).catch(f)},i)},m=new Promise((g,d)=>{if(i.aborted){a();return}else{const f=()=>{a(),s.forEach(u=>u()),s=[]},w=()=>{i.removeEventListener("abort",f)};i.addEventListener("abort",f,{once:!0}),t(u=>{w(),g(u)},u=>{w(),d(u)},h)}});super((g,d)=>{m.then(f=>g(f)).catch(d)}),this.controller=e,this.internalSignal=i,this.idsTimeout=r}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);this.idsTimeout.length=0}then(t,n){let e,i;const r=new o((s,c)=>{e=s,i=c},this.internalSignal);return r.controller=this.controller,super.then(s=>{var c;if((c=this.internalSignal)!=null&&c.aborted){this.clearTimeout();return}try{e(t?t(s):s)}catch(a){i(a)}},s=>{var c;if((c=this.internalSignal)!=null&&c.aborted){this.clearTimeout();return}try{n?e(n(s)):i(s)}catch(a){i(a)}}),r}catch(t){return this.then(null,t)}finally(t){return this.then(n=>(t(),n),n=>{if(t(),n instanceof Error)throw n;return n})}cancel(){var t;!((t=this.internalSignal)!=null&&t.aborted)&&this.controller.abort()}delay(t,n){return this.then(e=>new o(i=>{this.idsTimeout.push(setTimeout(()=>i(t(e)),n))},this.internalSignal))}sleep(t){return this.delay(n=>n,t)}fetch(t,n){return this.then(e=>{const i=typeof t=="function"?t(e):t,r={...typeof n=="function"?n(e):n,signal:this.internalSignal};return new o((s,c)=>{fetch(i,r).then(s).catch(a=>{a.name!=="AbortError"&&c(a)})})})}onCancel(t){const n=new o((e,i,r)=>{r.onCancel(t),this.then(s=>e(s),s=>i(s))},this.internalSignal);return n.controller=this.controller,n}futurizable(t){return this.then(n=>{const e=typeof t=="function"?t(n):t;return new o((i,r)=>{e.then(i).catch(r)},this.internalSignal)})}safe(){return this.then(t=>({success:!0,data:t,error:null}),t=>({success:!1,data:null,error:t}))}static resolve(t,n){return t?new o(e=>e(t),n):new o(e=>e(),n)}static reject(t,n){return new o((e,i)=>i(t),n)}static onCancel({cb:t,signal:n}){return new o((e,i,r)=>{r.onCancel(()=>e(t()))},n)}static delay({cb:t,timer:n,signal:e}){return new o((i,r,s)=>{s.delay(t,n).then(i,r)},e)}static sleep({timer:t,signal:n}){return o.delay({cb:()=>{},timer:t,signal:n})}static fetch(t,n){const e=(n==null?void 0:n.signal)||void 0;return n!=null&&n.signal&&delete n.signal,new o((i,r,s)=>{s.fetch(t,n).then(i).catch(r)},e)}static futurizable({promise:t,signal:n}){return new o((e,i)=>{t.then(e).catch(i)},n)}static handleValues(t,n){const e=[];for(const i of t)i instanceof o?e.push(i):i instanceof Promise?e.push(new o((r,s)=>{i.then(c=>r(c)).catch(s)},n)):e.push(new o(r=>r(i),n));return e}static all(t,n){let e,i;const r=new o((c,a,h)=>{e=c,i=a,h.onCancel(()=>{for(const m of s)m.cancel()})},n);n||=r.internalSignal;const s=o.handleValues(t,n);return super.all(s).then(c=>e(c)).catch(c=>i(c)),r}static allSettled(t,n){let e;const i=new o((s,c,a)=>{e=s,a.onCancel(()=>{for(const h of r)h.cancel()})},n);n||=i.internalSignal;const r=o.handleValues(t,n);return super.allSettled(r).then(s=>e(s)),i}static race(t,n){let e,i;const r=new o((c,a,h)=>{e=c,i=a,h.onCancel(()=>{for(const m of s)m.cancel()})},n);n||=r.internalSignal;const s=o.handleValues(t,n);return super.race(s).then(c=>e(c)).catch(c=>i(c)),r}static any(t,n){let e,i;const r=new o((c,a,h)=>{e=c,i=a,h.onCancel(()=>{for(const m of s)m.cancel()})},n);n||=r.internalSignal;const s=o.handleValues(t,n);return super.any(s).then(c=>e(c)).catch(c=>i(c)),r}static polling(t,{interval:n,signal:e,immediate:i}){let r,s;const c=[];let a=g=>{c.push(g)};const h=()=>{r&&r.cancel(),r=new o((g,d,f)=>{f.onCancel(()=>{s&&s instanceof o&&s.cancel()});try{const w=t();w instanceof o||w instanceof Promise?s=w.then(()=>g()).catch(u=>{a(u)}):g()}catch(w){a(w)}},e)};i&&h();const m=setInterval(h,n);return{cancel:()=>{m&&clearInterval(m),r&&r.cancel(),s&&s instanceof o&&s.cancel()},catch:g=>{a=g,c.length>0&&(c.forEach(d=>g(d)),c.length=0)}}}static withResolvers(t){let n,e,i;const r=new o((c,a,h)=>{n=c,e=a,i=h},t),s=r.cancel.bind(r);return{resolve:n,reject:e,utils:i,cancel:s,promise:r}}static safe(t,n){return new o(t,n).safe()}}class l{constructor(t,n){this.executor=t,this.controller=new AbortController,this.controller.signal.addEventListener("abort",()=>{this.cancelCallbacks.forEach(e=>e())},{once:!0}),n&&(n.aborted?this.controller.abort():n.addEventListener("abort",()=>this.controller.abort(),{once:!0}))}controller;cancelCallbacks=[];memoizeOptions={enabled:!1,catchErrors:!1};sourceTask;get signal(){return this.controller.signal}cancel(){this.controller.signal.aborted||this.controller.abort()}onCancel(t){return this.cancelCallbacks.push(t),this}run(t){if(this.memoizeOptions.enabled&&this.memoizeOptions.instance)if(this.memoizeOptions.instance.signal.aborted)delete this.memoizeOptions.instance;else return this.memoizeOptions.instance;const n=new AbortController;this.signal.aborted?n.abort():this.signal.addEventListener("abort",()=>n.abort(),{once:!0}),t&&(t.aborted?n.abort():t.addEventListener("abort",()=>n.abort(),{once:!0}));const e=new o(this.executor,n.signal);return this.memoizeOptions.enabled&&(this.memoizeOptions.instance=e,this.memoizeOptions.catchErrors||e.catch(()=>{delete this.memoizeOptions.instance})),e}runSafe(t){return this.run(t).safe()}memoize(t){const n=new l(this.executor,this.signal);return n.memoizeOptions.enabled=!0,n.memoizeOptions.catchErrors=t,n}map(t){return new l((n,e,i)=>{this.run(i.signal).then(r=>n(t(r,i.signal))).catch(e)},this.signal)}flatMap(t){return new l((n,e,i)=>{this.run(i.signal).then(r=>{t(r).run(i.signal).then(n).catch(e)}).catch(e)},this.signal)}andThen(t){return this.flatMap(()=>t)}tap(t){return this.map(async n=>(await t(n),n))}tapError(t){return new l((n,e,i)=>{this.run(i.signal).then(n).catch(async r=>{try{await t(r)}catch(s){console.error("tapError callback failed: ",s)}e(r)})},this.signal)}catchError(t){return new l((n,e,i)=>{this.run(i.signal).then(n).catch(r=>{t(r).run(i.signal).then(n).catch(e)})},this.signal)}orElse(t){return new l((n,e,i)=>{this.run(i.signal).then(n).catch(r=>{t(r).run(i.signal).then(n).catch(e)})},this.signal)}fallbackTo(t){return this.orElse(()=>l.resolve(t))}ifElse(t,n,e){return new l((i,r,s)=>{this.run(s.signal).then(async c=>{(await t(c)?n(c):e(c)).run(s.signal).then(i).catch(r)}).catch(r)},this.signal)}fold(t,n){return new l((e,i,r)=>{this.run(r.signal).then(s=>{n(s).run(r.signal).then(e).catch(i)}).catch(s=>{t(s).run(r.signal).then(e).catch(i)})},this.signal)}finally(t){return new l((n,e,i)=>{this.run(i.signal).then(async r=>{await t(),n(r)}).catch(async r=>{await t(),e(r)})},this.signal)}timeout(t,n="TimeoutExceeded"){return new l((e,i,r)=>{const s=setTimeout(()=>{c.cancel(),i(n)},t),c=this.run(r.signal);r.onCancel(()=>{clearTimeout(s)}),c.then(a=>{clearTimeout(s),e(a)}).catch(a=>{clearTimeout(s),i(a)})},this.signal)}delay(t){return new l(async(n,e,i)=>{await i.sleep(t),this.run(i.signal).then(n).catch(e)},this.signal)}retry(t,n=0){return new l(async(e,i,r)=>{let s;for(let c=0;c<=t;c++){if(r.signal.aborted)return;try{return e(await this.run(r.signal))}catch(a){s=a,c<t&&!r.signal.aborted&&n>0&&await r.sleep(n)}}i(s)},this.signal)}debounce(t){const n=this.sourceTask??this;let e=null;const i=new l((r,s,c)=>{c.onCancel(()=>{e&&clearTimeout(e),e=null}),e&&clearTimeout(e),e=setTimeout(()=>{n.run(c.signal).then(r).catch(s).finally(()=>{e=null})},t)},this.signal);return i.sourceTask=n,i}throttle(t){let n=0,e;return new l((i,r,s)=>{const c=Date.now();c-n>=t||!e?(n=c,e=this.run(s.signal),e.then(i).catch(r)):e&&e.then(i).catch(r)},this.signal)}zip(t){return new l((n,e,i)=>{o.all([this.run(i.signal),t.run(i.signal)],i.signal).then(([r,s])=>n([r,s])).catch(e)},this.signal)}zipWith(t,n){return this.zip(t).map(([e,i])=>n(e,i))}bimap(t,n){return new l((e,i,r)=>{this.run(r.signal).then(s=>e(t(s))).catch(s=>i(n(s)))},this.signal)}repeat(t){return l.times(t,()=>this)}pipe(...t){return t.reduce((n,e)=>e(n),this)}fetch(t,n){return new l((e,i,r)=>{this.run(r.signal).then(s=>{const c=typeof t=="function"?t(s):t,a={...typeof n=="function"?n(s):n,signal:r.signal};r.fetch(c,a).then(e).catch(i)}).catch(i)},this.signal)}static of(t,n){return typeof t=="function"?new l(async(e,i,r)=>{try{e(await t(r))}catch(s){i(s)}},n):new l(e=>e(t),n)}static resolve(t,n){return l.of(t,n)}static reject(t,n){return new l((e,i)=>i(t),n)}static all(t,n){return new l((e,i,r)=>{o.all(t.map(s=>s.run(r.signal)),r.signal).then(e).catch(i)},n)}static allSettled(t,n){return new l((e,i,r)=>{o.allSettled(t.map(s=>s.run(r.signal)),r.signal).then(e).catch(i)},n)}static race(t,n){return new l((e,i,r)=>{o.race(t.map(s=>s.run(r.signal)),r.signal).then(e).catch(i)},n)}static any(t,n){return new l((e,i,r)=>{o.any(t.map(s=>s.run(r.signal)),r.signal).then(e).catch(i)},n)}static delay(t,n){return new l((e,i,r)=>{r.sleep(t).then(e).catch(i)},n)}static fromEvent(t,n,e,i){return new l((r,s,c)=>{c.onCancel(()=>t.removeEventListener(n,a));const a=h=>{!(e!=null&&e.once)&&t.removeEventListener(n,a),r(h)};t.addEventListener(n,a,e)},i)}static sequence(t,n){return new l(async(e,i,r)=>{const s=[];try{for(const c of t){if(r.signal.aborted)return;s.push(await c.run(r.signal))}e(s)}catch(c){i(c)}},n)}static parallel(t,n=5,e){return new l(async(i,r,s)=>{const c=new Array(t.length),a=[];let h=0,m=0,g=0;s.onCancel(()=>{a.forEach(f=>f.cancel())});const d=(f,w)=>{if(m===t.length)return f(c);for(;h<n&&g<t.length;){const u=g++;h++;const p=t[u].run(s.signal);a.push(p),p.then(v=>{c[u]=v,h--,m++;const y=a.indexOf(p);y!==-1&&a.splice(y,1),d(f,w)}).catch(v=>{a.forEach(y=>y.cancel()),w(v)})}};d(i,r)},e)}static createLimiter(t,n={},e){let i=0;const r=[],s=()=>{for(var a;i<t&&r.length>0;){const h=r.shift();h&&h()}i===0&&r.length===0&&((a=n.onIdle)==null||a.call(n))},c=a=>new l((h,m,g)=>{let d=!1;const f=()=>{var w;d=!1,i++,(w=n.onActive)==null||w.call(n,a),a.run(g.signal).then(u=>{var p;(p=n.onCompleted)==null||p.call(n,u),h(u)}).catch(u=>{var p;(p=n.onError)==null||p.call(n,u),m(u)}).finally(()=>{i--,s()})};g.onCancel(()=>{if(d){const w=r.indexOf(f);w!==-1&&r.splice(w,1),s()}}),i<t?f():(d=!0,r.push(f))},e);return Object.defineProperties(c,{activeCount:{get:()=>i},pendingCount:{get:()=>r.length},concurrency:{get:()=>t}}),c}static compose(t,...n){return n.reduce((e,i)=>i(e),t)}static filter(t,n,e){return new l(async(i,r,s)=>{const c=[];try{for(const a of t){if(s.signal.aborted)return;const h=await a.run(s.signal);await n(h)&&c.push(h)}i(c)}catch(a){r(a)}},e)}static reduce(t,n,e,i){return new l(async(r,s,c)=>{let a=e;try{for(let h=0;h<t.length;h++){if(c.signal.aborted)return;const m=await t[h].run(c.signal);a=await n(a,m,h)}r(a)}catch(h){s(h)}},i)}static whilst(t,n,e){return new l(async(i,r,s)=>{const c=[];try{for(;await t();){if(s.signal.aborted)return;c.push(await n.run(s.signal))}i(c)}catch(a){r(a)}},e)}static until(t,n,e){return l.whilst(async()=>!await t(),n,e)}static times(t,n,e){return new l(async(i,r,s)=>{const c=[];try{for(let a=0;a<t;a++){if(s.signal.aborted)return;c.push(await n(a).run(s.signal))}i(c)}catch(a){r(a)}},e)}static traverse(t,n,e){return l.sequence(t.map((i,r)=>n(i,r)),e)}static fetch(t,n,e){return new l((i,r,s)=>{const c={...n,signal:s.signal};s.fetch(t,c).then(i).catch(r)},e)}}export{o as Futurable,l as FuturableTask};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@ndriadev/futurable",
|
|
3
3
|
"description": "JavaScript's Promise and Fetch APIs with superpowers!",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist/",
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
"module": "./dist/index.mjs",
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@eslint/eslintrc": "^3.
|
|
25
|
-
"@eslint/js": "^
|
|
26
|
-
"@types/node": "^
|
|
24
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
25
|
+
"@eslint/js": "^10.0.1",
|
|
26
|
+
"@types/node": "^25.3.0",
|
|
27
27
|
"@vitest/coverage-v8": "^4.0.18",
|
|
28
28
|
"@vitest/ui": "^4.0.18",
|
|
29
|
-
"globals": "^
|
|
30
|
-
"prettier": "^3.
|
|
31
|
-
"rimraf": "^6.
|
|
32
|
-
"typescript": "^5.
|
|
33
|
-
"typescript-eslint": "^8.
|
|
34
|
-
"unbuild": "^
|
|
35
|
-
"vitepress": "^1.
|
|
29
|
+
"globals": "^17.3.0",
|
|
30
|
+
"prettier": "^3.8.1",
|
|
31
|
+
"rimraf": "^6.1.3",
|
|
32
|
+
"typescript": "^5.9.3",
|
|
33
|
+
"typescript-eslint": "^8.56.0",
|
|
34
|
+
"unbuild": "^3.6.1",
|
|
35
|
+
"vitepress": "^1.6.4",
|
|
36
36
|
"vitest": "^4.0.18"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [
|