synstate 3.0.5 → 3.1.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 +1 -1
- package/dist/core/base/create-observable-base.d.mts +53 -8
- package/dist/core/base/create-observable-base.d.mts.map +1 -1
- package/dist/core/base/create-observable-base.mjs +48 -17
- package/dist/core/base/create-observable-base.mjs.map +1 -1
- package/dist/core/base/create-root-observable.d.mts +1 -1
- package/dist/core/base/create-root-observable.d.mts.map +1 -1
- package/dist/core/combine/combine.d.mts +2 -2
- package/dist/core/combine/combine.d.mts.map +1 -1
- package/dist/core/combine/merge.d.mts +2 -2
- package/dist/core/combine/merge.d.mts.map +1 -1
- package/dist/core/combine/zip.d.mts +2 -2
- package/dist/core/combine/zip.d.mts.map +1 -1
- package/dist/core/create/counter.d.mts +1 -1
- package/dist/core/create/counter.d.mts.map +1 -1
- package/dist/core/create/from-abortable-promise.d.mts +1 -1
- package/dist/core/create/from-abortable-promise.d.mts.map +1 -1
- package/dist/core/create/from-promise.d.mts +1 -1
- package/dist/core/create/from-promise.d.mts.map +1 -1
- package/dist/core/create/from-subscribable.d.mts +1 -1
- package/dist/core/create/from-subscribable.d.mts.map +1 -1
- package/dist/core/create/just.d.mts +1 -1
- package/dist/core/create/just.d.mts.map +1 -1
- package/dist/core/create/source.d.mts +1 -1
- package/dist/core/create/source.d.mts.map +1 -1
- package/dist/core/create/timer.d.mts +1 -1
- package/dist/core/create/timer.d.mts.map +1 -1
- package/dist/core/operators/audit.d.mts +1 -1
- package/dist/core/operators/audit.d.mts.map +1 -1
- package/dist/core/operators/debounce.d.mts +1 -1
- package/dist/core/operators/debounce.d.mts.map +1 -1
- package/dist/core/operators/filter.d.mts +1 -1
- package/dist/core/operators/filter.d.mts.map +1 -1
- package/dist/core/operators/map.d.mts +1 -1
- package/dist/core/operators/map.d.mts.map +1 -1
- package/dist/core/operators/merge-map.d.mts +1 -1
- package/dist/core/operators/merge-map.d.mts.map +1 -1
- package/dist/core/operators/pairwise.d.mts +2 -2
- package/dist/core/operators/pairwise.d.mts.map +1 -1
- package/dist/core/operators/scan.d.mts +1 -1
- package/dist/core/operators/scan.d.mts.map +1 -1
- package/dist/core/operators/skip-if-no-change.d.mts +1 -1
- package/dist/core/operators/skip-if-no-change.d.mts.map +1 -1
- package/dist/core/operators/skip-until.d.mts +1 -1
- package/dist/core/operators/skip-until.d.mts.map +1 -1
- package/dist/core/operators/skip-while.d.mts +1 -1
- package/dist/core/operators/skip-while.d.mts.map +1 -1
- package/dist/core/operators/switch-map.d.mts +1 -1
- package/dist/core/operators/switch-map.d.mts.map +1 -1
- package/dist/core/operators/take-until.d.mts +1 -1
- package/dist/core/operators/take-until.d.mts.map +1 -1
- package/dist/core/operators/take-while.d.mts +1 -1
- package/dist/core/operators/take-while.d.mts.map +1 -1
- package/dist/core/operators/throttle.d.mts +1 -1
- package/dist/core/operators/throttle.d.mts.map +1 -1
- package/dist/core/operators/with-buffered-from.d.mts +1 -1
- package/dist/core/operators/with-buffered-from.d.mts.map +1 -1
- package/dist/core/operators/with-current-value-from.d.mts +1 -1
- package/dist/core/operators/with-current-value-from.d.mts.map +1 -1
- package/dist/core/operators/with-initial-value.d.mts +1 -1
- package/dist/core/operators/with-initial-value.d.mts.map +1 -1
- package/dist/core/predefined/operators/attach-index.d.mts +2 -2
- package/dist/core/predefined/operators/attach-index.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-optional.d.mts +1 -1
- package/dist/core/predefined/operators/map-optional.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-result-err.d.mts +1 -1
- package/dist/core/predefined/operators/map-result-err.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-result-ok.d.mts +1 -1
- package/dist/core/predefined/operators/map-result-ok.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-to.d.mts +1 -1
- package/dist/core/predefined/operators/map-to.d.mts.map +1 -1
- package/dist/core/predefined/operators/pluck.d.mts +1 -1
- package/dist/core/predefined/operators/pluck.d.mts.map +1 -1
- package/dist/core/predefined/operators/skip.d.mts +2 -2
- package/dist/core/predefined/operators/skip.d.mts.map +1 -1
- package/dist/core/predefined/operators/take.d.mts +2 -2
- package/dist/core/predefined/operators/take.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-optional.d.mts +1 -1
- package/dist/core/predefined/operators/unwrap-optional.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-result-err.d.mts +1 -1
- package/dist/core/predefined/operators/unwrap-result-err.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-result-ok.d.mts +1 -1
- package/dist/core/predefined/operators/unwrap-result-ok.d.mts.map +1 -1
- package/dist/core/types/id.d.mts +1 -1
- package/dist/core/types/id.d.mts.map +1 -1
- package/dist/core/types/observable-family.d.mts +3 -3
- package/dist/core/types/observable-family.d.mts.map +1 -1
- package/dist/core/types/observable-kind.d.mts +1 -1
- package/dist/core/types/observable-kind.d.mts.map +1 -1
- package/dist/core/types/observable.d.mts +4 -4
- package/dist/core/types/observable.d.mts.map +1 -1
- package/dist/core/types/types.d.mts +1 -1
- package/dist/core/types/types.d.mts.map +1 -1
- package/dist/core/utils/id-maker.d.mts +1 -1
- package/dist/core/utils/id-maker.d.mts.map +1 -1
- package/dist/core/utils/max-depth.d.mts +1 -1
- package/dist/core/utils/max-depth.d.mts.map +1 -1
- package/dist/core/utils/observable-utils.d.mts +1 -1
- package/dist/core/utils/observable-utils.d.mts.map +1 -1
- package/dist/core/utils/utils.d.mts +1 -1
- package/dist/core/utils/utils.d.mts.map +1 -1
- package/dist/utils/collect-to-array.d.mts +1 -1
- package/dist/utils/collect-to-array.d.mts.map +1 -1
- package/dist/utils/create-boolean-state.d.mts +17 -14
- package/dist/utils/create-boolean-state.d.mts.map +1 -1
- package/dist/utils/create-boolean-state.mjs +4 -2
- package/dist/utils/create-boolean-state.mjs.map +1 -1
- package/dist/utils/create-reducer.d.mts +49 -2
- package/dist/utils/create-reducer.d.mts.map +1 -1
- package/dist/utils/create-reducer.mjs +31 -2
- package/dist/utils/create-reducer.mjs.map +1 -1
- package/dist/utils/create-state.d.mts +37 -2
- package/dist/utils/create-state.d.mts.map +1 -1
- package/dist/utils/create-state.mjs +36 -2
- package/dist/utils/create-state.mjs.map +1 -1
- package/package.json +11 -11
- package/src/core/base/create-child-observable.mts +1 -1
- package/src/core/base/create-observable-base.mts +131 -44
- package/src/core/base/create-root-observable.mts +1 -1
- package/src/core/base/observable-base.test.mts +7 -7
- package/src/core/combine/combine.mts +10 -10
- package/src/core/combine/merge.mts +8 -8
- package/src/core/combine/zip.mts +11 -11
- package/src/core/create/counter.mts +1 -1
- package/src/core/create/from-abortable-promise.mts +1 -1
- package/src/core/create/from-promise.mts +1 -1
- package/src/core/create/from-subscribable.mts +3 -3
- package/src/core/create/just.mts +1 -1
- package/src/core/create/source.mts +3 -3
- package/src/core/create/timer.mts +1 -1
- package/src/core/operators/audit.mts +5 -5
- package/src/core/operators/debounce.mts +5 -5
- package/src/core/operators/filter.mts +5 -5
- package/src/core/operators/map.mts +5 -5
- package/src/core/operators/merge-map.mts +5 -5
- package/src/core/operators/pairwise.mts +5 -5
- package/src/core/operators/scan.mts +4 -4
- package/src/core/operators/skip-if-no-change.mts +4 -4
- package/src/core/operators/skip-until.mts +4 -4
- package/src/core/operators/skip-while.mts +4 -4
- package/src/core/operators/switch-map.mts +5 -5
- package/src/core/operators/take-until.mts +4 -4
- package/src/core/operators/take-while.mts +5 -5
- package/src/core/operators/throttle.mts +5 -5
- package/src/core/operators/with-buffered-from.mts +4 -4
- package/src/core/operators/with-current-value-from.mts +4 -4
- package/src/core/operators/with-initial-value.mts +5 -5
- package/src/core/predefined/operators/attach-index.mts +2 -2
- package/src/core/predefined/operators/map-optional.mts +1 -1
- package/src/core/predefined/operators/map-result-err.mts +1 -1
- package/src/core/predefined/operators/map-result-ok.mts +1 -1
- package/src/core/predefined/operators/map-to.mts +1 -1
- package/src/core/predefined/operators/pluck.mts +1 -1
- package/src/core/predefined/operators/skip.mts +2 -2
- package/src/core/predefined/operators/take.mts +2 -2
- package/src/core/predefined/operators/unwrap-optional.mts +2 -2
- package/src/core/predefined/operators/unwrap-result-err.mts +2 -2
- package/src/core/predefined/operators/unwrap-result-ok.mts +2 -2
- package/src/core/types/id.mts +1 -1
- package/src/core/types/observable-family.mts +15 -15
- package/src/core/types/observable-kind.mts +1 -1
- package/src/core/types/observable.mts +4 -4
- package/src/core/types/types.mts +1 -1
- package/src/core/utils/id-maker.mts +4 -4
- package/src/core/utils/max-depth.mts +1 -1
- package/src/core/utils/observable-utils.mts +1 -1
- package/src/core/utils/utils.mts +1 -1
- package/src/utils/collect-to-array.mts +1 -1
- package/src/utils/create-boolean-state.mts +18 -14
- package/src/utils/create-boolean-state.test.mts +23 -0
- package/src/utils/create-reducer.mts +59 -2
- package/src/utils/create-reducer.test.mts +87 -0
- package/src/utils/create-state.mts +38 -2
- package/src/utils/create-state.test.mts +72 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Optional, Result } from 'ts-data-forge';
|
|
2
2
|
import { createRootObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type {
|
|
4
|
+
FromSubscribableObservable,
|
|
5
|
+
Subscribable,
|
|
6
6
|
} from '../types/index.mjs';
|
|
7
7
|
|
|
8
8
|
/**
|
package/src/core/create/just.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createRootObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { InitializedRootObservable } from '../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Creates an Observable that holds a single static value and immediately
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Arr, Optional } from 'ts-data-forge';
|
|
2
2
|
import { createRootObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type {
|
|
4
|
+
InitializedSourceObservable,
|
|
5
|
+
SourceObservable,
|
|
6
6
|
} from '../types/index.mjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createRootObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { TimerId, TimerObservable } from '../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Creates an observable that emits 0 after a specified delay and then completes.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createAsyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type {
|
|
4
|
+
AuditOperatorObservable,
|
|
5
|
+
KeepInitialValueOperator,
|
|
6
|
+
Observable,
|
|
7
|
+
TimerId,
|
|
8
8
|
} from '../types/index.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createAsyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DebounceOperatorObservable,
|
|
5
|
+
KeepInitialValueOperator,
|
|
6
|
+
Observable,
|
|
7
|
+
TimerId,
|
|
8
8
|
} from '../types/index.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
} from 'ts-data-forge';
|
|
8
8
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
9
9
|
import { source } from '../create/index.mjs';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
import type {
|
|
11
|
+
DropInitialValueOperator,
|
|
12
|
+
FilterOperatorObservable,
|
|
13
|
+
InitializedObservable,
|
|
14
|
+
Observable,
|
|
15
15
|
} from '../types/index.mjs';
|
|
16
16
|
import { withInitialValue } from './with-initial-value.mjs';
|
|
17
17
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Optional, SafeUint, asSafeUint, expectType } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
3
|
import { source } from '../create/index.mjs';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import type {
|
|
5
|
+
InitializedObservable,
|
|
6
|
+
KeepInitialValueOperator,
|
|
7
|
+
MapOperatorObservable,
|
|
8
|
+
Observable,
|
|
9
9
|
} from '../types/index.mjs';
|
|
10
10
|
import { withInitialValue } from './with-initial-value.mjs';
|
|
11
11
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Arr, Optional } from 'ts-data-forge';
|
|
2
2
|
import { createAsyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DropInitialValueOperator,
|
|
5
|
+
MergeMapOperatorObservable,
|
|
6
|
+
Observable,
|
|
7
|
+
Subscription,
|
|
8
8
|
} from '../types/index.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { FixedLengthTuple } from 'ts-type-forge';
|
|
3
3
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import type {
|
|
5
|
+
DropInitialValueOperator,
|
|
6
|
+
Observable,
|
|
7
|
+
PairwiseOperatorObservable,
|
|
8
8
|
} from '../types/index.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createInitializedSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
Observable,
|
|
5
|
+
ScanOperatorObservable,
|
|
6
|
+
WithInitialValueOperator,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
KeepInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
SkipIfNoChangeOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DropInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
SkipUntilOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional, SafeUint, asSafeUint, pipe } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DropInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
SkipWhileOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createAsyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DropInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
Subscription,
|
|
7
|
+
SwitchMapOperatorObservable,
|
|
8
8
|
} from '../types/index.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
KeepInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
TakeUntilOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
} from 'ts-data-forge';
|
|
8
8
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
9
9
|
import { source } from '../create/index.mjs';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
import type {
|
|
11
|
+
DropInitialValueOperator,
|
|
12
|
+
InitializedObservable,
|
|
13
|
+
Observable,
|
|
14
|
+
TakeWhileOperatorObservable,
|
|
15
15
|
} from '../types/index.mjs';
|
|
16
16
|
import { withInitialValue } from './with-initial-value.mjs';
|
|
17
17
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type {
|
|
4
|
+
KeepInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
ThrottleOperatorObservable,
|
|
7
|
+
TimerId,
|
|
8
8
|
} from '../types/index.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Arr, Optional, pipe } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
KeepInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
WithBufferedFromOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
import { maxDepth } from '../utils/index.mjs';
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional, pipe } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DropInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
WithCurrentValueFromOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
import { maxDepth } from '../utils/index.mjs';
|
|
9
9
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { expectType, Optional } from 'ts-data-forge';
|
|
2
2
|
import { createInitializedSyncChildObservable } from '../base/index.mjs';
|
|
3
3
|
import { source } from '../create/index.mjs';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import type {
|
|
5
|
+
InitializedObservable,
|
|
6
|
+
Observable,
|
|
7
|
+
WithInitialValueOperator,
|
|
8
|
+
WithInitialValueOperatorObservable,
|
|
9
9
|
} from '../types/index.mjs';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SafeUint } from 'ts-type-forge';
|
|
2
2
|
import { map } from '../../operators/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Attaches a sequential index to each emitted value, producing `[index, value]` tuples.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Optional, type UnknownOptional } from 'ts-data-forge';
|
|
2
2
|
import { map } from '../../operators/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Transforms the inner value of an `Optional` type emitted by the source.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result, type UnknownResult } from 'ts-data-forge';
|
|
2
2
|
import { map } from '../../operators/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Transforms the error value (`Err`) of a `Result` type emitted by the source.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result, type UnknownResult } from 'ts-data-forge';
|
|
2
2
|
import { map } from '../../operators/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Transforms the success value (`Ok`) of a `Result` type emitted by the source.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { map } from '../../operators/index.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Maps all emitted values to a constant value, ignoring the source values.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PositiveSafeInt } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { PositiveSafeIntWithSmallInt } from 'ts-type-forge';
|
|
3
3
|
import { skipWhile } from '../../operators/index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import type { DropInitialValueOperator } from '../../types/index.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Skips the first `n` emissions from the source observable.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PositiveSafeIntWithSmallInt } from 'ts-type-forge';
|
|
2
2
|
import { takeWhile } from '../../operators/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { DropInitialValueOperator } from '../../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Takes only the first `n` emissions from the source observable, then completes.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Optional, type UnknownOptional } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { Fn } from 'ts-type-forge';
|
|
3
3
|
import { map } from '../../operators/index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Unwraps `Optional` values, converting `Some(value)` to `value` and `None` to `undefined`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result, type UnknownResult } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { Fn } from 'ts-type-forge';
|
|
3
3
|
import { map } from '../../operators/index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Unwraps the error value from a `Result`, converting `Err(error)` to `error` and `Ok` to `undefined`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result, type UnknownResult } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { Fn } from 'ts-type-forge';
|
|
3
3
|
import { map } from '../../operators/index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Unwraps the success value from a `Result`, converting `Ok(value)` to `value` and `Err` to `undefined`.
|
package/src/core/types/id.mts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { expectType, type Result } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import type {
|
|
3
|
+
ArrayElement,
|
|
4
|
+
FixedLengthTuple,
|
|
5
|
+
NonEmptyTuple,
|
|
6
|
+
SafeUint,
|
|
7
7
|
} from 'ts-type-forge';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
import type {
|
|
9
|
+
AsyncChildObservable,
|
|
10
|
+
InitializedObservable,
|
|
11
|
+
InitializedRootObservable,
|
|
12
|
+
InitializedSyncChildObservable,
|
|
13
|
+
Observable,
|
|
14
|
+
RootObservable,
|
|
15
|
+
SyncChildObservable,
|
|
16
|
+
Unwrap,
|
|
17
17
|
} from './observable.mjs';
|
|
18
|
-
import {
|
|
18
|
+
import type { NonEmptyUnknownList } from './types.mjs';
|
|
19
19
|
|
|
20
20
|
// RootObservable
|
|
21
21
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { expectType, type Optional, type Some } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import type { FixedLengthTuple, StrictOmit } from 'ts-type-forge';
|
|
3
|
+
import type { ObservableId, UpdateToken } from './id.mjs';
|
|
4
|
+
import type { ObservableKind } from './observable-kind.mjs';
|
|
5
|
+
import type { NonEmptyUnknownList, Subscription } from './types.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Inheritance
|
package/src/core/types/types.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expectType, type Queue } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { NonEmptyTuple } from 'ts-type-forge';
|
|
3
3
|
|
|
4
4
|
export type TupleToQueueTuple<T extends readonly unknown[]> = Readonly<{
|
|
5
5
|
[P in keyof T]: Queue<T[P]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Arr, Optional, pipe } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { Observable } from '../types/index.mjs';
|
|
3
3
|
|
|
4
4
|
export const maxDepth = (parents: readonly Observable<unknown>[]): number =>
|
|
5
5
|
pipe(Arr.maxBy(parents, (p) => p.depth))
|
package/src/core/utils/utils.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { InitializedObservable } from '../core/index.mjs';
|
|
2
|
+
import type { StateOptions } from './create-reducer.mjs';
|
|
2
3
|
import { createState } from './create-state.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -6,6 +7,8 @@ import { createState } from './create-state.mjs';
|
|
|
6
7
|
* Extends `createState` with boolean-specific helpers like `toggle`, `setTrue`, and `setFalse`.
|
|
7
8
|
*
|
|
8
9
|
* @param initialState - The initial boolean value
|
|
10
|
+
* @param options - {@link StateOptions}: `equals`, to pass on only the
|
|
11
|
+
* updates that change the state
|
|
9
12
|
* @returns A 2-element tuple: `[state, { setTrue, setFalse, toggle, setState, updateState, resetState, getSnapshot, initialState }]`
|
|
10
13
|
*
|
|
11
14
|
* @example
|
|
@@ -14,24 +17,25 @@ import { createState } from './create-state.mjs';
|
|
|
14
17
|
* import { createBooleanState } from 'synstate';
|
|
15
18
|
* import { useObservableValue } from 'synstate-react-hooks';
|
|
16
19
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* // Menu drawer open/close state.
|
|
21
|
+
* // setTrue and setFalse can be passed directly as callbacks
|
|
22
|
+
* // — no need to create wrapper functions like `() => setState(true)`.
|
|
23
|
+
* const [menuOpen$, { setTrue: openMenu, setFalse: closeMenu }] =
|
|
24
|
+
* createBooleanState(false);
|
|
22
25
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
26
|
+
* const SampleComponent = (): React.JSX.Element => (
|
|
27
|
+
* <MenuDrawer
|
|
28
|
+
* open={useObservableValue(menuOpen$)}
|
|
29
|
+
* onClose={closeMenu}
|
|
30
|
+
* onOpen={openMenu}
|
|
31
|
+
* />
|
|
32
|
+
* );
|
|
30
33
|
* ```
|
|
31
34
|
*/
|
|
32
35
|
|
|
33
36
|
export const createBooleanState = (
|
|
34
37
|
initialState: boolean,
|
|
38
|
+
options?: StateOptions<boolean>,
|
|
35
39
|
): readonly [
|
|
36
40
|
state: InitializedObservable<boolean>,
|
|
37
41
|
utils: Readonly<{
|
|
@@ -46,7 +50,7 @@ export const createBooleanState = (
|
|
|
46
50
|
}>,
|
|
47
51
|
] => {
|
|
48
52
|
const [state, setState, { updateState, resetState, getSnapshot }] =
|
|
49
|
-
createState(initialState);
|
|
53
|
+
createState(initialState, options);
|
|
50
54
|
|
|
51
55
|
return [
|
|
52
56
|
state,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createBooleanState } from './create-boolean-state.mjs';
|
|
2
|
+
|
|
3
|
+
describe(createBooleanState, () => {
|
|
4
|
+
test('with `equals`, setting what it already holds passes nothing on', () => {
|
|
5
|
+
const [state, { setTrue, setFalse }] = createBooleanState(false, {
|
|
6
|
+
equals: Object.is,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const mut_seen: boolean[] = [];
|
|
10
|
+
|
|
11
|
+
state.subscribe((value) => {
|
|
12
|
+
mut_seen.push(value);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
setFalse();
|
|
16
|
+
|
|
17
|
+
setTrue();
|
|
18
|
+
|
|
19
|
+
setTrue();
|
|
20
|
+
|
|
21
|
+
assert.deepStrictEqual(mut_seen, [false, true]);
|
|
22
|
+
});
|
|
23
|
+
});
|