@helpers4/observable 2.0.0-alpha.7 → 2.0.0-alpha.9

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/lib/index.d.ts CHANGED
@@ -23,6 +23,7 @@ type combineOptions<T, U> = {
23
23
  * @returns an observable that emits the result of the map function
24
24
  * @see combineLatestOperator
25
25
  * @see mapOperator
26
+ * @since 1.0.0
26
27
  */
27
28
  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
 
package/lib/index.js CHANGED
@@ -19,6 +19,7 @@ import { combineLatest as combineLatest$1, map, of } from "rxjs";
19
19
  * @returns an observable that emits the result of the map function
20
20
  * @see combineLatestOperator
21
21
  * @see mapOperator
22
+ * @since 1.0.0
22
23
  */
23
24
  function combine(source1, source2, map$1, options) {
24
25
  if (options?.preTreatment) return combineLatest$1([source1, source2]).pipe(options.preTreatment, map(map$1));
@@ -54,6 +55,7 @@ function combine(source1, source2, map$1, options) {
54
55
  * @returns {Observable} An Observable of projected values from the most recent
55
56
  * values from each input Observable, or an array of the most recent values from
56
57
  * each input Observable.
58
+ * @since 1.0.0
57
59
  */
58
60
  function combineLatest(input) {
59
61
  if (Array.isArray(input)) {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../helpers/observable/combine.ts","../../../helpers/observable/combineLatest.ts"],"sourcesContent":["/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/*\n * This program is under the terms of the GNU Lesser General Public License version 3\n * The full license information can be found in LICENSE in the root directory of this project.\n */\nimport {\n Observable,\n OperatorFunction,\n combineLatest as combineLatestOperator,\n map as mapOperator,\n} from \"rxjs\";\n\n\ntype combineOptions<T, U> = {\n readonly preTreatment?: OperatorFunction<readonly [T, U], readonly [T, U]>;\n};\n\n/**\n * Combine two observables with a map function and an optional pre-treatment.\n *\n * Note: you can use the pre-treatment to add a filter, a distinctUntilChanged,\n * any other operator that can be used in a pipe, or even an `UntilDestroy`\n * operator.\n *\n * @param source1 first source of data\n * @param source2 second source of data\n * @param map way to combine data\n * @param options options for the combineLatest operator\n * @returns an observable that emits the result of the map function\n * @see combineLatestOperator\n * @see mapOperator\n */\nexport function combine<T, U, R>(\n source1: Observable<T>,\n source2: Observable<U>,\n map: (c: readonly [T, U]) => R,\n options?: combineOptions<T, U>\n): Observable<R> {\n if (options?.preTreatment) {\n return combineLatestOperator([source1, source2]).pipe(\n options.preTreatment,\n mapOperator(map)\n );\n } else {\n return combineLatestOperator([source1, source2]).pipe(mapOperator(map));\n }\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/*\n * This program is under the terms of the GNU Lesser General Public License version 3\n * The full license information can be found in LICENSE in the root directory of this project.\n */\nimport {\n Observable,\n ObservableInput,\n ObservableInputTuple,\n ObservedValueOf,\n combineLatest as combineLatestOperator,\n of,\n} from \"rxjs\";\n\n// combineLatest([a, b, c])\nexport function combineLatest<A extends readonly unknown[]>(\n sources: readonly [...ObservableInputTuple<A>]\n): Observable<A>;\n\n// combineLatest({a, b, c})\nexport function combineLatest<T extends Record<string, ObservableInput<any>>>(\n sourcesObject: T\n): Observable<{ [K in keyof T]: ObservedValueOf<T[K]> }>;\n\n/**\n * Combines multiple Observables to create an Observable whose values are\n * calculated from the latest values of each of its input Observables.\n *\n * This method relies on {@link combineLatestOperator} of rxjs.\n *\n * The main difference with {@link combineLatestOperator} is in case of empty parameters.\n * If the parameter is empty (empty array or empty object), the result will be\n * also empty.\n *\n * ATTENTION: this version doesn't support `scheduler` nor `mapper` as last\n * argument like in {@link combineLatestOperator}.\n *\n * @see {@link combineLatestOperator}\n * @see {@link combineLatestAll}\n * @see {@link merge}\n * @see {@link withLatestFrom}\n *\n * @param {ObservableInput} [observables] An array of input Observables to combine with each other.\n * An array of Observables must be given as the first argument.\n * @returns {Observable} An Observable of projected values from the most recent\n * values from each input Observable, or an array of the most recent values from\n * each input Observable.\n */\nexport function combineLatest(input: any): any {\n if (Array.isArray(input)) {\n input = input.filter((a) => !!a);\n return input.length ? combineLatestOperator(...input) : of([]);\n } else {\n return Object.entries(input).filter(([_, v]) => !!v).length\n ? combineLatestOperator(input)\n : of({});\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,QACd,SACA,SACA,OACA,SACe;AACf,KAAI,SAAS,aACX,QAAO,gBAAsB,CAAC,SAAS,QAAQ,CAAC,CAAC,KAC/C,QAAQ,cACR,IAAY,MAAI,CACjB;KAED,QAAO,gBAAsB,CAAC,SAAS,QAAQ,CAAC,CAAC,KAAK,IAAY,MAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACI3E,SAAgB,cAAc,OAAiB;AAC7C,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,UAAQ,MAAM,QAAQ,MAAM,CAAC,CAAC,EAAE;AAChC,SAAO,MAAM,SAAS,gBAAsB,GAAG,MAAM,GAAG,GAAG,EAAE,CAAC;OAE9D,QAAO,OAAO,QAAQ,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,SACjD,gBAAsB,MAAM,GAC5B,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../helpers/observable/combine.ts","../../../helpers/observable/combineLatest.ts"],"sourcesContent":["/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/*\n * This program is under the terms of the GNU Lesser General Public License version 3\n * The full license information can be found in LICENSE in the root directory of this project.\n */\nimport {\n Observable,\n OperatorFunction,\n combineLatest as combineLatestOperator,\n map as mapOperator,\n} from \"rxjs\";\n\n\ntype combineOptions<T, U> = {\n readonly preTreatment?: OperatorFunction<readonly [T, U], readonly [T, U]>;\n};\n\n/**\n * Combine two observables with a map function and an optional pre-treatment.\n *\n * Note: you can use the pre-treatment to add a filter, a distinctUntilChanged,\n * any other operator that can be used in a pipe, or even an `UntilDestroy`\n * operator.\n *\n * @param source1 first source of data\n * @param source2 second source of data\n * @param map way to combine data\n * @param options options for the combineLatest operator\n * @returns an observable that emits the result of the map function\n * @see combineLatestOperator\n * @see mapOperator\n * @since 1.0.0\n */\nexport function combine<T, U, R>(\n source1: Observable<T>,\n source2: Observable<U>,\n map: (c: readonly [T, U]) => R,\n options?: combineOptions<T, U>\n): Observable<R> {\n if (options?.preTreatment) {\n return combineLatestOperator([source1, source2]).pipe(\n options.preTreatment,\n mapOperator(map)\n );\n } else {\n return combineLatestOperator([source1, source2]).pipe(mapOperator(map));\n }\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/*\n * This program is under the terms of the GNU Lesser General Public License version 3\n * The full license information can be found in LICENSE in the root directory of this project.\n */\nimport {\n Observable,\n ObservableInput,\n ObservableInputTuple,\n ObservedValueOf,\n combineLatest as combineLatestOperator,\n of,\n} from \"rxjs\";\n\n// combineLatest([a, b, c])\nexport function combineLatest<A extends readonly unknown[]>(\n sources: readonly [...ObservableInputTuple<A>]\n): Observable<A>;\n\n// combineLatest({a, b, c})\nexport function combineLatest<T extends Record<string, ObservableInput<any>>>(\n sourcesObject: T\n): Observable<{ [K in keyof T]: ObservedValueOf<T[K]> }>;\n\n/**\n * Combines multiple Observables to create an Observable whose values are\n * calculated from the latest values of each of its input Observables.\n *\n * This method relies on {@link combineLatestOperator} of rxjs.\n *\n * The main difference with {@link combineLatestOperator} is in case of empty parameters.\n * If the parameter is empty (empty array or empty object), the result will be\n * also empty.\n *\n * ATTENTION: this version doesn't support `scheduler` nor `mapper` as last\n * argument like in {@link combineLatestOperator}.\n *\n * @see {@link combineLatestOperator}\n * @see {@link combineLatestAll}\n * @see {@link merge}\n * @see {@link withLatestFrom}\n *\n * @param {ObservableInput} [observables] An array of input Observables to combine with each other.\n * An array of Observables must be given as the first argument.\n * @returns {Observable} An Observable of projected values from the most recent\n * values from each input Observable, or an array of the most recent values from\n * each input Observable.\n * @since 1.0.0\n */\nexport function combineLatest(input: any): any {\n if (Array.isArray(input)) {\n input = input.filter((a) => !!a);\n return input.length ? combineLatestOperator(...input) : of([]);\n } else {\n return Object.entries(input).filter(([_, v]) => !!v).length\n ? combineLatestOperator(input)\n : of({});\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,QACd,SACA,SACA,OACA,SACe;AACf,KAAI,SAAS,aACX,QAAO,gBAAsB,CAAC,SAAS,QAAQ,CAAC,CAAC,KAC/C,QAAQ,cACR,IAAY,MAAI,CACjB;KAED,QAAO,gBAAsB,CAAC,SAAS,QAAQ,CAAC,CAAC,KAAK,IAAY,MAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACI3E,SAAgB,cAAc,OAAiB;AAC7C,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,UAAQ,MAAM,QAAQ,MAAM,CAAC,CAAC,EAAE;AAChC,SAAO,MAAM,SAAS,gBAAsB,GAAG,MAAM,GAAG,GAAG,EAAE,CAAC;OAE9D,QAAO,OAAO,QAAQ,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,SACjD,gBAAsB,MAAM,GAC5B,GAAG,EAAE,CAAC"}
package/meta/api.json ADDED
@@ -0,0 +1,127 @@
1
+ {
2
+ "category": "observable",
3
+ "version": "2.0.0-alpha.9",
4
+ "functions": [
5
+ {
6
+ "name": "combine",
7
+ "kind": "function",
8
+ "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.",
9
+ "since": "1.0.0",
10
+ "signatures": [
11
+ {
12
+ "signature": "combine<T, U, R>(source1: Observable<T>, source2: Observable<U>, map: function, options?: combineOptions<T, U>): Observable<R>",
13
+ "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.",
14
+ "params": [
15
+ {
16
+ "name": "source1",
17
+ "type": "Observable<T>",
18
+ "description": "first source of data"
19
+ },
20
+ {
21
+ "name": "source2",
22
+ "type": "Observable<U>",
23
+ "description": "second source of data"
24
+ },
25
+ {
26
+ "name": "map",
27
+ "type": "function",
28
+ "description": "way to combine data"
29
+ },
30
+ {
31
+ "name": "options",
32
+ "type": "combineOptions<T, U>",
33
+ "description": "options for the combineLatest operator",
34
+ "optional": true
35
+ }
36
+ ],
37
+ "returns": {
38
+ "type": "Observable<R>",
39
+ "description": "an observable that emits the result of the map function"
40
+ },
41
+ "typeParameters": [
42
+ {
43
+ "name": "T"
44
+ },
45
+ {
46
+ "name": "U"
47
+ },
48
+ {
49
+ "name": "R"
50
+ }
51
+ ]
52
+ }
53
+ ],
54
+ "examples": [
55
+ {
56
+ "title": "Combine two observables with a map",
57
+ "description": "Combines the latest values of two observables using a mapping function.",
58
+ "code": "combine(of(1), of(2), ([a, b]) => a + b)\n// emits 3"
59
+ }
60
+ ],
61
+ "sourceFile": "combine.ts"
62
+ },
63
+ {
64
+ "name": "combineLatest",
65
+ "kind": "function",
66
+ "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.",
67
+ "since": "1.0.0",
68
+ "signatures": [
69
+ {
70
+ "signature": "combineLatest<A extends readonly unknown[]>(sources: readonly [ObservableInputTuple<A>]): Observable<A>",
71
+ "description": "",
72
+ "params": [
73
+ {
74
+ "name": "sources",
75
+ "type": "readonly [ObservableInputTuple<A>]",
76
+ "description": ""
77
+ }
78
+ ],
79
+ "returns": {
80
+ "type": "Observable<A>",
81
+ "description": ""
82
+ },
83
+ "typeParameters": [
84
+ {
85
+ "name": "A",
86
+ "constraint": "readonly unknown[]"
87
+ }
88
+ ]
89
+ },
90
+ {
91
+ "signature": "combineLatest<T extends Record<string, ObservableInput<any>>>(sourcesObject: T): Observable<mapped>",
92
+ "description": "",
93
+ "params": [
94
+ {
95
+ "name": "sourcesObject",
96
+ "type": "T",
97
+ "description": ""
98
+ }
99
+ ],
100
+ "returns": {
101
+ "type": "Observable<mapped>",
102
+ "description": ""
103
+ },
104
+ "typeParameters": [
105
+ {
106
+ "name": "T",
107
+ "constraint": "Record<string, ObservableInput<any>>"
108
+ }
109
+ ]
110
+ }
111
+ ],
112
+ "examples": [
113
+ {
114
+ "title": "Combine array of observables",
115
+ "description": "Combines an array of observables into one that emits arrays of their latest values.",
116
+ "code": "combineLatest([of(1), of(2), of(3)])\n// emits [1, 2, 3]"
117
+ },
118
+ {
119
+ "title": "Handle empty array",
120
+ "description": "Returns an observable that emits an empty array when given no sources.",
121
+ "code": "combineLatest([])\n// emits []"
122
+ }
123
+ ],
124
+ "sourceFile": "combineLatest.ts"
125
+ }
126
+ ]
127
+ }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "category": "observable",
3
- "helpers": [
3
+ "functions": [
4
4
  {
5
- "helper": "combine",
5
+ "name": "combine",
6
6
  "examples": [
7
7
  {
8
8
  "title": "Combine two observables with a map",
@@ -12,7 +12,7 @@
12
12
  ]
13
13
  },
14
14
  {
15
- "helper": "combineLatest",
15
+ "name": "combineLatest",
16
16
  "examples": [
17
17
  {
18
18
  "title": "Combine array of observables",
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@helpers4/observable",
3
- "version": "2.0.0-alpha.7",
3
+ "version": "2.0.0-alpha.9",
4
4
  "description": "A set of helpers in TS/JS, compatible with tree-shaking, for observable.",
5
5
  "author": "baxyz <baxy@etik.com>",
6
6
  "license": "LGPL-3.0",
7
+ "homepage": "https://helpers4.dev/typescript/categories/observable/",
7
8
  "repository": {
8
9
  "type": "git",
9
10
  "url": "git+https://github.com/helpers4/typescript.git"
@@ -17,9 +18,9 @@
17
18
  "types": "./lib/index.d.ts",
18
19
  "import": "./lib/index.js"
19
20
  },
20
- "./examples.json": "./examples.json",
21
- "./api.json": "./api.json",
22
- "./licenses.json": "./licenses.json",
21
+ "./meta/api.json": "./meta/api.json",
22
+ "./meta/examples.json": "./meta/examples.json",
23
+ "./meta/licenses.json": "./meta/licenses.json",
23
24
  "./package.json": "./package.json"
24
25
  },
25
26
  "keywords": [
@@ -32,9 +33,7 @@
32
33
  "lib/index.js",
33
34
  "lib/index.d.ts",
34
35
  "lib/index.js.map",
35
- "examples.json",
36
- "api.json",
37
- "licenses.json",
36
+ "meta/",
38
37
  "LICENSE.md",
39
38
  "package.json",
40
39
  "README.md"
@@ -45,4 +44,4 @@
45
44
  "peerDependencies": {
46
45
  "rxjs": "^7.8.2"
47
46
  }
48
- }
47
+ }
package/api.json DELETED
@@ -1,48 +0,0 @@
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
- }
File without changes