@vielzeug/flux 1.0.7 → 2.0.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 +22 -25
- package/dist/_dev.cjs +1 -1
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js +2 -8
- package/dist/_dev.js.map +1 -1
- package/dist/_iterator.cjs +1 -1
- package/dist/_iterator.cjs.map +1 -1
- package/dist/_iterator.d.ts +3 -1
- package/dist/_iterator.d.ts.map +1 -1
- package/dist/_iterator.js +57 -35
- package/dist/_iterator.js.map +1 -1
- package/dist/_link.cjs +2 -0
- package/dist/_link.cjs.map +1 -0
- package/dist/_link.d.ts +4 -0
- package/dist/_link.d.ts.map +1 -0
- package/dist/_link.js +8 -0
- package/dist/_link.js.map +1 -0
- package/dist/_numeric.cjs +1 -1
- package/dist/_numeric.cjs.map +1 -1
- package/dist/_numeric.d.ts +2 -1
- package/dist/_numeric.d.ts.map +1 -1
- package/dist/_numeric.js +3 -7
- package/dist/_numeric.js.map +1 -1
- package/dist/_pipe.cjs +1 -1
- package/dist/_pipe.cjs.map +1 -1
- package/dist/_pipe.d.ts +2 -1
- package/dist/_pipe.d.ts.map +1 -1
- package/dist/_pipe.js +3 -3
- package/dist/_pipe.js.map +1 -1
- package/dist/_safe.cjs +1 -1
- package/dist/_safe.cjs.map +1 -1
- package/dist/_safe.d.ts +1 -1
- package/dist/_safe.d.ts.map +1 -1
- package/dist/_safe.js +2 -2
- package/dist/_safe.js.map +1 -1
- package/dist/_scheduler.cjs +1 -1
- package/dist/_scheduler.cjs.map +1 -1
- package/dist/_scheduler.d.ts +5 -2
- package/dist/_scheduler.d.ts.map +1 -1
- package/dist/_scheduler.js +1 -1
- package/dist/_scheduler.js.map +1 -1
- package/dist/_subscription.cjs +2 -0
- package/dist/_subscription.cjs.map +1 -0
- package/dist/_subscription.d.ts +8 -0
- package/dist/_subscription.d.ts.map +1 -0
- package/dist/_subscription.js +80 -0
- package/dist/_subscription.js.map +1 -0
- package/dist/adapters/courier.cjs +1 -1
- package/dist/adapters/courier.cjs.map +1 -1
- package/dist/adapters/courier.d.ts +35 -21
- package/dist/adapters/courier.d.ts.map +1 -1
- package/dist/adapters/courier.js +25 -6
- package/dist/adapters/courier.js.map +1 -1
- package/dist/adapters/herald.cjs +1 -1
- package/dist/adapters/herald.cjs.map +1 -1
- package/dist/adapters/herald.d.ts +2 -16
- package/dist/adapters/herald.d.ts.map +1 -1
- package/dist/adapters/herald.js +12 -8
- package/dist/adapters/herald.js.map +1 -1
- package/dist/adapters/pulse.cjs +1 -1
- package/dist/adapters/pulse.cjs.map +1 -1
- package/dist/adapters/pulse.d.ts +3 -20
- package/dist/adapters/pulse.d.ts.map +1 -1
- package/dist/adapters/pulse.js +2 -6
- package/dist/adapters/pulse.js.map +1 -1
- package/dist/adapters/ripple.cjs +1 -1
- package/dist/adapters/ripple.cjs.map +1 -1
- package/dist/adapters/ripple.d.ts +3 -39
- package/dist/adapters/ripple.d.ts.map +1 -1
- package/dist/adapters/ripple.js +22 -29
- package/dist/adapters/ripple.js.map +1 -1
- package/dist/async.cjs +2 -0
- package/dist/async.cjs.map +1 -0
- package/dist/async.d.ts +4 -0
- package/dist/async.d.ts.map +1 -0
- package/dist/async.js +11 -0
- package/dist/async.js.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +3 -16
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +12 -81
- package/dist/core.js.map +1 -1
- package/dist/courier.cjs +1 -0
- package/dist/courier.d.ts +2 -0
- package/dist/courier.d.ts.map +1 -0
- package/dist/courier.js +2 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/flux.cjs +1 -1
- package/dist/flux.cjs.map +1 -1
- package/dist/flux.iife.js +1 -1
- package/dist/flux.iife.js.map +1 -1
- package/dist/flux.js +1 -1
- package/dist/flux.js.map +1 -1
- package/dist/herald.cjs +1 -0
- package/dist/herald.d.ts +2 -0
- package/dist/herald.d.ts.map +1 -0
- package/dist/herald.js +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +13 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -14
- package/dist/operators/combination.cjs +1 -1
- package/dist/operators/combination.cjs.map +1 -1
- package/dist/operators/combination.d.ts +9 -64
- package/dist/operators/combination.d.ts.map +1 -1
- package/dist/operators/combination.js +46 -160
- package/dist/operators/combination.js.map +1 -1
- package/dist/operators/creation.cjs +1 -1
- package/dist/operators/creation.cjs.map +1 -1
- package/dist/operators/creation.d.ts +13 -46
- package/dist/operators/creation.d.ts.map +1 -1
- package/dist/operators/creation.js +61 -65
- package/dist/operators/creation.js.map +1 -1
- package/dist/operators/filtering.cjs +1 -1
- package/dist/operators/filtering.cjs.map +1 -1
- package/dist/operators/filtering.d.ts +10 -60
- package/dist/operators/filtering.d.ts.map +1 -1
- package/dist/operators/filtering.js +62 -109
- package/dist/operators/filtering.js.map +1 -1
- package/dist/operators/transformation.cjs +1 -1
- package/dist/operators/transformation.cjs.map +1 -1
- package/dist/operators/transformation.d.ts +9 -62
- package/dist/operators/transformation.d.ts.map +1 -1
- package/dist/operators/transformation.js +91 -142
- package/dist/operators/transformation.js.map +1 -1
- package/dist/operators/utility.cjs +1 -1
- package/dist/operators/utility.cjs.map +1 -1
- package/dist/operators/utility.d.ts +16 -97
- package/dist/operators/utility.d.ts.map +1 -1
- package/dist/operators/utility.js +75 -191
- package/dist/operators/utility.js.map +1 -1
- package/dist/pipe.cjs +2 -0
- package/dist/pipe.cjs.map +1 -0
- package/dist/pipe.d.ts +15 -0
- package/dist/pipe.d.ts.map +1 -0
- package/dist/pipe.js +9 -0
- package/dist/pipe.js.map +1 -0
- package/dist/pulse.cjs +1 -0
- package/dist/pulse.d.ts +2 -0
- package/dist/pulse.d.ts.map +1 -0
- package/dist/pulse.js +2 -0
- package/dist/ripple.cjs +1 -0
- package/dist/ripple.d.ts +3 -0
- package/dist/ripple.d.ts.map +1 -0
- package/dist/ripple.js +2 -0
- package/dist/subject.cjs +1 -1
- package/dist/subject.cjs.map +1 -1
- package/dist/subject.d.ts +14 -65
- package/dist/subject.d.ts.map +1 -1
- package/dist/subject.js +31 -166
- package/dist/subject.js.map +1 -1
- package/dist/subjects.cjs +1 -0
- package/dist/subjects.d.ts +3 -0
- package/dist/subjects.d.ts.map +1 -0
- package/dist/subjects.js +2 -0
- package/dist/types.d.ts +32 -79
- package/dist/types.d.ts.map +1 -1
- package/package.json +54 -15
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vielzeug/flux
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Minimal push streams for TypeScript. Streams are reusable; subscriptions own cancellation; async buffering is explicit. Provide an `error` observer when caller owns recovery.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -11,38 +11,35 @@ pnpm add @vielzeug/flux
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return () => clearInterval(id);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Compose with operators
|
|
24
|
-
const even$ = count$.pipe(
|
|
25
|
-
filter((n) => n % 2 === 0),
|
|
26
|
-
map((n) => n * 2),
|
|
14
|
+
import { toArray, interval, map, pipe, take } from '@vielzeug/flux';
|
|
15
|
+
|
|
16
|
+
const values = pipe(
|
|
17
|
+
interval({ every: 100 }),
|
|
18
|
+
map((value) => value * 2),
|
|
19
|
+
take(3),
|
|
27
20
|
);
|
|
28
21
|
|
|
29
|
-
//
|
|
30
|
-
|
|
22
|
+
console.log(await toArray(values, { maxItems: 3 })); // [0, 2, 4]
|
|
23
|
+
```
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
## Channels
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { createChannel } from '@vielzeug/flux/subjects';
|
|
29
|
+
|
|
30
|
+
const events = createChannel<string>({ replay: 1 });
|
|
31
|
+
events.stream.subscribe(console.log);
|
|
32
|
+
events.send('connected');
|
|
33
|
+
events.dispose();
|
|
37
34
|
```
|
|
38
35
|
|
|
39
36
|
## Adapters
|
|
40
37
|
|
|
41
38
|
```ts
|
|
42
|
-
import {
|
|
43
|
-
import { fromBus
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
39
|
+
import { fromQuery } from '@vielzeug/flux/courier';
|
|
40
|
+
import { fromBus } from '@vielzeug/flux/herald';
|
|
41
|
+
import { fromPresence } from '@vielzeug/flux/pulse';
|
|
42
|
+
import { fromSignal, toSignal } from '@vielzeug/flux/ripple';
|
|
46
43
|
```
|
|
47
44
|
|
|
48
45
|
## License
|
package/dist/_dev.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,...t){}exports.error=e;
|
|
2
2
|
//# sourceMappingURL=_dev.cjs.map
|
package/dist/_dev.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dev.cjs","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/**\n * Set to `true` by the Vite `define` config in production builds so that all\n * dev-only `warn()` / `error()` calls are eliminated by the bundler.\n * When running tests or without a bundler the flag is absent and warnings fire.\n */\nconst isDev = !(globalThis as { __FLUX_PROD__?: boolean }).__FLUX_PROD__;\n\n/** @internal @security Messages may include user data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/flux] ${msg}`);\n}\n\n/** @internal @security Messages and args may include user data. */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/flux] ${msg}`, ...args);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"_dev.cjs","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/**\n * Set to `true` by the Vite `define` config in production builds so that all\n * dev-only `warn()` / `error()` calls are eliminated by the bundler.\n * When running tests or without a bundler the flag is absent and warnings fire.\n */\nconst isDev = !(globalThis as { __FLUX_PROD__?: boolean }).__FLUX_PROD__;\n\n/** @internal @security Messages may include user data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/flux] ${msg}`);\n}\n\n/** @internal @security Messages and args may include user data. */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/flux] ${msg}`, ...args);\n}\n"],"mappings":"AAaA,SAAgB,EAAM,EAAa,GAAG,EAAuB,CAE7D"}
|
package/dist/_dev.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
//#region src/_dev.ts
|
|
2
|
-
|
|
3
|
-
function t(t) {
|
|
4
|
-
e && console.warn(`[@vielzeug/flux] ${t}`);
|
|
5
|
-
}
|
|
6
|
-
function n(t, ...n) {
|
|
7
|
-
e && console.error(`[@vielzeug/flux] ${t}`, ...n);
|
|
8
|
-
}
|
|
2
|
+
function e(e, ...t) {}
|
|
9
3
|
//#endregion
|
|
10
|
-
export {
|
|
4
|
+
export { e as error };
|
|
11
5
|
|
|
12
6
|
//# sourceMappingURL=_dev.js.map
|
package/dist/_dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dev.js","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/**\n * Set to `true` by the Vite `define` config in production builds so that all\n * dev-only `warn()` / `error()` calls are eliminated by the bundler.\n * When running tests or without a bundler the flag is absent and warnings fire.\n */\nconst isDev = !(globalThis as { __FLUX_PROD__?: boolean }).__FLUX_PROD__;\n\n/** @internal @security Messages may include user data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/flux] ${msg}`);\n}\n\n/** @internal @security Messages and args may include user data. */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/flux] ${msg}`, ...args);\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"_dev.js","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/**\n * Set to `true` by the Vite `define` config in production builds so that all\n * dev-only `warn()` / `error()` calls are eliminated by the bundler.\n * When running tests or without a bundler the flag is absent and warnings fire.\n */\nconst isDev = !(globalThis as { __FLUX_PROD__?: boolean }).__FLUX_PROD__;\n\n/** @internal @security Messages may include user data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/flux] ${msg}`);\n}\n\n/** @internal @security Messages and args may include user data. */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/flux] ${msg}`, ...args);\n}\n"],"mappings":";AAaA,SAAgB,EAAM,GAAa,GAAG,GAAuB,CAE7D"}
|
package/dist/_iterator.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e){if(!Number.isInteger(e.capacity)||e.capacity<1)throw RangeError(`Async iterable capacity must be a positive integer`)}function t(t,n){e(n);let r=new AbortController,i=[],a={kind:`open`,queue:[]},o=()=>n.signal?.removeEventListener(`abort`,u),s=()=>{for(;i.length>0;)i.shift().resolve({done:!0,value:void 0})},c=()=>{a.kind===`open`&&(a.kind=`complete`,o(),s())},l=e=>{if(a.kind===`open`)for(a={kind:`error`,queue:a.queue,reason:e},r.abort(),o();i.length>0;)i.shift().reject(e)},u=()=>{r.abort(),o(),a={kind:`returned`},s()},d={complete:c,error:l,next(e){if(a.kind!==`open`)return;let t=i.shift();if(t){t.resolve({done:!1,value:e});return}if(a.queue.length<n.capacity){a.queue.push(e);return}n.overflow===`drop-oldest`?(a.queue.shift(),a.queue.push(e)):n.overflow===`error`&&l(RangeError(`Async iterable buffer capacity exceeded`))}};return n.signal?.aborted?u():n.signal?.addEventListener(`abort`,u,{once:!0}),t.subscribe(d,{signal:r.signal}),{next(){return a.kind===`returned`?Promise.resolve({done:!0,value:void 0}):a.queue.length>0?Promise.resolve({done:!1,value:a.queue.shift()}):a.kind===`error`?Promise.reject(a.reason):a.kind===`complete`?Promise.resolve({done:!0,value:void 0}):new Promise((e,t)=>i.push({reject:t,resolve:e}))},return(){return u(),Promise.resolve({done:!0,value:void 0})},[Symbol.asyncIterator](){return this}}}exports.toIterator=t;
|
|
2
2
|
//# sourceMappingURL=_iterator.cjs.map
|
package/dist/_iterator.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_iterator.cjs","names":[],"sources":["../src/_iterator.ts"],"sourcesContent":["import type { Observer,
|
|
1
|
+
{"version":3,"file":"_iterator.cjs","names":[],"sources":["../src/_iterator.ts"],"sourcesContent":["import type { AsyncIterableOptions, Observer, Stream } from './types';\n\ntype Pending<T> = {\n reject(reason: unknown): void;\n resolve(result: IteratorResult<T>): void;\n};\n\ntype IteratorState<T> =\n { kind: 'complete' | 'open'; queue: T[] } | { kind: 'error'; queue: T[]; reason: unknown } | { kind: 'returned' };\n\nfunction assertOptions(options: AsyncIterableOptions): void {\n if (!Number.isInteger(options.capacity) || options.capacity < 1) {\n throw new RangeError('Async iterable capacity must be a positive integer');\n }\n}\n\n/** Async iteration requires explicit queue policy because streams are push based. */\nexport function toIterator<T>(source: Stream<T>, options: AsyncIterableOptions): AsyncIterableIterator<T> {\n assertOptions(options);\n\n const controller = new AbortController();\n const pending: Pending<T>[] = [];\n let state: IteratorState<T> = { kind: 'open', queue: [] };\n\n const detach = (): void => options.signal?.removeEventListener('abort', stop);\n\n const resolveDone = (): void => {\n while (pending.length > 0) pending.shift()!.resolve({ done: true, value: undefined as T });\n };\n\n const complete = (): void => {\n if (state.kind !== 'open') return;\n\n state.kind = 'complete';\n detach();\n resolveDone();\n };\n\n const fail = (reason: unknown): void => {\n if (state.kind !== 'open') return;\n\n state = { kind: 'error', queue: state.queue, reason };\n controller.abort();\n detach();\n\n while (pending.length > 0) pending.shift()!.reject(reason);\n };\n\n const stop = (): void => {\n controller.abort();\n detach();\n state = { kind: 'returned' };\n resolveDone();\n };\n\n const observer: Observer<T> = {\n complete,\n error: fail,\n next(value) {\n if (state.kind !== 'open') return;\n\n const waiter = pending.shift();\n\n if (waiter) {\n waiter.resolve({ done: false, value });\n\n return;\n }\n\n if (state.queue.length < options.capacity) {\n state.queue.push(value);\n\n return;\n }\n\n if (options.overflow === 'drop-oldest') {\n state.queue.shift();\n state.queue.push(value);\n } else if (options.overflow === 'error') {\n fail(new RangeError('Async iterable buffer capacity exceeded'));\n }\n },\n };\n\n if (options.signal?.aborted) stop();\n else options.signal?.addEventListener('abort', stop, { once: true });\n\n source.subscribe(observer, { signal: controller.signal });\n\n return {\n next(): Promise<IteratorResult<T>> {\n if (state.kind === 'returned') return Promise.resolve({ done: true, value: undefined as T });\n\n if (state.queue.length > 0) return Promise.resolve({ done: false, value: state.queue.shift()! });\n\n if (state.kind === 'error') return Promise.reject(state.reason);\n\n if (state.kind === 'complete') return Promise.resolve({ done: true, value: undefined as T });\n\n return new Promise<IteratorResult<T>>((resolve, reject) => pending.push({ reject, resolve }));\n },\n return(): Promise<IteratorResult<T>> {\n stop();\n\n return Promise.resolve({ done: true, value: undefined as T });\n },\n [Symbol.asyncIterator](): AsyncIterableIterator<T> {\n return this;\n },\n };\n}\n"],"mappings":"AAUA,SAAS,EAAc,EAAqC,CAC1D,GAAI,CAAC,OAAO,UAAU,EAAQ,QAAQ,GAAK,EAAQ,SAAW,EAC5D,MAAU,WAAW,oDAAoD,CAE7E,CAGA,SAAgB,EAAc,EAAmB,EAAyD,CACxG,EAAc,CAAO,EAErB,IAAM,EAAa,IAAI,gBACjB,EAAwB,CAAC,EAC3B,EAA0B,CAAE,KAAM,OAAQ,MAAO,CAAC,CAAE,EAElD,MAAqB,EAAQ,QAAQ,oBAAoB,QAAS,CAAI,EAEtE,MAA0B,CAC9B,KAAO,EAAQ,OAAS,GAAG,EAAQ,MAAM,CAAC,CAAE,QAAQ,CAAE,KAAM,GAAM,MAAO,IAAA,EAAe,CAAC,CAC3F,EAEM,MAAuB,CACvB,EAAM,OAAS,SAEnB,EAAM,KAAO,WACb,EAAO,EACP,EAAY,EACd,EAEM,EAAQ,GAA0B,CAClC,KAAM,OAAS,OAMnB,IAJA,EAAQ,CAAE,KAAM,QAAS,MAAO,EAAM,MAAO,QAAO,EACpD,EAAW,MAAM,EACjB,EAAO,EAEA,EAAQ,OAAS,GAAG,EAAQ,MAAM,CAAC,CAAE,OAAO,CAAM,CAC3D,EAEM,MAAmB,CACvB,EAAW,MAAM,EACjB,EAAO,EACP,EAAQ,CAAE,KAAM,UAAW,EAC3B,EAAY,CACd,EAEM,EAAwB,CAC5B,WACA,MAAO,EACP,KAAK,EAAO,CACV,GAAI,EAAM,OAAS,OAAQ,OAE3B,IAAM,EAAS,EAAQ,MAAM,EAE7B,GAAI,EAAQ,CACV,EAAO,QAAQ,CAAE,KAAM,GAAO,OAAM,CAAC,EAErC,MACF,CAEA,GAAI,EAAM,MAAM,OAAS,EAAQ,SAAU,CACzC,EAAM,MAAM,KAAK,CAAK,EAEtB,MACF,CAEI,EAAQ,WAAa,eACvB,EAAM,MAAM,MAAM,EAClB,EAAM,MAAM,KAAK,CAAK,GACb,EAAQ,WAAa,SAC9B,EAAS,WAAW,yCAAyC,CAAC,CAElE,CACF,EAOA,OALI,EAAQ,QAAQ,QAAS,EAAK,EAC7B,EAAQ,QAAQ,iBAAiB,QAAS,EAAM,CAAE,KAAM,EAAK,CAAC,EAEnE,EAAO,UAAU,EAAU,CAAE,OAAQ,EAAW,MAAO,CAAC,EAEjD,CACL,MAAmC,CASjC,OARI,EAAM,OAAS,WAAmB,QAAQ,QAAQ,CAAE,KAAM,GAAM,MAAO,IAAA,EAAe,CAAC,EAEvF,EAAM,MAAM,OAAS,EAAU,QAAQ,QAAQ,CAAE,KAAM,GAAO,MAAO,EAAM,MAAM,MAAM,CAAG,CAAC,EAE3F,EAAM,OAAS,QAAgB,QAAQ,OAAO,EAAM,MAAM,EAE1D,EAAM,OAAS,WAAmB,QAAQ,QAAQ,CAAE,KAAM,GAAM,MAAO,IAAA,EAAe,CAAC,EAEpF,IAAI,SAA4B,EAAS,IAAW,EAAQ,KAAK,CAAE,SAAQ,SAAQ,CAAC,CAAC,CAC9F,EACA,QAAqC,CAGnC,OAFA,EAAK,EAEE,QAAQ,QAAQ,CAAE,KAAM,GAAM,MAAO,IAAA,EAAe,CAAC,CAC9D,EACA,CAAC,OAAO,gBAA2C,CACjD,OAAO,IACT,CACF,CACF"}
|
package/dist/_iterator.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { AsyncIterableOptions, Stream } from './types';
|
|
2
|
+
/** Async iteration requires explicit queue policy because streams are push based. */
|
|
3
|
+
export declare function toIterator<T>(source: Stream<T>, options: AsyncIterableOptions): AsyncIterableIterator<T>;
|
|
2
4
|
//# sourceMappingURL=_iterator.d.ts.map
|
package/dist/_iterator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_iterator.d.ts","sourceRoot":"","sources":["../src/_iterator.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"_iterator.d.ts","sourceRoot":"","sources":["../src/_iterator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAY,MAAM,EAAE,MAAM,SAAS,CAAC;AAgBtE,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,oBAAoB,GAAG,qBAAqB,CAAC,CAAC,CAAC,CA6FxG"}
|
package/dist/_iterator.js
CHANGED
|
@@ -1,53 +1,75 @@
|
|
|
1
|
-
import { warn as e } from "./_dev.js";
|
|
2
1
|
//#region src/_iterator.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (!Number.isInteger(e.capacity) || e.capacity < 1) throw RangeError("Async iterable capacity must be a positive integer");
|
|
4
|
+
}
|
|
5
|
+
function t(t, n) {
|
|
6
|
+
e(n);
|
|
7
|
+
let r = new AbortController(), i = [], a = {
|
|
8
|
+
kind: "open",
|
|
9
|
+
queue: []
|
|
10
|
+
}, o = () => n.signal?.removeEventListener("abort", u), s = () => {
|
|
11
|
+
for (; i.length > 0;) i.shift().resolve({
|
|
12
|
+
done: !0,
|
|
13
|
+
value: void 0
|
|
14
|
+
});
|
|
15
|
+
}, c = () => {
|
|
16
|
+
a.kind === "open" && (a.kind = "complete", o(), s());
|
|
17
|
+
}, l = (e) => {
|
|
18
|
+
if (a.kind === "open") for (a = {
|
|
19
|
+
kind: "error",
|
|
20
|
+
queue: a.queue,
|
|
21
|
+
reason: e
|
|
22
|
+
}, r.abort(), o(); i.length > 0;) i.shift().reject(e);
|
|
23
|
+
}, u = () => {
|
|
24
|
+
r.abort(), o(), a = { kind: "returned" }, s();
|
|
25
|
+
}, d = {
|
|
26
|
+
complete: c,
|
|
27
|
+
error: l,
|
|
28
|
+
next(e) {
|
|
29
|
+
if (a.kind !== "open") return;
|
|
30
|
+
let t = i.shift();
|
|
31
|
+
if (t) {
|
|
32
|
+
t.resolve({
|
|
33
|
+
done: !1,
|
|
34
|
+
value: e
|
|
35
|
+
});
|
|
22
36
|
return;
|
|
23
37
|
}
|
|
24
|
-
|
|
38
|
+
if (a.queue.length < n.capacity) {
|
|
39
|
+
a.queue.push(e);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
n.overflow === "drop-oldest" ? (a.queue.shift(), a.queue.push(e)) : n.overflow === "error" && l(/* @__PURE__ */ RangeError("Async iterable buffer capacity exceeded"));
|
|
25
43
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
for (; i.length > 0;) i.shift().resolve(s);
|
|
29
|
-
}
|
|
30
|
-
let u = {
|
|
44
|
+
};
|
|
45
|
+
return n.signal?.aborted ? u() : n.signal?.addEventListener("abort", u, { once: !0 }), t.subscribe(d, { signal: r.signal }), {
|
|
31
46
|
next() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
47
|
+
return a.kind === "returned" ? Promise.resolve({
|
|
48
|
+
done: !0,
|
|
49
|
+
value: void 0
|
|
50
|
+
}) : a.queue.length > 0 ? Promise.resolve({
|
|
51
|
+
done: !1,
|
|
52
|
+
value: a.queue.shift()
|
|
53
|
+
}) : a.kind === "error" ? Promise.reject(a.reason) : a.kind === "complete" ? Promise.resolve({
|
|
54
|
+
done: !0,
|
|
55
|
+
value: void 0
|
|
56
|
+
}) : new Promise((e, t) => i.push({
|
|
37
57
|
reject: t,
|
|
38
58
|
resolve: e
|
|
39
59
|
}));
|
|
40
60
|
},
|
|
41
61
|
return() {
|
|
42
|
-
return
|
|
62
|
+
return u(), Promise.resolve({
|
|
63
|
+
done: !0,
|
|
64
|
+
value: void 0
|
|
65
|
+
});
|
|
43
66
|
},
|
|
44
67
|
[Symbol.asyncIterator]() {
|
|
45
|
-
return
|
|
68
|
+
return this;
|
|
46
69
|
}
|
|
47
70
|
};
|
|
48
|
-
return u;
|
|
49
71
|
}
|
|
50
72
|
//#endregion
|
|
51
|
-
export {
|
|
73
|
+
export { t as toIterator };
|
|
52
74
|
|
|
53
75
|
//# sourceMappingURL=_iterator.js.map
|
package/dist/_iterator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_iterator.js","names":[],"sources":["../src/_iterator.ts"],"sourcesContent":["import type { Observer,
|
|
1
|
+
{"version":3,"file":"_iterator.js","names":[],"sources":["../src/_iterator.ts"],"sourcesContent":["import type { AsyncIterableOptions, Observer, Stream } from './types';\n\ntype Pending<T> = {\n reject(reason: unknown): void;\n resolve(result: IteratorResult<T>): void;\n};\n\ntype IteratorState<T> =\n { kind: 'complete' | 'open'; queue: T[] } | { kind: 'error'; queue: T[]; reason: unknown } | { kind: 'returned' };\n\nfunction assertOptions(options: AsyncIterableOptions): void {\n if (!Number.isInteger(options.capacity) || options.capacity < 1) {\n throw new RangeError('Async iterable capacity must be a positive integer');\n }\n}\n\n/** Async iteration requires explicit queue policy because streams are push based. */\nexport function toIterator<T>(source: Stream<T>, options: AsyncIterableOptions): AsyncIterableIterator<T> {\n assertOptions(options);\n\n const controller = new AbortController();\n const pending: Pending<T>[] = [];\n let state: IteratorState<T> = { kind: 'open', queue: [] };\n\n const detach = (): void => options.signal?.removeEventListener('abort', stop);\n\n const resolveDone = (): void => {\n while (pending.length > 0) pending.shift()!.resolve({ done: true, value: undefined as T });\n };\n\n const complete = (): void => {\n if (state.kind !== 'open') return;\n\n state.kind = 'complete';\n detach();\n resolveDone();\n };\n\n const fail = (reason: unknown): void => {\n if (state.kind !== 'open') return;\n\n state = { kind: 'error', queue: state.queue, reason };\n controller.abort();\n detach();\n\n while (pending.length > 0) pending.shift()!.reject(reason);\n };\n\n const stop = (): void => {\n controller.abort();\n detach();\n state = { kind: 'returned' };\n resolveDone();\n };\n\n const observer: Observer<T> = {\n complete,\n error: fail,\n next(value) {\n if (state.kind !== 'open') return;\n\n const waiter = pending.shift();\n\n if (waiter) {\n waiter.resolve({ done: false, value });\n\n return;\n }\n\n if (state.queue.length < options.capacity) {\n state.queue.push(value);\n\n return;\n }\n\n if (options.overflow === 'drop-oldest') {\n state.queue.shift();\n state.queue.push(value);\n } else if (options.overflow === 'error') {\n fail(new RangeError('Async iterable buffer capacity exceeded'));\n }\n },\n };\n\n if (options.signal?.aborted) stop();\n else options.signal?.addEventListener('abort', stop, { once: true });\n\n source.subscribe(observer, { signal: controller.signal });\n\n return {\n next(): Promise<IteratorResult<T>> {\n if (state.kind === 'returned') return Promise.resolve({ done: true, value: undefined as T });\n\n if (state.queue.length > 0) return Promise.resolve({ done: false, value: state.queue.shift()! });\n\n if (state.kind === 'error') return Promise.reject(state.reason);\n\n if (state.kind === 'complete') return Promise.resolve({ done: true, value: undefined as T });\n\n return new Promise<IteratorResult<T>>((resolve, reject) => pending.push({ reject, resolve }));\n },\n return(): Promise<IteratorResult<T>> {\n stop();\n\n return Promise.resolve({ done: true, value: undefined as T });\n },\n [Symbol.asyncIterator](): AsyncIterableIterator<T> {\n return this;\n },\n };\n}\n"],"mappings":";AAUA,SAAS,EAAc,GAAqC;CAC1D,IAAI,CAAC,OAAO,UAAU,EAAQ,QAAQ,KAAK,EAAQ,WAAW,GAC5D,MAAU,WAAW,oDAAoD;AAE7E;AAGA,SAAgB,EAAc,GAAmB,GAAyD;CACxG,EAAc,CAAO;CAErB,IAAM,IAAa,IAAI,gBAAgB,GACjC,IAAwB,CAAC,GAC3B,IAA0B;EAAE,MAAM;EAAQ,OAAO,CAAC;CAAE,GAElD,UAAqB,EAAQ,QAAQ,oBAAoB,SAAS,CAAI,GAEtE,UAA0B;EAC9B,OAAO,EAAQ,SAAS,IAAG,EAAQ,MAAM,CAAC,CAAE,QAAQ;GAAE,MAAM;GAAM,OAAO,KAAA;EAAe,CAAC;CAC3F,GAEM,UAAuB;EACvB,EAAM,SAAS,WAEnB,EAAM,OAAO,YACb,EAAO,GACP,EAAY;CACd,GAEM,KAAQ,MAA0B;EAClC,MAAM,SAAS,QAMnB,KAJA,IAAQ;GAAE,MAAM;GAAS,OAAO,EAAM;GAAO;EAAO,GACpD,EAAW,MAAM,GACjB,EAAO,GAEA,EAAQ,SAAS,IAAG,EAAQ,MAAM,CAAC,CAAE,OAAO,CAAM;CAC3D,GAEM,UAAmB;EAIvB,AAHA,EAAW,MAAM,GACjB,EAAO,GACP,IAAQ,EAAE,MAAM,WAAW,GAC3B,EAAY;CACd,GAEM,IAAwB;EAC5B;EACA,OAAO;EACP,KAAK,GAAO;GACV,IAAI,EAAM,SAAS,QAAQ;GAE3B,IAAM,IAAS,EAAQ,MAAM;GAE7B,IAAI,GAAQ;IACV,EAAO,QAAQ;KAAE,MAAM;KAAO;IAAM,CAAC;IAErC;GACF;GAEA,IAAI,EAAM,MAAM,SAAS,EAAQ,UAAU;IACzC,EAAM,MAAM,KAAK,CAAK;IAEtB;GACF;GAEA,AAAI,EAAQ,aAAa,iBACvB,EAAM,MAAM,MAAM,GAClB,EAAM,MAAM,KAAK,CAAK,KACb,EAAQ,aAAa,WAC9B,EAAK,gBAAI,WAAW,yCAAyC,CAAC;EAElE;CACF;CAOA,OALI,EAAQ,QAAQ,UAAS,EAAK,IAC7B,EAAQ,QAAQ,iBAAiB,SAAS,GAAM,EAAE,MAAM,GAAK,CAAC,GAEnE,EAAO,UAAU,GAAU,EAAE,QAAQ,EAAW,OAAO,CAAC,GAEjD;EACL,OAAmC;GASjC,OARI,EAAM,SAAS,aAAmB,QAAQ,QAAQ;IAAE,MAAM;IAAM,OAAO,KAAA;GAAe,CAAC,IAEvF,EAAM,MAAM,SAAS,IAAU,QAAQ,QAAQ;IAAE,MAAM;IAAO,OAAO,EAAM,MAAM,MAAM;GAAG,CAAC,IAE3F,EAAM,SAAS,UAAgB,QAAQ,OAAO,EAAM,MAAM,IAE1D,EAAM,SAAS,aAAmB,QAAQ,QAAQ;IAAE,MAAM;IAAM,OAAO,KAAA;GAAe,CAAC,IAEpF,IAAI,SAA4B,GAAS,MAAW,EAAQ,KAAK;IAAE;IAAQ;GAAQ,CAAC,CAAC;EAC9F;EACA,SAAqC;GAGnC,OAFA,EAAK,GAEE,QAAQ,QAAQ;IAAE,MAAM;IAAM,OAAO,KAAA;GAAe,CAAC;EAC9D;EACA,CAAC,OAAO,iBAA2C;GACjD,OAAO;EACT;CACF;AACF"}
|
package/dist/_link.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_link.cjs","names":[],"sources":["../src/_link.ts"],"sourcesContent":["import type { Observer, Stream, Subscription } from './types';\n\n/** Every operator forwards its own lifetime to every upstream subscription. */\nexport function link<T>(source: Stream<T>, observer: Observer<T>, signal: AbortSignal): Subscription {\n return source.subscribe(observer, { signal });\n}\n"],"mappings":"AAGA,SAAgB,EAAQ,EAAmB,EAAuB,EAAmC,CACnG,OAAO,EAAO,UAAU,EAAU,CAAE,QAAO,CAAC,CAC9C"}
|
package/dist/_link.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Observer, Stream, Subscription } from './types';
|
|
2
|
+
/** Every operator forwards its own lifetime to every upstream subscription. */
|
|
3
|
+
export declare function link<T>(source: Stream<T>, observer: Observer<T>, signal: AbortSignal): Subscription;
|
|
4
|
+
//# sourceMappingURL=_link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_link.d.ts","sourceRoot":"","sources":["../src/_link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE9D,+EAA+E;AAC/E,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,YAAY,CAEnG"}
|
package/dist/_link.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_link.js","names":[],"sources":["../src/_link.ts"],"sourcesContent":["import type { Observer, Stream, Subscription } from './types';\n\n/** Every operator forwards its own lifetime to every upstream subscription. */\nexport function link<T>(source: Stream<T>, observer: Observer<T>, signal: AbortSignal): Subscription {\n return source.subscribe(observer, { signal });\n}\n"],"mappings":";AAGA,SAAgB,EAAQ,GAAmB,GAAuB,GAAmC;CACnG,OAAO,EAAO,UAAU,GAAU,EAAE,UAAO,CAAC;AAC9C"}
|
package/dist/_numeric.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e){
|
|
1
|
+
function e(e,t){if(!Number.isInteger(e)||e<0)throw RangeError(`${t} must be a non-negative integer`)}exports.assertNonNegativeInteger=e;
|
|
2
2
|
//# sourceMappingURL=_numeric.cjs.map
|
package/dist/_numeric.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_numeric.cjs","names":[],"sources":["../src/_numeric.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"_numeric.cjs","names":[],"sources":["../src/_numeric.ts"],"sourcesContent":["export function assertNonNegativeInteger(value: number, name: string): void {\n if (!Number.isInteger(value) || value < 0) {\n throw new RangeError(`${name} must be a non-negative integer`);\n }\n}\n\nexport function assertPositiveInteger(value: number, name: string): void {\n if (!Number.isInteger(value) || value < 1) {\n throw new RangeError(`${name} must be a positive integer`);\n }\n}\n"],"mappings":"AAAA,SAAgB,EAAyB,EAAe,EAAoB,CAC1E,GAAI,CAAC,OAAO,UAAU,CAAK,GAAK,EAAQ,EACtC,MAAU,WAAW,GAAG,EAAK,gCAAgC,CAEjE"}
|
package/dist/_numeric.d.ts
CHANGED
package/dist/_numeric.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_numeric.d.ts","sourceRoot":"","sources":["../src/_numeric.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"_numeric.d.ts","sourceRoot":"","sources":["../src/_numeric.ts"],"names":[],"mappings":"AAAA,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAI1E;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAIvE"}
|
package/dist/_numeric.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
//#region src/_numeric.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
|
|
4
|
-
return {
|
|
5
|
-
clamped: t !== e,
|
|
6
|
-
value: t
|
|
7
|
-
};
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (!Number.isInteger(e) || e < 0) throw RangeError(`${t} must be a non-negative integer`);
|
|
8
4
|
}
|
|
9
5
|
//#endregion
|
|
10
|
-
export { e as
|
|
6
|
+
export { e as assertNonNegativeInteger };
|
|
11
7
|
|
|
12
8
|
//# sourceMappingURL=_numeric.js.map
|
package/dist/_numeric.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_numeric.js","names":[],"sources":["../src/_numeric.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"_numeric.js","names":[],"sources":["../src/_numeric.ts"],"sourcesContent":["export function assertNonNegativeInteger(value: number, name: string): void {\n if (!Number.isInteger(value) || value < 0) {\n throw new RangeError(`${name} must be a non-negative integer`);\n }\n}\n\nexport function assertPositiveInteger(value: number, name: string): void {\n if (!Number.isInteger(value) || value < 1) {\n throw new RangeError(`${name} must be a positive integer`);\n }\n}\n"],"mappings":";AAAA,SAAgB,EAAyB,GAAe,GAAoB;CAC1E,IAAI,CAAC,OAAO,UAAU,CAAK,KAAK,IAAQ,GACtC,MAAU,WAAW,GAAG,EAAK,gCAAgC;AAEjE"}
|
package/dist/_pipe.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e){return
|
|
1
|
+
function e(e,t){return t.reduce((e,t)=>t(e),e)}exports.applyOperators=e;
|
|
2
2
|
//# sourceMappingURL=_pipe.cjs.map
|
package/dist/_pipe.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_pipe.cjs","names":[],"sources":["../src/_pipe.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"_pipe.cjs","names":[],"sources":["../src/_pipe.ts"],"sourcesContent":["import type { Operator, Stream } from './types';\n\nexport function applyOperators(source: Stream<unknown>, operators: readonly Operator[]): Stream<unknown> {\n return operators.reduce((current, operator) => operator(current), source);\n}\n"],"mappings":"AAEA,SAAgB,EAAe,EAAyB,EAAiD,CACvG,OAAO,EAAU,QAAQ,EAAS,IAAa,EAAS,CAAO,EAAG,CAAM,CAC1E"}
|
package/dist/_pipe.d.ts
CHANGED
package/dist/_pipe.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_pipe.d.ts","sourceRoot":"","sources":["../src/_pipe.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"_pipe.d.ts","sourceRoot":"","sources":["../src/_pipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,CAEvG"}
|
package/dist/_pipe.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/_pipe.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
return
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
return t.reduce((e, t) => t(e), e);
|
|
4
4
|
}
|
|
5
5
|
//#endregion
|
|
6
|
-
export { e as
|
|
6
|
+
export { e as applyOperators };
|
|
7
7
|
|
|
8
8
|
//# sourceMappingURL=_pipe.js.map
|
package/dist/_pipe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_pipe.js","names":[],"sources":["../src/_pipe.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"_pipe.js","names":[],"sources":["../src/_pipe.ts"],"sourcesContent":["import type { Operator, Stream } from './types';\n\nexport function applyOperators(source: Stream<unknown>, operators: readonly Operator[]): Stream<unknown> {\n return operators.reduce((current, operator) => operator(current), source);\n}\n"],"mappings":";AAEA,SAAgB,EAAe,GAAyB,GAAiD;CACvG,OAAO,EAAU,QAAQ,GAAS,MAAa,EAAS,CAAO,GAAG,CAAM;AAC1E"}
|
package/dist/_safe.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t){try{e()}catch(e){t
|
|
1
|
+
function e(e,t){try{e()}catch(e){t(e)}}exports.tryCall=e;
|
|
2
2
|
//# sourceMappingURL=_safe.cjs.map
|
package/dist/_safe.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_safe.cjs","names":[],"sources":["../src/_safe.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"_safe.cjs","names":[],"sources":["../src/_safe.ts"],"sourcesContent":["export function tryCall(callback: () => void, onError: (reason: unknown) => void): void {\n try {\n callback();\n } catch (reason) {\n onError(reason);\n }\n}\n"],"mappings":"AAAA,SAAgB,EAAQ,EAAsB,EAA0C,CACtF,GAAI,CACF,EAAS,CACX,OAAS,EAAQ,CACf,EAAQ,CAAM,CAChB,CACF"}
|
package/dist/_safe.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function tryCall(callback: () => void, onError: (reason: unknown) => void): void;
|
|
2
2
|
//# sourceMappingURL=_safe.d.ts.map
|
package/dist/_safe.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_safe.d.ts","sourceRoot":"","sources":["../src/_safe.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"_safe.d.ts","sourceRoot":"","sources":["../src/_safe.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAMtF"}
|
package/dist/_safe.js
CHANGED
package/dist/_safe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_safe.js","names":[],"sources":["../src/_safe.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"_safe.js","names":[],"sources":["../src/_safe.ts"],"sourcesContent":["export function tryCall(callback: () => void, onError: (reason: unknown) => void): void {\n try {\n callback();\n } catch (reason) {\n onError(reason);\n }\n}\n"],"mappings":";AAAA,SAAgB,EAAQ,GAAsB,GAA0C;CACtF,IAAI;EACF,EAAS;CACX,SAAS,GAAQ;EACf,EAAQ,CAAM;CAChB;AACF"}
|
package/dist/_scheduler.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e={delay(e,t){let n=setTimeout(e,t);return()=>clearTimeout(n)},repeat(e,t){let n=setInterval(e,t);return()=>clearInterval(n)}};exports.
|
|
1
|
+
var e={delay(e,t){let n=setTimeout(e,t);return()=>clearTimeout(n)},repeat(e,t){let n=setInterval(e,t);return()=>clearInterval(n)}};exports.defaultScheduler=e;
|
|
2
2
|
//# sourceMappingURL=_scheduler.cjs.map
|
package/dist/_scheduler.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_scheduler.cjs","names":[],"sources":["../src/_scheduler.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"_scheduler.cjs","names":[],"sources":["../src/_scheduler.ts"],"sourcesContent":["export type Scheduler = {\n delay(callback: () => void, milliseconds: number): () => void;\n repeat(callback: () => void, milliseconds: number): () => void;\n};\n\nexport const defaultScheduler: Scheduler = {\n delay(callback, milliseconds) {\n const id = setTimeout(callback, milliseconds);\n\n return () => clearTimeout(id);\n },\n repeat(callback, milliseconds) {\n const id = setInterval(callback, milliseconds);\n\n return () => clearInterval(id);\n },\n};\n"],"mappings":"AAKA,IAAa,EAA8B,CACzC,MAAM,EAAU,EAAc,CAC5B,IAAM,EAAK,WAAW,EAAU,CAAY,EAE5C,UAAa,aAAa,CAAE,CAC9B,EACA,OAAO,EAAU,EAAc,CAC7B,IAAM,EAAK,YAAY,EAAU,CAAY,EAE7C,UAAa,cAAc,CAAE,CAC/B,CACF"}
|
package/dist/_scheduler.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export type Scheduler = {
|
|
2
|
+
delay(callback: () => void, milliseconds: number): () => void;
|
|
3
|
+
repeat(callback: () => void, milliseconds: number): () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare const defaultScheduler: Scheduler;
|
|
3
6
|
//# sourceMappingURL=_scheduler.d.ts.map
|
package/dist/_scheduler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_scheduler.d.ts","sourceRoot":"","sources":["../src/_scheduler.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"_scheduler.d.ts","sourceRoot":"","sources":["../src/_scheduler.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;IAC9D,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;CAChE,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,SAW9B,CAAC"}
|
package/dist/_scheduler.js
CHANGED
package/dist/_scheduler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_scheduler.js","names":[],"sources":["../src/_scheduler.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"_scheduler.js","names":[],"sources":["../src/_scheduler.ts"],"sourcesContent":["export type Scheduler = {\n delay(callback: () => void, milliseconds: number): () => void;\n repeat(callback: () => void, milliseconds: number): () => void;\n};\n\nexport const defaultScheduler: Scheduler = {\n delay(callback, milliseconds) {\n const id = setTimeout(callback, milliseconds);\n\n return () => clearTimeout(id);\n },\n repeat(callback, milliseconds) {\n const id = setInterval(callback, milliseconds);\n\n return () => clearInterval(id);\n },\n};\n"],"mappings":";AAKA,IAAa,IAA8B;CACzC,MAAM,GAAU,GAAc;EAC5B,IAAM,IAAK,WAAW,GAAU,CAAY;EAE5C,aAAa,aAAa,CAAE;CAC9B;CACA,OAAO,GAAU,GAAc;EAC7B,IAAM,IAAK,YAAY,GAAU,CAAY;EAE7C,aAAa,cAAc,CAAE;CAC/B;AACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){let t=globalThis.reportError;if(t){t(e);return}queueMicrotask(()=>{throw e})}function t(t,n){let r=typeof t==`function`?{next:t}:t,i=new AbortController,a=!1,o,s=()=>{if(!a){a=!0,i.abort(),n?.removeEventListener(`abort`,s);try{o?.()}catch(t){e(t)}}};return n?.aborted?s():n?.addEventListener(`abort`,s,{once:!0}),{add:t=>{if(t){if(a){try{t()}catch(t){e(t)}return}o=t}},signal:i.signal,sink:{complete(){if(!a){try{r.complete?.()}catch(t){e(t)}s()}},error(t){if(!a){if(r.error)try{r.error(t)}catch(t){e(t)}else e(t);s()}},next(t){if(!a)try{r.next(t)}catch(t){s(),e(t)}}},subscription:{get closed(){return a},[Symbol.dispose]:s,unsubscribe:s}}}exports.createSubscription=t;
|
|
2
|
+
//# sourceMappingURL=_subscription.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_subscription.cjs","names":[],"sources":["../src/_subscription.ts"],"sourcesContent":["import type { Observer, Sink, Subscription, Teardown } from './types';\n\nfunction reportUnhandledError(reason: unknown): void {\n const reportError = (globalThis as { reportError?: (value: unknown) => void }).reportError;\n\n if (reportError) {\n reportError(reason);\n\n return;\n }\n\n queueMicrotask(() => {\n throw reason;\n });\n}\n\nexport function createSubscription<T>(\n observerOrNext: Observer<T> | ((value: T) => void),\n signal?: AbortSignal,\n): { add(teardown: Teardown | void): void; signal: AbortSignal; sink: Sink<T>; subscription: Subscription } {\n const observer: Observer<T> = typeof observerOrNext === 'function' ? { next: observerOrNext } : observerOrNext;\n const controller = new AbortController();\n let closed = false;\n let teardown: Teardown | undefined;\n\n const unsubscribe = (): void => {\n if (closed) return;\n\n closed = true;\n controller.abort();\n signal?.removeEventListener('abort', unsubscribe);\n\n try {\n teardown?.();\n } catch (reason) {\n reportUnhandledError(reason);\n }\n };\n\n const sink: Sink<T> = {\n complete(): void {\n if (closed) return;\n\n try {\n observer.complete?.();\n } catch (reason) {\n reportUnhandledError(reason);\n }\n\n unsubscribe();\n },\n\n error(reason: unknown): void {\n if (closed) return;\n\n if (observer.error) {\n try {\n observer.error(reason);\n } catch (callbackError) {\n reportUnhandledError(callbackError);\n }\n } else {\n reportUnhandledError(reason);\n }\n\n unsubscribe();\n },\n\n next(value: T): void {\n if (closed) return;\n\n try {\n observer.next(value);\n } catch (reason) {\n unsubscribe();\n reportUnhandledError(reason);\n }\n },\n };\n\n const add = (nextTeardown: Teardown | void): void => {\n if (!nextTeardown) return;\n\n if (closed) {\n try {\n nextTeardown();\n } catch (reason) {\n reportUnhandledError(reason);\n }\n\n return;\n }\n\n teardown = nextTeardown;\n };\n\n if (signal?.aborted) {\n unsubscribe();\n } else {\n signal?.addEventListener('abort', unsubscribe, { once: true });\n }\n\n return {\n add,\n signal: controller.signal,\n sink,\n subscription: {\n get closed(): boolean {\n return closed;\n },\n [Symbol.dispose]: unsubscribe,\n unsubscribe,\n },\n };\n}\n"],"mappings":"AAEA,SAAS,EAAqB,EAAuB,CACnD,IAAM,EAAe,WAA0D,YAE/E,GAAI,EAAa,CACf,EAAY,CAAM,EAElB,MACF,CAEA,mBAAqB,CACnB,MAAM,CACR,CAAC,CACH,CAEA,SAAgB,EACd,EACA,EAC0G,CAC1G,IAAM,EAAwB,OAAO,GAAmB,WAAa,CAAE,KAAM,CAAe,EAAI,EAC1F,EAAa,IAAI,gBACnB,EAAS,GACT,EAEE,MAA0B,CAC1B,MAIJ,CAFA,EAAS,GACT,EAAW,MAAM,EACjB,GAAQ,oBAAoB,QAAS,CAAW,EAEhD,GAAI,CACF,IAAW,CACb,OAAS,EAAQ,CACf,EAAqB,CAAM,CAC7B,CANgD,CAOlD,EAiEA,OANI,GAAQ,QACV,EAAY,EAEZ,GAAQ,iBAAiB,QAAS,EAAa,CAAE,KAAM,EAAK,CAAC,EAGxD,CACL,IAvBW,GAAwC,CAC9C,KAEL,IAAI,EAAQ,CACV,GAAI,CACF,EAAa,CACf,OAAS,EAAQ,CACf,EAAqB,CAAM,CAC7B,CAEA,MACF,CAEA,EAAW,CAFX,CAGF,EAUE,OAAQ,EAAW,OACnB,MAjEA,UAAiB,CACX,MAEJ,IAAI,CACF,EAAS,WAAW,CACtB,OAAS,EAAQ,CACf,EAAqB,CAAM,CAC7B,CAEA,EAAY,CAFZ,CAGF,EAEA,MAAM,EAAuB,CACvB,MAEJ,IAAI,EAAS,MACX,GAAI,CACF,EAAS,MAAM,CAAM,CACvB,OAAS,EAAe,CACtB,EAAqB,CAAa,CACpC,MAEA,EAAqB,CAAM,EAG7B,EAAY,CAHiB,CAI/B,EAEA,KAAK,EAAgB,CACf,MAEJ,GAAI,CACF,EAAS,KAAK,CAAK,CACrB,OAAS,EAAQ,CACf,EAAY,EACZ,EAAqB,CAAM,CAC7B,CACF,CA4BA,EACA,aAAc,CACZ,IAAI,QAAkB,CACpB,OAAO,CACT,GACC,OAAO,SAAU,EAClB,aACF,CACF,CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Observer, Sink, Subscription, Teardown } from './types';
|
|
2
|
+
export declare function createSubscription<T>(observerOrNext: Observer<T> | ((value: T) => void), signal?: AbortSignal): {
|
|
3
|
+
add(teardown: Teardown | void): void;
|
|
4
|
+
signal: AbortSignal;
|
|
5
|
+
sink: Sink<T>;
|
|
6
|
+
subscription: Subscription;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=_subscription.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_subscription.d.ts","sourceRoot":"","sources":["../src/_subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAgBtE,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,EAClD,MAAM,CAAC,EAAE,WAAW,GACnB;IAAE,GAAG,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAAC,YAAY,EAAE,YAAY,CAAA;CAAE,CA+F1G"}
|