@ersbeth/picoflow 0.1.0 → 0.2.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.
Files changed (48) hide show
  1. package/api/doc/picoflow.array.md +55 -0
  2. package/api/doc/picoflow.flowarray._constructor_.md +49 -0
  3. package/api/doc/picoflow.flowarray._lastaction.md +13 -0
  4. package/api/doc/picoflow.flowarray.clear.md +17 -0
  5. package/api/doc/picoflow.flowarray.dispose.md +55 -0
  6. package/api/doc/picoflow.flowarray.get.md +19 -0
  7. package/api/doc/picoflow.flowarray.length.md +13 -0
  8. package/api/doc/picoflow.flowarray.md +273 -0
  9. package/api/doc/picoflow.flowarray.pop.md +17 -0
  10. package/api/doc/picoflow.flowarray.push.md +53 -0
  11. package/api/doc/picoflow.flowarray.set.md +53 -0
  12. package/api/doc/picoflow.flowarray.setitem.md +69 -0
  13. package/api/doc/picoflow.flowarray.shift.md +17 -0
  14. package/api/doc/picoflow.flowarray.splice.md +85 -0
  15. package/api/doc/picoflow.flowarray.unshift.md +53 -0
  16. package/api/doc/picoflow.flowarrayaction.md +37 -0
  17. package/api/doc/picoflow.flowdisposable.dispose.md +55 -0
  18. package/api/doc/picoflow.flowdisposable.md +43 -0
  19. package/api/doc/picoflow.flowsignal.dispose.md +39 -1
  20. package/api/doc/picoflow.flowsignal.md +3 -2
  21. package/api/doc/picoflow.isdisposable.md +55 -0
  22. package/api/doc/picoflow.md +70 -0
  23. package/api/picoflow.public.api.md +63 -2
  24. package/dist/picoflow.js +188 -4
  25. package/dist/types/advanced/array.d.ts +116 -0
  26. package/dist/types/advanced/array.d.ts.map +1 -0
  27. package/dist/types/advanced/index.d.ts +2 -0
  28. package/dist/types/advanced/index.d.ts.map +1 -1
  29. package/dist/types/basic/disposable.d.ts +23 -0
  30. package/dist/types/basic/disposable.d.ts.map +1 -0
  31. package/dist/types/basic/index.d.ts +2 -0
  32. package/dist/types/basic/index.d.ts.map +1 -1
  33. package/dist/types/basic/signal.d.ts +5 -2
  34. package/dist/types/basic/signal.d.ts.map +1 -1
  35. package/dist/types/creators.d.ts +9 -0
  36. package/dist/types/creators.d.ts.map +1 -1
  37. package/dist/types/index.d.ts +6 -3
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/src/advanced/array.ts +224 -0
  41. package/src/advanced/index.ts +2 -0
  42. package/src/basic/disposable.ts +27 -0
  43. package/src/basic/index.ts +2 -0
  44. package/src/basic/observable.ts +2 -2
  45. package/src/basic/signal.ts +17 -5
  46. package/src/creators.ts +12 -0
  47. package/src/index.ts +13 -3
  48. package/test/array.test.ts +620 -0
