@helpers4/observable 2.0.0-alpha.2 → 2.0.0-alpha.6
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/LICENSE.md +150 -650
- package/README.md +2 -0
- package/api.json +48 -0
- package/examples.json +30 -0
- package/lib/index.d.ts +40 -4
- package/lib/index.js +67 -1402
- package/lib/index.js.map +1 -0
- package/package.json +14 -5
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ A set of helpers for working with URLs.
|
|
|
22
22
|
- [array](../array)
|
|
23
23
|
- [date](../date)
|
|
24
24
|
- [function](../function)
|
|
25
|
+
- [math](../math)
|
|
25
26
|
- [number](../number)
|
|
26
27
|
- [object](../object)
|
|
27
28
|
- [promise](../promise)
|
|
@@ -39,6 +40,7 @@ A set of helpers for working with URLs.
|
|
|
39
40
|
| array | [@helpers4/array](https://www.npmjs.com/package/@helpers4/array) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/array) | Array manipulation utilities |
|
|
40
41
|
| date | [@helpers4/date](https://www.npmjs.com/package/@helpers4/date) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/date) | date utilities |
|
|
41
42
|
| function | [@helpers4/function](https://www.npmjs.com/package/@helpers4/function) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/function) | Function utilities and type guards |
|
|
43
|
+
| math | [@helpers4/math](https://www.npmjs.com/package/@helpers4/math) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/math) | math utilities |
|
|
42
44
|
| number | [@helpers4/number](https://www.npmjs.com/package/@helpers4/number) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/number) | number utilities |
|
|
43
45
|
| object | [@helpers4/object](https://www.npmjs.com/package/@helpers4/object) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/object) | Object manipulation utilities |
|
|
44
46
|
| observable | [@helpers4/observable](https://www.npmjs.com/package/@helpers4/observable) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/observable) | Observable utilities and combinators |
|
package/api.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"category": "observable",
|
|
3
|
+
"members": [
|
|
4
|
+
{
|
|
5
|
+
"name": "combine",
|
|
6
|
+
"kind": "function",
|
|
7
|
+
"description": "Combine two observables with a map function and an optional pre-treatment.\n\nNote: you can use the pre-treatment to add a filter, a distinctUntilChanged,\nany other operator that can be used in a pipe, or even an `UntilDestroy`\noperator.",
|
|
8
|
+
"signature": "combine<T, U, R>(source1: Observable<T>, source2: Observable<U>, map: object, options: combineOptions<T, U>): Observable<R>",
|
|
9
|
+
"params": [
|
|
10
|
+
{
|
|
11
|
+
"name": "source1",
|
|
12
|
+
"type": "Observable<T>",
|
|
13
|
+
"description": "first source of data"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "source2",
|
|
17
|
+
"type": "Observable<U>",
|
|
18
|
+
"description": "second source of data"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "map",
|
|
22
|
+
"type": "object",
|
|
23
|
+
"description": "way to combine data"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "options",
|
|
27
|
+
"type": "combineOptions<T, U>",
|
|
28
|
+
"description": "options for the combineLatest operator"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"returns": "Observable<R>"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "combineLatest",
|
|
35
|
+
"kind": "function",
|
|
36
|
+
"description": "Combines multiple Observables to create an Observable whose values are\ncalculated from the latest values of each of its input Observables.\n\nThis method relies on combineLatestOperator of rxjs.\n\nThe main difference with combineLatestOperator is in case of empty parameters.\nIf the parameter is empty (empty array or empty object), the result will be\nalso empty.\n\nATTENTION: this version doesn't support `scheduler` nor `mapper` as last\nargument like in combineLatestOperator.",
|
|
37
|
+
"signature": "combineLatest<A>(sources: typeOperator): Observable<A>",
|
|
38
|
+
"params": [
|
|
39
|
+
{
|
|
40
|
+
"name": "sources",
|
|
41
|
+
"type": "typeOperator",
|
|
42
|
+
"description": ""
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"returns": "Observable<A>"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
package/examples.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"category": "observable",
|
|
3
|
+
"helpers": [
|
|
4
|
+
{
|
|
5
|
+
"helper": "combine",
|
|
6
|
+
"examples": [
|
|
7
|
+
{
|
|
8
|
+
"title": "Combine two observables with a map",
|
|
9
|
+
"description": "Combines the latest values of two observables using a mapping function.",
|
|
10
|
+
"code": "combine(of(1), of(2), ([a, b]) => a + b)\n// emits 3"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"helper": "combineLatest",
|
|
16
|
+
"examples": [
|
|
17
|
+
{
|
|
18
|
+
"title": "Combine array of observables",
|
|
19
|
+
"description": "Combines an array of observables into one that emits arrays of their latest values.",
|
|
20
|
+
"code": "combineLatest([of(1), of(2), of(3)])\n// emits [1, 2, 3]"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"title": "Handle empty array",
|
|
24
|
+
"description": "Returns an observable that emits an empty array when given no sources.",
|
|
25
|
+
"code": "combineLatest([])\n// emits []"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Observable, OperatorFunction, ObservableInputTuple, ObservableInput, ObservedValueOf } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of helpers4.
|
|
5
|
+
* Copyright (C) 2025 baxyz
|
|
6
|
+
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
type combineOptions<T, U> = {
|
|
10
|
+
readonly preTreatment?: OperatorFunction<readonly [T, U], readonly [T, U]>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Combine two observables with a map function and an optional pre-treatment.
|
|
14
|
+
*
|
|
15
|
+
* Note: you can use the pre-treatment to add a filter, a distinctUntilChanged,
|
|
16
|
+
* any other operator that can be used in a pipe, or even an `UntilDestroy`
|
|
17
|
+
* operator.
|
|
18
|
+
*
|
|
19
|
+
* @param source1 first source of data
|
|
20
|
+
* @param source2 second source of data
|
|
21
|
+
* @param map way to combine data
|
|
22
|
+
* @param options options for the combineLatest operator
|
|
23
|
+
* @returns an observable that emits the result of the map function
|
|
24
|
+
* @see combineLatestOperator
|
|
25
|
+
* @see mapOperator
|
|
26
|
+
*/
|
|
27
|
+
declare function combine<T, U, R>(source1: Observable<T>, source2: Observable<U>, map: (c: readonly [T, U]) => R, options?: combineOptions<T, U>): Observable<R>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* This file is part of helpers4.
|
|
31
|
+
* Copyright (C) 2025 baxyz
|
|
32
|
+
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
declare function combineLatest<A extends readonly unknown[]>(sources: readonly [...ObservableInputTuple<A>]): Observable<A>;
|
|
36
|
+
declare function combineLatest<T extends Record<string, ObservableInput<any>>>(sourcesObject: T): Observable<{
|
|
37
|
+
[K in keyof T]: ObservedValueOf<T[K]>;
|
|
38
|
+
}>;
|
|
39
|
+
|
|
40
|
+
export { combine, combineLatest };
|