@helpers4/observable 2.0.0-beta.0 → 2.0.0-beta.3

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 CHANGED
@@ -20,10 +20,12 @@ A set of helpers for working with URLs.
20
20
 
21
21
  <!-- AUTOMATIC-SIBLINGS -->
22
22
  - [array](../array)
23
+ - [ci](../ci)
23
24
  - [commit](../commit)
24
25
  - [date](../date)
25
26
  - [function](../function)
26
- - [math](../math)
27
+ - [id](../id)
28
+ - [markdown](../markdown)
27
29
  - [number](../number)
28
30
  - [object](../object)
29
31
  - [promise](../promise)
@@ -39,10 +41,12 @@ A set of helpers for working with URLs.
39
41
  | Name | Package | Source Code | Description |
40
42
  |------|---------|-------------|-------------|
41
43
  | array | [@helpers4/array](https://www.npmjs.com/package/@helpers4/array) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/array) | Array manipulation utilities |
44
+ | ci | [@helpers4/ci](https://www.npmjs.com/package/@helpers4/ci) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/ci) | CI/CD workflow status utilities |
42
45
  | commit | [@helpers4/commit](https://www.npmjs.com/package/@helpers4/commit) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/commit) | Conventional Commits parsing and analysis |
43
46
  | date | [@helpers4/date](https://www.npmjs.com/package/@helpers4/date) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/date) | Date and time utility functions |
44
47
  | 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 |
45
- | math | [@helpers4/math](https://www.npmjs.com/package/@helpers4/math) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/math) | Mathematical utility functions and calculations |
48
+ | id | [@helpers4/id](https://www.npmjs.com/package/@helpers4/id) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/id) | Unique identifier generation utilities |
49
+ | markdown | [@helpers4/markdown](https://www.npmjs.com/package/@helpers4/markdown) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/markdown) | Markdown formatting and escaping utilities |
46
50
  | number | [@helpers4/number](https://www.npmjs.com/package/@helpers4/number) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/number) | Number utility functions and validation |
47
51
  | object | [@helpers4/object](https://www.npmjs.com/package/@helpers4/object) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/object) | Object manipulation utilities |
48
52
  | 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/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../helpers/observable/combine.ts","../../../helpers/type/isDefined.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\nimport type { Maybe } from './Maybe.model';\n\n/**\n * Checks if a value is defined (not undefined nor null).\n * This is the inverse of {@link isNullish}.\n *\n * Use as a type-safe filter callback to remove `null`/`undefined` from arrays.\n *\n * @param value - The value to check\n * @returns True if value is not undefined nor null\n * @example\n * isDefined(42) // => true\n * isDefined('') // => true (empty string is defined)\n * isDefined(null) // => false\n * isDefined(undefined) // => false\n *\n * @example\n * // Type-safe alternative to filter out null/undefined\n * const items: (string | null | undefined)[] = ['a', null, 'b', undefined];\n * const result = items.filter(isDefined);\n * // => ['a', 'b'] with type string[]\n *\n * @see {@link isNullish} for the inverse check\n * @see {@link isTruthy} to also filter out `0`, `\"\"`, `false`, and `NaN`\n * @since 2.0.0\n */\nexport function isDefined<T>(value: Maybe<T>): value is T {\n return value !== undefined && value !== null;\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\";\nimport { isDefined } from '../type/isDefined';\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<unknown>>>(\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: readonly ObservableInput<unknown>[] | Record<string, ObservableInput<unknown>>): Observable<unknown> {\n if (Array.isArray(input)) {\n const filtered = input.filter(isDefined);\n return filtered.length ? combineLatestOperator(filtered) : of([]);\n } else {\n const filtered = Object.fromEntries(\n Object.entries(input).filter(([_, v]) => isDefined(v)),\n );\n return Object.keys(filtered).length\n ? combineLatestOperator(filtered)\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;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClB3E,SAAgB,UAAa,OAA6B;AACxD,QAAO,UAAU,KAAA,KAAa,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACsB1C,SAAgB,cAAc,OAA4G;AACxI,KAAI,MAAM,QAAQ,MAAM,EAAE;EACxB,MAAM,WAAW,MAAM,OAAO,UAAU;AACxC,SAAO,SAAS,SAAS,gBAAsB,SAAS,GAAG,GAAG,EAAE,CAAC;QAC5D;EACL,MAAM,WAAW,OAAO,YACtB,OAAO,QAAQ,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,UAAU,EAAE,CAAC,CACvD;AACD,SAAO,OAAO,KAAK,SAAS,CAAC,SACzB,gBAAsB,SAAS,GAC/B,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../helpers/observable/combine.ts","../../../helpers/type/isDefined.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\nimport type { Maybe } from './Maybe';\n\n/**\n * Checks if a value is defined (not undefined nor null).\n * This is the inverse of {@link isNullish}.\n *\n * Use as a type-safe filter callback to remove `null`/`undefined` from arrays.\n *\n * @param value - The value to check\n * @returns True if value is not undefined nor null\n * @example\n * isDefined(42) // => true\n * isDefined('') // => true (empty string is defined)\n * isDefined(null) // => false\n * isDefined(undefined) // => false\n *\n * @example\n * // Type-safe alternative to filter out null/undefined\n * const items: (string | null | undefined)[] = ['a', null, 'b', undefined];\n * const result = items.filter(isDefined);\n * // => ['a', 'b'] with type string[]\n *\n * @see {@link isNullish} for the inverse check\n * @see {@link isTruthy} to also filter out `0`, `\"\"`, `false`, and `NaN`\n * @since 2.0.0\n */\nexport function isDefined<T>(value: Maybe<T>): value is T {\n return value !== undefined && value !== null;\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\";\nimport { isDefined } from '../type/isDefined';\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<unknown>>>(\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: readonly ObservableInput<unknown>[] | Record<string, ObservableInput<unknown>>): Observable<unknown> {\n if (Array.isArray(input)) {\n const filtered = input.filter(isDefined);\n return filtered.length ? combineLatestOperator(filtered) : of([]);\n } else {\n const filtered = Object.fromEntries(\n Object.entries(input).filter(([_, v]) => isDefined(v)),\n );\n return Object.keys(filtered).length\n ? combineLatestOperator(filtered)\n : of({});\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,QACd,SACA,SACA,OACA,SACe;CACf,IAAI,SAAS,cACX,OAAO,gBAAsB,CAAC,SAAS,QAAQ,CAAC,CAAC,KAC/C,QAAQ,cACR,IAAY,MAAI,CACjB;MAED,OAAO,gBAAsB,CAAC,SAAS,QAAQ,CAAC,CAAC,KAAK,IAAY,MAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClB3E,SAAgB,UAAa,OAA6B;CACxD,OAAO,UAAU,KAAA,KAAa,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACsB1C,SAAgB,cAAc,OAA4G;CACxI,IAAI,MAAM,QAAQ,MAAM,EAAE;EACxB,MAAM,WAAW,MAAM,OAAO,UAAU;EACxC,OAAO,SAAS,SAAS,gBAAsB,SAAS,GAAG,GAAG,EAAE,CAAC;QAC5D;EACL,MAAM,WAAW,OAAO,YACtB,OAAO,QAAQ,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,UAAU,EAAE,CAAC,CACvD;EACD,OAAO,OAAO,KAAK,SAAS,CAAC,SACzB,gBAAsB,SAAS,GAC/B,GAAG,EAAE,CAAC"}
package/llms.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  # @helpers4/observable
2
2
 
3
3
  > Tree-shakable TypeScript utility functions for the `observable` domain.
4
- > Package: `@helpers4/observable` — Version: 2.0.0-beta.0
4
+ > Package: `@helpers4/observable` — Version: 2.0.0-beta.3
5
5
  > License: LGPL-3.0-or-later
6
6
 
7
7
  ## Installation
package/meta/api.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "category": "observable",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.3",
4
4
  "functions": [
5
5
  {
6
6
  "name": "combine",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helpers4/observable",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.3",
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",