package/dist/picoflow.js CHANGED
@@ -16,10 +16,21 @@ class FlowSignal {
16
16
  * @throws If the FlowSignal is already disposed.
17
17
  * @public
18
18
  */
19
- dispose() {
19
+ dispose(options) {
20
20
  if (this._disposed) throw new Error("[PicoFlow] Primitive is disposed");
21
- Array.from(this._effects).forEach((effect) => effect.dispose());
22
- Array.from(this._listeners).forEach((listener) => listener.dispose());
21
+ if (options?.self) {
22
+ Array.from(this._effects).forEach(
23
+ (effect) => effect._unregisterDependency(this)
24
+ );
25
+ Array.from(this._listeners).forEach(
26
+ (listener) => listener._unregisterDependency(this)
27
+ );
28
+ } else {
29
+ Array.from(this._effects).forEach((effect) => effect.dispose());
30
+ Array.from(this._listeners).forEach(
31
+ (listener) => listener.dispose()
32
+ );
33
+ }
23
34
  Array.from(this._dependencies).forEach((dependency) => {
24
35
  this._unregisterDependency(dependency);
25
36
  });
@@ -317,6 +328,10 @@ class FlowDerivation extends FlowObservable {
317
328
  }
318
329
  }
319
330
 
331
+ function isDisposable(obj) {
332
+ return obj !== null && obj !== void 0 && typeof obj.dispose === "function";
333
+ }
334
+
320
335
  class FlowMap extends FlowState {
321
336
  /**
322
337
  * A reactive state that holds the most recent key and value that were set.
@@ -560,6 +575,172 @@ class FlowResourceAsync extends FlowObservable {
560
575
  _fetch;
561
576
  }
562
577
 
578
+ class FlowArray extends FlowObservable {
579
+ /**
580
+ * Last action performed on the FlowArray.
581
+ * @public
582
+ */
583
+ $lastAction;
584
+ /**
585
+ * Creates an instance of FlowArray.
586
+ * @param value - Initial array value.
587
+ * @public
588
+ */
589
+ constructor(value = []) {
590
+ super();
591
+ this._value = value;
592
+ this.$lastAction = state({
593
+ type: "set",
594
+ items: value
595
+ });
596
+ }
597
+ /**
598
+ * Gets the current length of the array.
599
+ * @returns The length of the array.
600
+ * @public
601
+ */
602
+ get length() {
603
+ if (this._disposed) throw new Error("[PicoFlow] Primitive is disposed");
604
+ return this._value.length;
605
+ }
606
+ /**
607
+ * Returns a copy of the internal array.
608
+ * @returns A copy of the array.
609
+ * @public
610
+ */
611
+ get() {
612
+ if (this._disposed) throw new Error("[PicoFlow] Primitive is disposed");
613
+ return [...this._value];
614
+ }
615
+ /**
616
+ * Replaces the entire array with new items.
617
+ * @param items - The new array of items.
618
+ * @public
619
+ */
620
+ set(items) {
621
+ if (this._disposed) throw new Error("[PicoFlow] Primitive is disposed");
622
+ this._value.forEach((item) => {
623
+ if (isDisposable(item)) item.dispose({ self: true });
624
+ });
625
+ this._value = items;
626
+ this._notify();
627
+ this.$lastAction.set({ type: "set", items });
628
+ }
629
+ /**
630
+ * Replaces an item at a specific index.
631
+ * @param index - The index of the item to replace.
632
+ * @param item - The new item.
633
+ * @public
634
+ */
635
+ setItem(index, item) {
636
+ if (this._disposed) throw new Error("[PicoFlow] Primitive is disposed");
637
+ if (index < 0 || index >= this._value.length) {
638
+ throw new Error("[PicoFlow] Index out of bounds");
639
+ }
640
+ this._value[index] = item;
641
+ this._notify();
642
+ this.$lastAction.set({ type: "setItem", index, item });
643
+ }
644
+ /**
645
+ * Appends an item to the end of the array.
646
+ * @param item - The item to append.
647
+ * @public
648
+ */
649
+ push(item) {
650
+ if (this._disposed) throw new Error("[PicoFlow] Primitive is disposed");
651
+ this._value.push(item);
652
+ this._notify();
653
+ this.$lastAction.set({ type: "push", item });
654
+ }
655
+ /**
656
+ * Removes the last item from the array.
657
+ * @public
658
+ */
659
+ pop() {
660
+ if (this._disposed) throw new Error("[PicoFlow] Primitive is disposed");
661
+ const item = this._value.pop();
662
+ if (isDisposable(item)) {
663
+ item.dispose({ self: true });
664
+ }
665
+ this._notify();
666
+ this.$lastAction.set({ type: "pop" });
667
+ }
668
+ /**
669
+ * Inserts an item at the beginning of the array.
670
+ * @param item - The item to insert.
671
+ * @public
672
+ */
673
+ unshift(item) {
674
+ if (this._disposed) throw new Error("[PicoFlow] Primitive is disposed");
675
+ this._value.unshift(item);
676
+ this._notify();
677
+ this.$lastAction.set({ type: "unshift", item });
678
+ }
679
+ /**
680
+ * Removes the first item from the array.
681
+ * @public
682
+ */
683
+ shift() {
684
+ if (this._disposed) throw new Error("[PicoFlow] Primitive is disposed");
685
+ const item = this._value.shift();
686
+ if (isDisposable(item)) {
687
+ item.dispose({ self: true });
688
+ }
689
+ this._notify();
690
+ this.$lastAction.set({ type: "shift" });
691
+ }
692
+ /**
693
+ * Changes the content of the array.
694
+ * @param start - The starting index.
695
+ * @param deleteCount - Number of items to remove.
696
+ * @param newItems - New items to add.
697
+ * @public
698
+ */
699
+ splice(start, deleteCount, ...newItems) {
700
+ if (this._disposed) throw new Error("[PicoFlow] Primitive is disposed");
701
+ const items = this._value.splice(start, deleteCount, ...newItems);
702
+ items.forEach((item) => {
703
+ if (isDisposable(item)) item.dispose({ self: true });
704
+ });
705
+ this._notify();
706
+ this.$lastAction.set({
707
+ type: "splice",
708
+ start,
709
+ deleteCount,
710
+ items: newItems
711
+ });
712
+ }
713
+ /**
714
+ * Clears all items from the array.
715
+ * @public
716
+ */
717
+ clear() {
718
+ if (this._disposed) throw new Error("[PicoFlow] Primitive is disposed");
719
+ const items = [...this._value];
720
+ items.forEach((item) => {
721
+ if (isDisposable(item)) item.dispose({ self: true });
722
+ });
723
+ this._value = [];
724
+ this._notify();
725
+ this.$lastAction.set({ type: "clear" });
726
+ }
727
+ /**
728
+ * Disposes the FlowArray and its items.
729
+ * @param options - Disposal options.
730
+ * @public
731
+ */
732
+ dispose(options) {
733
+ super.dispose(options);
734
+ this._value.forEach((item) => {
735
+ if (isDisposable(item)) item.dispose(options);
736
+ });
737
+ this._value = [];
738
+ }
739
+ /* INTERNAL */
740
+ /*@internal*/
741
+ _value = [];
742
+ }
743
+
563
744
  function signal() {
564
745
  return new FlowSignal();
565
746
  }
@@ -592,5 +773,8 @@ function map(initial) {
592
773
  new Map(initial ? Object.entries(initial) : [])
593
774
  );
594
775
  }
776
+ function array(initial) {
777
+ return new FlowArray(initial);
778
+ }
595
779
 
596
- export { constant, derivation, effect, map, resource, resourceAsync, signal, state, stream, streamAsync };
780
+ export { FlowArray, FlowConstant, FlowDerivation, FlowEffect, FlowMap, FlowObservable, FlowResource, FlowResourceAsync, FlowSignal, FlowState, FlowStream, FlowStreamAsync, array, constant, derivation, effect, isDisposable, map, resource, resourceAsync, signal, state, stream, streamAsync };
@@ -0,0 +1,116 @@
1
+ import { FlowObservable, FlowState } from '../basic';
2
+ /**
3
+ * Represents the actions that can be performed on a FlowArray.
4
+ * @public
5
+ */
6
+ export type FlowArrayAction<T> = {
7
+ type: "set";
8
+ items: T[];
9
+ } | {
10
+ type: "setItem";
11
+ index: number;
12
+ item: T;
13
+ } | {
14
+ type: "push";
15
+ item: T;
16
+ } | {
17
+ type: "pop";
18
+ } | {
19
+ type: "unshift";
20
+ item: T;
21
+ } | {
22
+ type: "shift";
23
+ } | {
24
+ type: "splice";
25
+ start: number;
26
+ deleteCount: number;
27
+ items: T[];
28
+ } | {
29
+ type: "clear";
30
+ };
31
+ /**
32
+ * Represents a reactive array.
33
+ * @public
34
+ */
35
+ export declare class FlowArray<T> extends FlowObservable<T[]> {
36
+ /**
37
+ * Last action performed on the FlowArray.
38
+ * @public
39
+ */
40
+ $lastAction: FlowState<FlowArrayAction<T>>;
41
+ /**
42
+ * Creates an instance of FlowArray.
43
+ * @param value - Initial array value.
44
+ * @public
45
+ */
46
+ constructor(value?: T[]);
47
+ /**
48
+ * Gets the current length of the array.
49
+ * @returns The length of the array.
50
+ * @public
51
+ */
52
+ get length(): number;
53
+ /**
54
+ * Returns a copy of the internal array.
55
+ * @returns A copy of the array.
56
+ * @public
57
+ */
58
+ get(): T[];
59
+ /**
60
+ * Replaces the entire array with new items.
61
+ * @param items - The new array of items.
62
+ * @public
63
+ */
64
+ set(items: T[]): void;
65
+ /**
66
+ * Replaces an item at a specific index.
67
+ * @param index - The index of the item to replace.
68
+ * @param item - The new item.
69
+ * @public
70
+ */
71
+ setItem(index: number, item: T): void;
72
+ /**
73
+ * Appends an item to the end of the array.
74
+ * @param item - The item to append.
75
+ * @public
76
+ */
77
+ push(item: T): void;
78
+ /**
79
+ * Removes the last item from the array.
80
+ * @public
81
+ */
82
+ pop(): void;
83
+ /**
84
+ * Inserts an item at the beginning of the array.
85
+ * @param item - The item to insert.
86
+ * @public
87
+ */
88
+ unshift(item: T): void;
89
+ /**
90
+ * Removes the first item from the array.
91
+ * @public
92
+ */
93
+ shift(): void;
94
+ /**
95
+ * Changes the content of the array.
96
+ * @param start - The starting index.
97
+ * @param deleteCount - Number of items to remove.
98
+ * @param newItems - New items to add.
99
+ * @public
100
+ */
101
+ splice(start: number, deleteCount: number, ...newItems: T[]): void;
102
+ /**
103
+ * Clears all items from the array.
104
+ * @public
105
+ */
106
+ clear(): void;
107
+ /**
108
+ * Disposes the FlowArray and its items.
109
+ * @param options - Disposal options.
110
+ * @public
111
+ */
112
+ dispose(options?: {
113
+ self: boolean;
114
+ }): void;
115
+ }
116
+ //# sourceMappingURL=array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/advanced/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1D;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IACvB;IACI,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,CA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M,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC,EAAE,GAAG,IAAI;IAelE;;;OAGG;IACH,KAAK,IAAI,IAAI;IAWb;;;;OAIG;IACM,OAAO,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;CAWtD"}
@@ -4,4 +4,6 @@ export { FlowStreamAsync } from './streamAsync';
4
4
  export { FlowResource } from './resource';
5
5
  export { FlowResourceAsync } from './resourceAsync';
6
6
  export type { FlowStreamUpdater, FlowStreamDisposer, FlowStreamSetter, } from './stream';
7
+ export { FlowArray } from './array';
8
+ export type { FlowArrayAction } from './array';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/advanced/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EACR,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACnB,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/advanced/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EACR,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Represents an object with a disposable lifecycle.
3
+ * @remarks
4
+ * Objects implementing this interface require explicit resource disposal.
5
+ * @public
6
+ */
7
+ export interface FlowDisposable {
8
+ /**
9
+ * Disposes resources held by this object.
10
+ * @param options - Options to specify disposal behavior.
11
+ */
12
+ dispose(options?: {
13
+ self: boolean;
14
+ }): void;
15
+ }
16
+ /**
17
+ * Checks whether an object implements the FlowDisposable interface.
18
+ * @param obj - The object to test.
19
+ * @returns True if the object has a dispose method, otherwise false.
20
+ * @public
21
+ */
22
+ export declare function isDisposable(obj: unknown): obj is FlowDisposable;
23
+ //# sourceMappingURL=disposable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disposable.d.ts","sourceRoot":"","sources":["../../../src/basic/disposable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC3B;;;OAGG;IACH,OAAO,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CAC9C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc,CAMhE"}
@@ -4,6 +4,8 @@ export { FlowObservable } from './observable';
4
4
  export { FlowDerivation } from './derivation';
5
5
  export { FlowEffect } from './effect';
6
6
  export { FlowConstant } from './constant';
7
+ export { isDisposable } from './disposable';
7
8
  export type { FlowGetter } from './observable';
8
9
  export type { FlowWatcher } from './signal';
10
+ export type { FlowDisposable } from './disposable';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/basic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/basic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { FlowDisposable } from './disposable';
1
2
  /**
2
3
  * A function for watching a FlowSignal.
3
4
  * @param signal - The FlowSignal that is being observed.
@@ -11,7 +12,7 @@ export type FlowWatcher = (signal: FlowSignal) => void;
11
12
  * Signals can be triggered and disposed. Once disposed, interactions with the signal will throw errors.
12
13
  * @public
13
14
  */
14
- export declare class FlowSignal {
15
+ export declare class FlowSignal implements FlowDisposable {
15
16
  /**
16
17
  * Triggers the FlowSignal.
17
18
  * Notifies all registered listeners and schedules execution of associated effects.
@@ -26,7 +27,9 @@ export declare class FlowSignal {
26
27
  * @throws If the FlowSignal is already disposed.
27
28
  * @public
28
29
  */
29
- dispose(): void;
30
+ dispose(options?: {
31
+ self: boolean;
32
+ }): void;
30
33
  /**
31
34
  * Indicates whether the FlowSignal has been disposed.
32
35
  * @remarks Once disposed, the signal should not be used.
@@ -1 +1 @@
1
- {"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../../src/basic/signal.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;AAEvD;;;;;;GAMG;AACH,qBAAa,UAAU;IACnB;;;;;OAKG;IACI,OAAO,IAAI,IAAI;IAKtB;;;;;;OAMG;IACI,OAAO,IAAI,IAAI;IAUtB;;;;OAIG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;CAoDJ"}
1
+ {"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../../src/basic/signal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;AAEvD;;;;;;GAMG;AACH,qBAAa,UAAW,YAAW,cAAc;IAC7C;;;;;OAKG;IACI,OAAO,IAAI,IAAI;IAKtB;;;;;;OAMG;IACI,OAAO,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAqBjD;;;;OAIG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;CAoDJ"}
@@ -1,4 +1,5 @@
1
1
  import { FlowMap, FlowResource, FlowResourceAsync, FlowStream, FlowStreamAsync } from './advanced/';
2
+ import { FlowArray } from './advanced/array';
2
3
  import { FlowConstant, FlowDerivation, FlowEffect, FlowSignal, FlowState, FlowGetter, FlowWatcher } from './basic/';
3
4
  /**
4
5
  * Creates a new reactive signal.
@@ -83,4 +84,12 @@ export declare function effect(fn: (get: FlowGetter, watch: FlowWatcher) => void
83
84
  * @public
84
85
  */
85
86
  export declare function map<K extends string | number | symbol, V>(initial?: Record<K, V>): FlowMap<K, V>;
87
+ /**
88
+ * Creates a new reactive array.
89
+ * @typeparam T - The type of the array elements.
90
+ * @param initial - An optional array of initial values.
91
+ * @returns A new instance of {@link FlowArray}.
92
+ * @public
93
+ */
94
+ export declare function array<T>(initial?: T[]): FlowArray<T>;
86
95
  //# sourceMappingURL=creators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"creators.d.ts","sourceRoot":"","sources":["../../src/creators.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,eAAe,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,YAAY,EACZ,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,MAAM,IAAI,UAAU,CAEnC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,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;;;GAMG;AACH,wBAAgB,MAAM,CAClB,EAAE,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,GAClD,UAAU,CAEZ;AAED;;;;;;;;;GASG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EACrD,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACvB,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAIf;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAEpD"}
@@ -6,7 +6,10 @@
6
6
  * effects, and reactive maps.
7
7
  *
8
8
  */
9
- export { signal, state, constant, resource, stream, derivation, effect, map, streamAsync, resourceAsync, } from './creators';
10
- export type { FlowDerivation, FlowEffect, FlowGetter, FlowObservable, FlowSignal, FlowWatcher, FlowState, FlowConstant, } from './basic/';
11
- export type { FlowResource, FlowMap, FlowResourceAsync, FlowStreamAsync, FlowStream, FlowStreamDisposer, FlowStreamSetter, FlowStreamUpdater, } from './advanced/';
9
+ export { signal, state, constant, resource, stream, derivation, effect, map, array, streamAsync, resourceAsync, } from './creators';
10
+ export { isDisposable } from './basic';
11
+ export { FlowDerivation, FlowEffect, FlowObservable, FlowSignal, FlowState, FlowConstant, } from './basic/';
12
+ export type { FlowGetter, FlowWatcher, FlowDisposable, } from './basic/';
13
+ export { FlowResource, FlowMap, FlowResourceAsync, FlowStreamAsync, FlowStream, FlowArray, } from './advanced/';
14
+ export type { FlowStreamDisposer, FlowStreamSetter, FlowStreamUpdater, FlowArrayAction, } from './advanced/';
12
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACH,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,UAAU,EACV,MAAM,EACN,GAAG,EACH,WAAW,EACX,aAAa,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EACR,cAAc,EACd,UAAU,EACV,UAAU,EACV,cAAc,EACd,UAAU,EACV,WAAW,EACX,SAAS,EACT,YAAY,GACf,MAAM,UAAU,CAAC;AAClB,YAAY,EACR,YAAY,EACZ,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,GACpB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACH,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,UAAU,EACV,MAAM,EACN,GAAG,EACH,KAAK,EACL,WAAW,EACX,aAAa,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EACH,cAAc,EACd,UAAU,EACV,cAAc,EACd,UAAU,EACV,SAAS,EACT,YAAY,GACf,MAAM,UAAU,CAAC;AAElB,YAAY,EACR,UAAU,EACV,WAAW,EACX,cAAc,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EACH,YAAY,EACZ,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,SAAS,GACZ,MAAM,aAAa,CAAC;AACrB,YAAY,EACR,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAClB,MAAM,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ersbeth/picoflow",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Minimal Dataflow librairy for TypeScript",
5
5
  "type": "module",
6
6
  "exports": {