@ersbeth/picoflow 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/doc/index.md +1 -1
- package/api/doc/picoflow.array.md +55 -0
- package/api/doc/picoflow.constant.md +55 -0
- package/api/doc/picoflow.derivation.md +1 -1
- package/api/doc/picoflow.effect.md +1 -1
- package/api/doc/picoflow.flowarray._constructor_.md +49 -0
- package/api/doc/picoflow.flowarray._lastaction.md +13 -0
- package/api/doc/picoflow.flowarray.clear.md +17 -0
- package/api/doc/picoflow.flowarray.dispose.md +55 -0
- package/api/doc/picoflow.flowarray.get.md +19 -0
- package/api/doc/picoflow.flowarray.length.md +13 -0
- package/api/doc/picoflow.flowarray.md +273 -0
- package/api/doc/picoflow.flowarray.pop.md +17 -0
- package/api/doc/picoflow.flowarray.push.md +53 -0
- package/api/doc/picoflow.flowarray.set.md +53 -0
- package/api/doc/picoflow.flowarray.setitem.md +69 -0
- package/api/doc/picoflow.flowarray.shift.md +17 -0
- package/api/doc/picoflow.flowarray.splice.md +85 -0
- package/api/doc/picoflow.flowarray.unshift.md +53 -0
- package/api/doc/picoflow.flowarrayaction.md +37 -0
- package/api/doc/picoflow.flowconstant._constructor_.md +49 -0
- package/api/doc/picoflow.flowconstant.get.md +25 -0
- package/api/doc/picoflow.flowconstant.md +88 -0
- package/api/doc/picoflow.flowderivation._constructor_.md +2 -2
- package/api/doc/picoflow.flowderivation.get.md +2 -2
- package/api/doc/picoflow.flowderivation.md +2 -2
- package/api/doc/picoflow.flowdisposable.dispose.md +55 -0
- package/api/doc/picoflow.flowdisposable.md +43 -0
- package/api/doc/picoflow.floweffect._constructor_.md +7 -2
- package/api/doc/picoflow.floweffect.dispose.md +3 -3
- package/api/doc/picoflow.floweffect.disposed.md +1 -1
- package/api/doc/picoflow.floweffect.md +4 -4
- package/api/doc/picoflow.flowgetter.md +2 -2
- package/api/doc/picoflow.flowmap._lastdeleted.md +1 -1
- package/api/doc/picoflow.flowmap._lastset.md +1 -1
- package/api/doc/picoflow.flowmap.delete.md +6 -2
- package/api/doc/picoflow.flowmap.md +5 -7
- package/api/doc/picoflow.flowmap.setat.md +6 -2
- package/api/doc/picoflow.flowobservable.get.md +3 -3
- package/api/doc/picoflow.flowobservable.md +18 -4
- package/api/doc/picoflow.flowobservable.subscribe.md +55 -0
- package/api/doc/picoflow.flowresource._constructor_.md +2 -18
- package/api/doc/picoflow.flowresource.fetch.md +1 -1
- package/api/doc/picoflow.flowresource.get.md +4 -4
- package/api/doc/picoflow.flowresource.md +4 -4
- package/api/doc/picoflow.flowresourceasync._constructor_.md +49 -0
- package/api/doc/picoflow.flowresourceasync.fetch.md +27 -0
- package/api/doc/picoflow.flowresourceasync.get.md +23 -0
- package/api/doc/picoflow.flowresourceasync.md +100 -0
- package/api/doc/picoflow.flowsignal.dispose.md +42 -8
- package/api/doc/picoflow.flowsignal.disposed.md +2 -2
- package/api/doc/picoflow.flowsignal.md +8 -7
- package/api/doc/picoflow.flowsignal.trigger.md +3 -7
- package/api/doc/picoflow.flowstate.md +4 -52
- package/api/doc/picoflow.flowstate.set.md +5 -5
- package/api/doc/picoflow.flowstream._constructor_.md +3 -19
- package/api/doc/picoflow.flowstream.dispose.md +1 -1
- package/api/doc/picoflow.flowstream.get.md +4 -4
- package/api/doc/picoflow.flowstream.md +5 -5
- package/api/doc/picoflow.flowstreamasync._constructor_.md +54 -0
- package/api/doc/picoflow.flowstreamasync.dispose.md +21 -0
- package/api/doc/picoflow.flowstreamasync.get.md +23 -0
- package/api/doc/picoflow.flowstreamasync.md +100 -0
- package/api/doc/picoflow.flowstreamdisposer.md +13 -0
- package/api/doc/picoflow.flowstreamsetter.md +13 -0
- package/api/doc/picoflow.flowstreamupdater.md +19 -0
- package/api/doc/picoflow.flowwatcher.md +1 -1
- package/api/doc/picoflow.isdisposable.md +55 -0
- package/api/doc/picoflow.map.md +1 -1
- package/api/doc/picoflow.md +149 -13
- package/api/doc/picoflow.resource.md +2 -18
- package/api/doc/picoflow.resourceasync.md +55 -0
- package/api/doc/picoflow.signal.md +1 -1
- package/api/doc/picoflow.state.md +3 -3
- package/api/doc/picoflow.stream.md +2 -18
- package/api/doc/picoflow.streamasync.md +55 -0
- package/api/picoflow.public.api.md +192 -0
- package/api-extractor.json +2 -1
- package/dist/picoflow.js +513 -305
- package/dist/types/advanced/array.d.ts +116 -0
- package/dist/types/advanced/array.d.ts.map +1 -0
- package/dist/types/advanced/index.d.ts +9 -0
- package/dist/types/advanced/index.d.ts.map +1 -0
- package/dist/types/{map.d.ts → advanced/map.d.ts} +12 -12
- package/dist/types/advanced/map.d.ts.map +1 -0
- package/dist/types/advanced/resource.d.ts +39 -0
- package/dist/types/advanced/resource.d.ts.map +1 -0
- package/dist/types/{resource.d.ts → advanced/resourceAsync.d.ts} +6 -11
- package/dist/types/advanced/resourceAsync.d.ts.map +1 -0
- package/dist/types/advanced/stream.d.ts +59 -0
- package/dist/types/advanced/stream.d.ts.map +1 -0
- package/dist/types/advanced/streamAsync.d.ts +43 -0
- package/dist/types/advanced/streamAsync.d.ts.map +1 -0
- package/dist/types/basic/constant.d.ts +32 -0
- package/dist/types/basic/constant.d.ts.map +1 -0
- package/dist/types/basic/derivation.d.ts +40 -0
- package/dist/types/basic/derivation.d.ts.map +1 -0
- package/dist/types/basic/disposable.d.ts +23 -0
- package/dist/types/basic/disposable.d.ts.map +1 -0
- package/dist/types/basic/effect.d.ts +56 -0
- package/dist/types/basic/effect.d.ts.map +1 -0
- package/dist/types/basic/index.d.ts +11 -0
- package/dist/types/basic/index.d.ts.map +1 -0
- package/dist/types/basic/observable.d.ts +34 -0
- package/dist/types/basic/observable.d.ts.map +1 -0
- package/dist/types/basic/signal.d.ts +40 -0
- package/dist/types/basic/signal.d.ts.map +1 -0
- package/dist/types/basic/state.d.ts +26 -0
- package/dist/types/basic/state.d.ts.map +1 -0
- package/dist/types/creators.d.ts +38 -13
- package/dist/types/creators.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -9
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/advanced/array.ts +224 -0
- package/src/advanced/index.ts +12 -0
- package/src/{map.ts → advanced/map.ts} +14 -14
- package/src/advanced/resource.ts +56 -0
- package/src/{resource.ts → advanced/resourceAsync.ts} +9 -16
- package/src/advanced/stream.ts +87 -0
- package/src/advanced/streamAsync.ts +82 -0
- package/src/basic/constant.ts +64 -0
- package/src/basic/derivation.ts +86 -0
- package/src/basic/disposable.ts +27 -0
- package/src/basic/effect.ts +96 -0
- package/src/basic/index.ts +10 -0
- package/src/basic/observable.ts +51 -0
- package/src/basic/signal.ts +117 -0
- package/src/basic/state.ts +39 -0
- package/src/creators.ts +66 -15
- package/src/index.ts +26 -11
- package/test/array.test.ts +620 -0
- package/test/constant.test.ts +46 -0
- package/test/derivation.test.ts +30 -6
- package/test/effect.test.ts +29 -0
- package/test/map.test.ts +38 -0
- package/test/resource.test.ts +18 -16
- package/test/resourceAsync.test.ts +108 -0
- package/test/signal.test.ts +18 -1
- package/test/state.test.ts +107 -2
- package/test/stream.test.ts +38 -13
- package/test/streamAsync.test.ts +194 -0
- package/tsconfig.json +3 -1
- package/api/doc/picoflow.flowdisposer.md +0 -13
- package/api/doc/picoflow.flowsetter.md +0 -13
- package/api/doc/picoflow.flowstate._constructor_.md +0 -49
- package/api/doc/picoflow.flowstate.get.md +0 -23
- package/api/doc/picoflow.flowupdater.md +0 -19
- package/api/picoflow.api.md +0 -145
- package/dist/types/derivation.d.ts +0 -58
- package/dist/types/derivation.d.ts.map +0 -1
- package/dist/types/effect.d.ts +0 -108
- package/dist/types/effect.d.ts.map +0 -1
- package/dist/types/map.d.ts.map +0 -1
- package/dist/types/observable.d.ts +0 -40
- package/dist/types/observable.d.ts.map +0 -1
- package/dist/types/resource.d.ts.map +0 -1
- package/dist/types/signal.d.ts +0 -111
- package/dist/types/signal.d.ts.map +0 -1
- package/dist/types/state.d.ts +0 -39
- package/dist/types/state.d.ts.map +0 -1
- package/dist/types/stream.d.ts +0 -71
- package/dist/types/stream.d.ts.map +0 -1
- package/src/derivation.ts +0 -96
- package/src/effect.ts +0 -152
- package/src/observable.ts +0 -50
- package/src/signal.ts +0 -166
- package/src/state.ts +0 -52
- package/src/stream.ts +0 -99
package/src/creators.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FlowMap,
|
|
3
|
+
FlowResource,
|
|
4
|
+
FlowResourceAsync,
|
|
5
|
+
FlowStream,
|
|
6
|
+
FlowStreamAsync,
|
|
7
|
+
} from "./advanced/";
|
|
8
|
+
import { FlowArray } from "./advanced/array";
|
|
9
|
+
import {
|
|
10
|
+
FlowConstant,
|
|
11
|
+
FlowDerivation,
|
|
12
|
+
FlowEffect,
|
|
13
|
+
FlowSignal,
|
|
14
|
+
FlowState,
|
|
15
|
+
} from "./basic/";
|
|
16
|
+
import type { FlowGetter, FlowWatcher } from "./basic/";
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
19
|
* Creates a new reactive signal.
|
|
@@ -16,6 +24,16 @@ export function signal(): FlowSignal {
|
|
|
16
24
|
return new FlowSignal();
|
|
17
25
|
}
|
|
18
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new reactive constant.
|
|
29
|
+
* @param value - The value or a function that returns the value.
|
|
30
|
+
* @returns A new instance of {@link FlowConstant}.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export function constant<T>(value: T | (() => T)): FlowConstant<T> {
|
|
34
|
+
return new FlowConstant<T>(value);
|
|
35
|
+
}
|
|
36
|
+
|
|
19
37
|
/**
|
|
20
38
|
* Creates a new reactive state holding a value.
|
|
21
39
|
* @typeparam T - The type of the state value.
|
|
@@ -23,7 +41,7 @@ export function signal(): FlowSignal {
|
|
|
23
41
|
* @returns A new instance of {@link FlowState}.
|
|
24
42
|
* @public
|
|
25
43
|
*/
|
|
26
|
-
export function state<T>(value: T): FlowState<T> {
|
|
44
|
+
export function state<T>(value: T | (() => T)): FlowState<T> {
|
|
27
45
|
return new FlowState(value);
|
|
28
46
|
}
|
|
29
47
|
|
|
@@ -31,12 +49,22 @@ export function state<T>(value: T): FlowState<T> {
|
|
|
31
49
|
* Creates a new reactive resource that asynchronously fetches its value.
|
|
32
50
|
* @typeparam T - The type of the resource value.
|
|
33
51
|
* @param fn - An asynchronous function that fetches the resource value.
|
|
34
|
-
* @param initial - The initial value of the resource.
|
|
35
52
|
* @returns A new instance of {@link FlowResource}.
|
|
36
53
|
* @public
|
|
37
54
|
*/
|
|
38
|
-
export function resource<T>(fn: () => Promise<T
|
|
39
|
-
return new FlowResource(fn
|
|
55
|
+
export function resource<T>(fn: () => Promise<T>): FlowResource<T> {
|
|
56
|
+
return new FlowResource(fn);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new reactive asynchronous resource that fetches its value.
|
|
61
|
+
* @typeparam T - The type of the resource value.
|
|
62
|
+
* @param fn - An asynchronous function that fetches the resource value.
|
|
63
|
+
* @returns A new instance of {@link FlowResourceAsync}.
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
export function resourceAsync<T>(fn: () => Promise<T>): FlowResourceAsync<T> {
|
|
67
|
+
return new FlowResourceAsync(fn);
|
|
40
68
|
}
|
|
41
69
|
|
|
42
70
|
/**
|
|
@@ -44,15 +72,27 @@ export function resource<T>(fn: () => Promise<T>, initial: T): FlowResource<T> {
|
|
|
44
72
|
* @typeparam T - The type of the stream value.
|
|
45
73
|
* @param updater - A function that receives a setter to update the stream's value.
|
|
46
74
|
* It should return a disposer function to clean up resources.
|
|
47
|
-
* @param initial - The initial value of the stream.
|
|
48
75
|
* @returns A new instance of {@link FlowStream}.
|
|
49
76
|
* @public
|
|
50
77
|
*/
|
|
51
78
|
export function stream<T>(
|
|
52
79
|
updater: (set: (value: T) => void) => () => void,
|
|
53
|
-
initial: T,
|
|
54
80
|
): FlowStream<T> {
|
|
55
|
-
return new FlowStream(updater
|
|
81
|
+
return new FlowStream(updater);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Creates a new reactive asynchronous stream.
|
|
86
|
+
* @typeparam T - The type of the stream value.
|
|
87
|
+
* @param updater - A function that receives a setter to update the stream's value.
|
|
88
|
+
* It should return a disposer function to clean up resources.
|
|
89
|
+
* @returns A new instance of {@link FlowStreamAsync}.
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
export function streamAsync<T>(
|
|
93
|
+
updater: (set: (value: T) => void) => () => void,
|
|
94
|
+
): FlowStreamAsync<T> {
|
|
95
|
+
return new FlowStreamAsync(updater);
|
|
56
96
|
}
|
|
57
97
|
|
|
58
98
|
/**
|
|
@@ -99,3 +139,14 @@ export function map<K extends string | number | symbol, V>(
|
|
|
99
139
|
new Map<K, V>(initial ? (Object.entries(initial) as [K, V][]) : []),
|
|
100
140
|
);
|
|
101
141
|
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Creates a new reactive array.
|
|
145
|
+
* @typeparam T - The type of the array elements.
|
|
146
|
+
* @param initial - An optional array of initial values.
|
|
147
|
+
* @returns A new instance of {@link FlowArray}.
|
|
148
|
+
* @public
|
|
149
|
+
*/
|
|
150
|
+
export function array<T>(initial?: T[]): FlowArray<T> {
|
|
151
|
+
return new FlowArray<T>(initial);
|
|
152
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -9,22 +9,37 @@
|
|
|
9
9
|
export {
|
|
10
10
|
signal,
|
|
11
11
|
state,
|
|
12
|
+
constant,
|
|
12
13
|
resource,
|
|
13
14
|
stream,
|
|
14
15
|
derivation,
|
|
15
16
|
effect,
|
|
16
17
|
map,
|
|
18
|
+
array,
|
|
19
|
+
streamAsync,
|
|
20
|
+
resourceAsync,
|
|
17
21
|
} from "./creators";
|
|
18
|
-
export
|
|
19
|
-
export type { FlowEffect } from "./effect";
|
|
20
|
-
export type { FlowGetter, FlowObservable } from "./observable";
|
|
21
|
-
export type { FlowResource } from "./resource";
|
|
22
|
-
export type { FlowSignal, FlowWatcher } from "./signal";
|
|
23
|
-
export type { FlowState } from "./state";
|
|
24
|
-
export type { FlowMap } from "./map";
|
|
22
|
+
export { isDisposable } from "./basic";
|
|
25
23
|
export type {
|
|
24
|
+
FlowDerivation,
|
|
25
|
+
FlowEffect,
|
|
26
|
+
FlowGetter,
|
|
27
|
+
FlowObservable,
|
|
28
|
+
FlowSignal,
|
|
29
|
+
FlowWatcher,
|
|
30
|
+
FlowState,
|
|
31
|
+
FlowConstant,
|
|
32
|
+
FlowDisposable,
|
|
33
|
+
} from "./basic/";
|
|
34
|
+
export type {
|
|
35
|
+
FlowResource,
|
|
36
|
+
FlowMap,
|
|
37
|
+
FlowResourceAsync,
|
|
38
|
+
FlowStreamAsync,
|
|
26
39
|
FlowStream,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
FlowStreamDisposer,
|
|
41
|
+
FlowStreamSetter,
|
|
42
|
+
FlowStreamUpdater,
|
|
43
|
+
FlowArray,
|
|
44
|
+
FlowArrayAction,
|
|
45
|
+
} from "./advanced/";
|