Compare commits

...

70 Commits

Author SHA1 Message Date
4969a703da 3.0.10 2025-04-25 09:01:40 +00:00
5e16294773 fix(ci): Update CI workflows, dependency versions, and TypeScript configuration 2025-04-25 09:01:40 +00:00
e0a4e5a076 3.0.9 2025-04-25 08:48:08 +00:00
23c6e17536 fix(deps/ts_plugins): Update @types/node dependency and adjust rxjs operator exports ordering 2025-04-25 08:48:08 +00:00
a0df30adf1 update description 2024-05-29 14:15:57 +02:00
d4de9087d5 update tsconfig 2024-04-14 18:15:29 +02:00
6c5a16bbdb update tsconfig 2024-04-01 21:40:44 +02:00
4a03e952fc update npmextra.json: githost 2024-04-01 19:59:31 +02:00
80b404a379 update npmextra.json: githost 2024-03-30 21:48:31 +01:00
d7c1bd06f2 3.0.8 2023-11-04 01:06:12 +01:00
124400df69 fix(core): update 2023-11-04 01:06:11 +01:00
84d3a6310d 3.0.7 2023-11-01 14:12:53 +01:00
984f7e7bb6 fix(core): update 2023-11-01 14:12:53 +01:00
f4e548aa2c 3.0.6 2023-07-24 13:59:47 +02:00
3f85e9fa3c fix(core): update 2023-07-24 13:59:46 +02:00
1b60ba805d 3.0.5 2023-07-24 13:15:02 +02:00
ceddf45850 fix(core): update 2023-07-24 13:15:01 +02:00
45fd82279e 3.0.4 2023-07-24 13:09:38 +02:00
110a2e27cc fix(core): update 2023-07-24 13:09:38 +02:00
a41652ba52 3.0.3 2023-07-12 10:57:25 +02:00
fad166c100 fix(core): update 2023-07-12 10:57:25 +02:00
ed6db60055 switch to new org scheme 2023-07-10 10:17:56 +02:00
0097f819a0 3.0.2 2023-06-11 22:15:29 +02:00
a3ed2e5dbd fix(core): update 2023-06-11 22:15:29 +02:00
f9e43be46a 3.0.1 2023-06-10 13:33:10 +02:00
ca22a417da fix(core): update 2023-06-10 13:33:09 +02:00
093b1dd7a9 3.0.0 2022-08-05 13:25:45 +02:00
3c1bfaa1f7 BREAKING CHANGE(core): switch to esm 2022-08-05 13:25:44 +02:00
83cd98022a 2.0.26 2022-08-05 12:50:38 +02:00
b06ceaa9bf fix(core): update 2022-08-05 12:50:37 +02:00
e8057c0c95 2.0.25 2022-01-24 21:48:32 +01:00
d389d180e5 fix(core): update 2022-01-24 21:48:32 +01:00
d92123dcb9 2.0.24 2022-01-24 07:37:53 +01:00
5d8f569339 fix(core): update 2022-01-24 07:37:52 +01:00
7168bd7ffd 2.0.23 2022-01-24 07:30:55 +01:00
5031d28c32 fix(core): update 2022-01-24 07:30:54 +01:00
4eaf91af3a 2.0.22 2022-01-24 07:08:25 +01:00
511396894d fix(core): update 2022-01-24 07:08:24 +01:00
a1bd0499a0 2.0.21 2022-01-24 07:06:38 +01:00
803c8a4d8f fix(core): update 2022-01-24 07:06:37 +01:00
d5a2b0a78e 2.0.20 2022-01-24 03:44:14 +01:00
5fdd756672 fix(core): update 2022-01-24 03:44:13 +01:00
5f7580b28f 2.0.19 2020-09-24 17:28:57 +00:00
bba7bb7eea fix(core): update 2020-09-24 17:28:57 +00:00
552cae9755 2.0.18 2020-07-12 01:53:33 +00:00
610c1d6beb fix(core): update 2020-07-12 01:53:32 +00:00
037e33caee 2.0.17 2020-06-26 00:57:14 +00:00
2400e61024 fix(core): update 2020-06-26 00:57:14 +00:00
0fe16f4fc4 2.0.16 2020-06-26 00:52:51 +00:00
fa8fb5b622 fix(core): update 2020-06-26 00:52:51 +00:00
389f502dd0 2.0.15 2020-05-27 20:12:26 +00:00
ea3e7dd2ab fix(core): update 2020-05-27 20:12:25 +00:00
e4ac6232b8 2.0.14 2020-05-27 19:56:52 +00:00
fd9c57dcd0 fix(core): update 2020-05-27 19:56:52 +00:00
090142cb16 2.0.13 2020-05-27 19:44:35 +00:00
b05a8e4fa4 fix(core): update 2020-05-27 19:44:35 +00:00
66ee8ba0df 2.0.12 2020-05-27 18:49:44 +00:00
f9d8175c8c fix(core): update 2020-05-27 18:49:44 +00:00
5e218e36a5 2.0.11 2020-05-27 18:30:28 +00:00
417772a1ec fix(core): update 2020-05-27 18:30:27 +00:00
e34d9f7cad 2.0.10 2020-05-27 17:26:32 +00:00
9908d759c6 fix(core): update 2020-05-27 17:26:32 +00:00
c4d48b17e9 2.0.9 2020-05-27 17:06:29 +00:00
3cf9396773 fix(core): update 2020-05-27 17:06:29 +00:00
3632941abc 2.0.8 2020-05-27 17:05:53 +00:00
b8d7653434 fix(core): update 2020-05-27 17:05:53 +00:00
f2b02a2f68 2.0.7 2020-05-27 17:05:18 +00:00
aa8e2a9ae4 fix(core): update 2020-05-27 17:05:18 +00:00
bfff3b4da5 2.0.6 2020-05-26 00:18:03 +00:00
5e2d11980c fix(core): update 2020-05-26 00:18:02 +00:00
24 changed files with 10587 additions and 1941 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

7
.gitignore vendored
View File

@ -3,7 +3,6 @@
# artifacts # artifacts
coverage/ coverage/
public/ public/
pages/
# installs # installs
node_modules/ node_modules/
@ -15,8 +14,6 @@ node_modules/
# builds # builds
dist/ dist/
dist_web/ dist_*/
dist_serve/
dist_ts_web/
# custom #------# custom

View File

@ -1,119 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- docker
- notpriv
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
stage: release
script:
- npmci node install lts
- npmci npm publish
only:
- tags
tags:
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
script:
- npmci command npm install -g tslint typescript
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- docker
- notpriv
pages:
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:stable-dind
stage: metadata
script:
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

146
changelog.md Normal file
View File

@ -0,0 +1,146 @@
# Changelog
## 2025-04-25 - 3.0.10 - fix(ci)
Update CI workflows, dependency versions, and TypeScript configuration
- Updated .gitea workflow files: changed IMAGE URL and npmci package name (@shipzone/npmci to @ship.zone/npmci)
- Upgraded development dependencies from @gitzone/* to @git.zone/* packages
- Enhanced tsconfig.json with emitDecoratorMetadata, baseUrl, and paths
- Minor code formatting improvements and trailing comma adjustments in TypeScript files
- Updated package.json homepage and added bugs/overrides configuration
## 2025-04-25 - 3.0.9 - fix(deps/ts_plugins)
Update @types/node dependency and adjust rxjs operator exports ordering
- Upgraded @types/node from ^20.8.10 to ^22.15.2 in package.json
- Reordered rxjs operator imports and exports in ts/smartrx.plugins.rxjs.ts for improved clarity
## 2024-05-29 - 3.0.8 - configuration updates
Updated project description and configuration files.
- Updated description.
- Revised tsconfig settings (2024-04-14 and 2024-04-01).
- Updated npmextra.json githost entries (2024-04-01 and 2024-03-30).
## 2023-11-04 - 3.0.7 - core
Fixed core functionality.
- Applied core fixes.
## 2023-11-01 - 3.0.6 - core
Fixed core functionality.
- Applied core fixes.
## 2023-07-24 - 3.0.5 - core
Fixed core functionality.
- Applied core fixes.
## 2023-07-24 - 3.0.4 - core
Fixed core functionality.
- Applied core fixes.
## 2023-07-24 - 3.0.3 - core
Fixed core functionality.
- Applied core fixes.
## 2023-07-12 - 3.0.2 - core
Fixed core functionality and organization scheme.
- Applied core fixes.
- Switched to new organization scheme (commit dated 2023-07-10).
## 2023-06-11 - 3.0.1 - core
Fixed core functionality.
- Applied core fixes.
## 2023-06-10 - 3.0.0 - core
Fixed core functionality.
- Applied core fixes.
---
## 2022-08-05 - 2.0.26 to 2.0.25 - core
Included a breaking change alongside core fixes.
- BREAKING CHANGE: Switched to ESM.
- Applied core fixes.
## 2022-01-24 - 2.0.24 to 2.0.19 - core
Consolidated several minor core fixes.
- Applied multiple core update fixes.
## 2020-09-24 - 2.0.18 - core
Fixed core functionality.
- Applied core fix.
## 2020-07-12 - 2.0.17 - core
Fixed core functionality.
- Applied core fix.
## 2020-06-26 - 2.0.16 to 2.0.15 - core
Fixed core functionality.
- Applied core fixes.
## 2020-05-27 - 2.0.14 to 2.0.6 - core
Fixed core functionality across several releases.
- Applied core fixes.
## 2020-05-26 - 2.0.5 - core
Fixed core functionality.
- Applied core fix.
## 2019-09-10 - 2.0.4 to 2.0.3 - core
Fixed core functionality.
- Applied core fixes.
## 2018-12-10 to 2018-11-23 - 2.0.2 to 2.0.1 - core & dependencies
Fixed core functionality and updated dependencies.
- Applied core fixes (2.0.2).
- Updated dependencies (2.0.1 fix).
## 2018-10-10 - 2.0.0 - core
Fixed core functionality.
- Applied core fix.
---
## 2018-10-10 - 1.0.5 - scope change
Introduced a breaking change in package scope.
- BREAKING CHANGE: Switched to the @pushrocks scope.
## 2017-11-01 - 1.0.4 - testing improvements
Enhanced test quality and intake functionality.
- Improved tests.
- Enabled working intake.
## 2017-10-30 - 1.0.3 - documentation
Updated project documentation.
- Revised docs.
## 2017-10-30 - 1.0.2 - documentation
Enhanced project information.
- Added README.
## 2017-10-26 - 1.0.1 - observable feature
Introduced observability features.
- Added observable functionality.

View File

@ -7,13 +7,27 @@
"command": "rm -r node_modules && yarn install && yarn test" "command": "rm -r node_modules && yarn install && yarn test"
}, },
"gitzone": { "gitzone": {
"projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "code.foss.global",
"gitscope": "pushrocks", "gitscope": "push.rocks",
"gitrepo": "smartrx", "gitrepo": "smartrx",
"shortDescription": "smart wrapper for rxjs", "description": "A smart wrapper for rxjs to manage and extend observables.",
"npmPackagename": "@pushrocks/smartrx", "npmPackagename": "@push.rocks/smartrx",
"license": "MIT" "license": "MIT",
"keywords": [
"rxjs",
"wrapper",
"observables",
"event emitter",
"stream processing",
"reactive programming",
"backpressure",
"event handling"
]
} }
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
} }
} }

1678
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +1,65 @@
{ {
"name": "@pushrocks/smartrx", "name": "@push.rocks/smartrx",
"version": "2.0.5", "version": "3.0.10",
"private": false, "private": false,
"description": "smart wrapper for rxjs", "description": "A smart wrapper for rxjs to manage and extend observables.",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild)" "build": "(tsbuild --web && tsbundle npm)",
"buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.17", "@git.zone/tsbuild": "^2.3.2",
"@gitzone/tsrun": "^1.2.8", "@git.zone/tsbundle": "^2.2.5",
"@gitzone/tstest": "^1.0.24", "@git.zone/tsrun": "^1.3.3",
"@pushrocks/tapbundle": "^3.0.13", "@git.zone/tstest": "^1.0.96",
"@types/node": "^12.7.4", "@push.rocks/tapbundle": "^5.0.15",
"tslint": "^5.20.0", "@types/node": "^22.15.2"
"tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.11", "@push.rocks/smartpromise": "^4.0.2",
"@pushrocks/smartevent": "^2.0.3", "rxjs": "^7.8.1"
"@pushrocks/smartpromise": "^3.0.2",
"rxjs": "^6.5.3"
}, },
"files": [ "files": [
"ts/*", "ts/**/*",
"ts_web/*", "ts_web/**/*",
"dist/*", "dist/**/*",
"dist_web/*", "dist_*/**/*",
"dist_ts_web/*", "dist_ts/**/*",
"assets/*", "dist_ts_web/**/*",
"assets/**/*",
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
] ],
"browserslist": [
"last 1 chrome versions"
],
"keywords": [
"rxjs",
"wrapper",
"observables",
"event emitter",
"stream processing",
"reactive programming",
"backpressure",
"event handling"
],
"homepage": "https://code.foss.global/push.rocks/smartrx#readme",
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smartrx.git"
},
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6",
"bugs": {
"url": "https://code.foss.global/push.rocks/smartrx/issues"
},
"pnpm": {
"overrides": {}
}
} }

9849
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

130
readme.md
View File

@ -1,35 +1,119 @@
# @pushrocks/smartrx # @push.rocks/smartrx
smart wrapper for rxjs smart wrapper for rxjs
## Availabililty and Links ## Install
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartrx)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartrx)
* [github.com (source mirror)](https://github.com/pushrocks/smartrx)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartrx/)
## Status for master To install `@push.rocks/smartrx`, run the following command in your terminal:
[![build status](https://gitlab.com/pushrocks/smartrx/badges/master/build.svg)](https://gitlab.com/pushrocks/smartrx/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartrx/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartrx/commits/master) ```bash
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartrx.svg)](https://www.npmjs.com/package/@pushrocks/smartrx) npm install @push.rocks/smartrx --save
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartrx/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartrx) ```
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) This package is distributed via npm and should be saved as a dependency in your project's `package.json` file once installed.
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage ## Usage
Use TypeScript for best in class instellisense. `@push.rocks/smartrx` provides a smart wrapper for working with RxJS, enhancing its already powerful reactive programming capabilities with additional functionalities, including easier observable map management and observable intake handling. We'll explore key features and how to use them in TypeScript.
For further information read the linked docs at the top of this README. First, ensure you're working in an environment configured for TypeScript and modern JavaScript development.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) ### Basic Setup
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks) To start using `@push.rocks/smartrx`, first, import what you need from the package:
For further information read the linked docs at the top of this readme. ```typescript
import { Observablemap, ObservableIntake, rxjs } from '@push.rocks/smartrx';
```
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) ### Observable Map Management
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) `Observablemap` helps manage observables efficiently, especially useful when you need to ensure a single observable per event or when working with event emitters.
#### Basic Observablemap Use
```typescript
import { Observablemap } from '@push.rocks/smartrx';
import { EventEmitter } from 'events';
// Initialize Observablemap
const observableMap = new Observablemap();
// Your event emitter (node.js events in this case)
const myEmitter = new EventEmitter();
// Get a Subject for a specific event
const myEventSubject = observableMap.getSubjectForEmitterEvent(myEmitter, 'myEvent');
// Subscribe to the Subject
myEventSubject.subscribe({
next: (value) => console.log(`Received value: ${value}`),
});
// Emit events
myEmitter.emit('myEvent', 'Hello World!');
```
This approach ensures that you have a single observable (Subject in this case) per event, efficiently reusing existing observables instead of creating new ones for the same event.
### Observable Intake
`ObservableIntake` is designed for efficiently managing and controlling the flow of data through observables, offering features like buffering and intake requests.
#### Using ObservableIntake
```typescript
import { ObservableIntake } from '@push.rocks/smartrx';
// Initialize ObservableIntake
const observableIntake = new ObservableIntake<string>();
// Listen to the observableIntake as you would with any RxJS Observable
observableIntake.subscribe({
next: (message) => console.log(message),
complete: () => console.log('No more messages'),
});
// Push messages into the observable intake
observableIntake.push('Hello');
observableIntake.push('World');
// Signal completion
observableIntake.signalComplete();
```
`ObservableIntake` offers the flexibility of adding values as they come and controlling when those values are emitted to subscribers, including buffering capabilities for managing backpressure.
#### Advanced Use-cases
`@push.rocks/smartrx` is built to handle more sophisticated scenarios like working with streams or handling events in a web environment.
- **From Streams with Backpressure**: Efficiently create observables from Node.js streams, applying backpressure as needed.
- **Event Management in Browsers**: Easily map browser events to observables, enabling reactive programming principles in frontend development.
### Conclusion
`@push.rocks/smartrx` significantly simplifies some of the more tedious aspects of working with RxJS, making it easier to manage observables related to event emitters and providing helpful utilities like observable intake for controlling data flow. With its smart wrappers, developers can focus more on business logic rather than boilerplate code for observable management.
For more complex use cases, such as integrating with external data sources or managing complex state with Redux, `@push.rocks/smartrx` offers a solid foundation for building reactive applications with ease and efficiency.
Remember, reactive programming with RxJS is a powerful paradigm that can make handling asynchronous data streams simpler and more maintainable. `@push.rocks/smartrx` enhances this paradigm by providing tools that make working with RxJS even more pleasant and productive.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

View File

@ -1,15 +1,15 @@
import { tap, expect } from '@pushrocks/tapbundle'; import { tap, expect } from '@push.rocks/tapbundle';
import * as smartrx from '../ts/index'; import * as smartrx from '../ts/index.js';
tap.test('should create a valid instance of observableinstake', async () => { tap.test('should create a valid instance of observableinstake', async () => {
const testObservableIntake = new smartrx.ObservableIntake(); const testObservableIntake = new smartrx.ObservableIntake();
expect(testObservableIntake).to.be.instanceOf(smartrx.ObservableIntake); expect(testObservableIntake).toBeInstanceOf(smartrx.ObservableIntake);
}); });
tap.test('expect testObserservableIntake to push things', async tools => { tap.test('expect testObserservableIntake to push things', async (tools) => {
const testObserservableIntake = new smartrx.ObservableIntake(); const testObserservableIntake = new smartrx.ObservableIntake();
testObserservableIntake.subscribe(value => { testObserservableIntake.subscribe((value: any) => {
console.log(value); console.log(value);
}); });
@ -19,13 +19,13 @@ tap.test('expect testObserservableIntake to push things', async tools => {
await testObserservableIntake.completed; await testObserservableIntake.completed;
}); });
tap.test('expect testObserservableIntake to push things', async tools => { tap.test('expect testObserservableIntake to push things', async (tools) => {
const testObserservableIntake = new smartrx.ObservableIntake(); const testObserservableIntake = new smartrx.ObservableIntake();
testObserservableIntake.push('hi'); testObserservableIntake.push('hi');
testObserservableIntake.push('wow'); testObserservableIntake.push('wow');
testObserservableIntake.makeBuffered(); testObserservableIntake.makeBuffered();
testObserservableIntake.push('jo'); testObserservableIntake.push('jo');
testObserservableIntake.subscribe(value => { testObserservableIntake.subscribe((value: any) => {
console.log(value); console.log(value);
testObserservableIntake.signalComplete(); testObserservableIntake.signalComplete();
}); });

View File

@ -1,11 +1,11 @@
// import test framework // import test framework
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@push.rocks/tapbundle';
import * as events from 'events'; import * as events from 'events';
import * as rx from 'rxjs'; import * as rx from 'rxjs';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@push.rocks/smartpromise';
// import the module // import the module
import * as smartrx from '../ts/index'; import * as smartrx from '../ts/index.js';
let testObservablemap: smartrx.Observablemap; let testObservablemap: smartrx.Observablemap;
let testObservable1: rx.Observable<any>; let testObservable1: rx.Observable<any>;
@ -15,20 +15,20 @@ let testEmitter: events.EventEmitter;
tap.test('should create an instance', async () => { tap.test('should create an instance', async () => {
testObservablemap = new smartrx.Observablemap(); testObservablemap = new smartrx.Observablemap();
expect(testObservablemap).be.instanceof(smartrx.Observablemap); expect(testObservablemap).toBeInstanceOf(smartrx.Observablemap);
}); });
tap.test('should accept a new emitter', async () => { tap.test('should accept a new emitter', async () => {
let done = smartpromise.defer(); let done = smartpromise.defer();
testEmitter = new events.EventEmitter(); testEmitter = new events.EventEmitter();
testObservable1 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1'); testObservable1 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event1');
testObservable1.subscribe(x => { testObservable1.subscribe((x) => {
done.resolve(); done.resolve();
}); });
testObservable2 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1'); testObservable2 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event1');
testObservable3 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event2'); testObservable3 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event2');
expect(testObservable1 === testObservable2).to.be.true; expect(testObservable1 === testObservable2).toBeTrue();
expect(testObservable1 === testObservable3).to.be.false; expect(testObservable1 === testObservable3).toBeFalse();
testEmitter.emit('event1'); testEmitter.emit('event1');
await done.promise; await done.promise;
}); });

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartrx',
version: '3.0.10',
description: 'A smart wrapper for rxjs to manage and extend observables.'
}

View File

@ -1,7 +1,6 @@
import * as plugins from './smartrx.plugins'; import * as plugins from './smartrx.plugins.js';
export * from './smartrx.classes.observablemap'; export * from './smartrx.classes.observablemap.js';
export * from './smartrx.classes.observableintake'; export * from './smartrx.classes.observableintake.js';
export * from './smartrx.functions.js';
import * as rxjs from 'rxjs'; import * as rxjs from './smartrx.plugins.rxjs.js';
export { rxjs }; export { rxjs };

View File

@ -1,42 +1,42 @@
import * as plugins from './smartrx.plugins'; import * as plugins from './smartrx.plugins.js';
import { Observable, Subscription } from 'rxjs';
import { Deferred } from '@pushrocks/smartpromise'; import * as rxjs from './smartrx.plugins.rxjs.js';
/** /**
* ObservableIntake * ObservableIntake
*/ */
export class ObservableIntake<T> { export class ObservableIntake<T> {
public observable: Observable<T>; public observable: rxjs.Observable<T>;
public completed: Promise<void>; public completed: Promise<void>;
private completedDeffered: Deferred<void>; private completedDeffered: plugins.smartpromise.Deferred<void>;
private observableFunctions: any = { private observableFunctions: any = {
next: payloadArg => { next: (payloadArg: T) => {
// nothing // nothing
}, },
complete: payloadArg => { complete: (payloadArg: T) => {
// nothing // nothing
} },
}; };
private generator = null; private generator: Generator<T> = null;
private buffered = false; private buffered = false;
private payloadBuffer = []; private payloadBuffer: any[] = [];
constructor() { constructor() {
this.observable = Observable.create(observerArg => { this.observable = new rxjs.Observable((observerArg: rxjs.Observer<any>) => {
this.observableFunctions.next = (...args) => { this.observableFunctions.next = (...args: any) => {
return observerArg.next(...args); return observerArg.next(args);
}; };
this.observableFunctions.complete = (...args) => { this.observableFunctions.complete = () => {
this.completedDeffered.resolve(); this.completedDeffered.resolve();
return observerArg.complete(...args); return observerArg.complete();
}; };
}); });
this.completedDeffered = plugins.smartpromise.defer(); this.completedDeffered = plugins.smartpromise.defer();
this.completed = this.completedDeffered.promise; this.completed = this.completedDeffered.promise;
} }
public setObservable(observableFunc) { public setObservable(observableFunc: rxjs.Observable<any>) {
this.observable = observableFunc(); this.observable = observableFunc;
} }
public push(payloadArg: T) { public push(payloadArg: T) {
@ -61,7 +61,7 @@ export class ObservableIntake<T> {
* sets a generator to query the next pushed value * sets a generator to query the next pushed value
* @param generatorArg * @param generatorArg
*/ */
public setGenerator(generatorArg) { public setGenerator(generatorArg: Generator<T>) {
this.generator = generatorArg; this.generator = generatorArg;
} }
@ -69,7 +69,7 @@ export class ObservableIntake<T> {
this.buffered = true; this.buffered = true;
} }
public subscribe(...args) { public subscribe(...args: any) {
return this.observable.subscribe(...args); return this.observable.subscribe(...args);
} }
@ -85,8 +85,8 @@ export class ObservableIntake<T> {
if (this.payloadBuffer.length > 0) { if (this.payloadBuffer.length > 0) {
this.internalPush(this.payloadBuffer.shift()); this.internalPush(this.payloadBuffer.shift());
} else { } else {
const nextPayload = this.generator(); const nextPayload = this.generator.next();
this.internalPush(nextPayload); this.internalPush(nextPayload.value);
} }
} }
} }
@ -99,7 +99,7 @@ export class ObservableIntake<T> {
this.observableFunctions.complete(); this.observableFunctions.complete();
} }
private internalPush(payloadArg) { private internalPush(payloadArg: T) {
this.observableFunctions.next(payloadArg); this.observableFunctions.next(payloadArg);
} }
} }

View File

@ -1,12 +1,16 @@
import * as plugins from './smartrx.plugins'; import * as plugins from './smartrx.plugins.js';
import { Observable, fromEvent } from 'rxjs'; import * as rxjs from './smartrx.plugins.rxjs.js';
import { Objectmap, Stringmap } from '@pushrocks/lik';
export interface IEventEmitter<T = any> {
on: (eventNameArg: string, eventHandlerArg: (eventPayload: T) => any) => void;
}
/** /**
* bundles an observable with an emitter * bundles an observable with an emitter
*/ */
export interface ObservableEmitterBundle { export interface IObservableEventBundle<T> {
observable: plugins.rxjs.Observable<any>; subject: rxjs.Subject<any>;
emitter: plugins.events.EventEmitter; eventRef: T;
event: string; event: string;
} }
@ -14,26 +18,56 @@ export interface ObservableEmitterBundle {
* manages observables by making sure that only one observable is regsitered per event * manages observables by making sure that only one observable is regsitered per event
*/ */
export class Observablemap { export class Observablemap {
ObservableEmitterBundleObjectmap = new Objectmap<ObservableEmitterBundle>(); public observableEventEmitterBundleArray = new Array<
IObservableEventBundle<IEventEmitter<unknown>>
>();
public observableEventTargetBundleArray = new Array<IObservableEventBundle<EventTarget>>();
/** /**
* creates a new observable if not yet registered for the same event. * creates a hot subject if not yet registered for the event.
* In case event has been registered before the same observable is returned. * In case event has been registered before the same observable is returned.
*/ */
getObservableForEmitterEvent(emitterArg: plugins.events.EventEmitter, eventArg: string) { public getSubjectForEmitterEvent<T>(
let existingBundle = this.ObservableEmitterBundleObjectmap.find(bundleArg => { emitterArg: IEventEmitter<T>,
return bundleArg.emitter === emitterArg && bundleArg.event === eventArg; eventArg: string,
): rxjs.Subject<T> {
const existingBundle = this.observableEventEmitterBundleArray.find((bundleArg) => {
return bundleArg.eventRef === emitterArg && bundleArg.event === eventArg;
}); });
if (existingBundle) { if (existingBundle) {
return existingBundle.observable; return existingBundle.subject;
} else { } else {
let emitterObservable = fromEvent(emitterArg, eventArg); const emitterObservable = rxjs.fromEvent<T>(emitterArg as any, eventArg);
this.ObservableEmitterBundleObjectmap.add({ const emitterSubject = new rxjs.Subject();
observable: emitterObservable, emitterObservable.subscribe(emitterSubject);
emitter: emitterArg, const newBundle: IObservableEventBundle<IEventEmitter> = {
event: eventArg subject: emitterSubject,
}); eventRef: emitterArg,
return emitterObservable; event: eventArg,
};
this.observableEventEmitterBundleArray.push(newBundle);
return newBundle.subject;
}
}
public getSubjectForEventTarget<T>(
eventTargetArg: EventTarget,
eventNameArg: string,
): rxjs.Subject<T> {
const existingBundle = this.observableEventTargetBundleArray.find((bundleArg) => {
return bundleArg.eventRef === eventTargetArg && bundleArg.event === eventNameArg;
});
if (existingBundle) {
return existingBundle.subject;
} else {
const emitterSubject = new rxjs.Subject();
const newBundle: IObservableEventBundle<EventTarget> = {
subject: emitterSubject,
eventRef: eventTargetArg,
event: eventNameArg,
};
this.observableEventTargetBundleArray.push(newBundle);
return newBundle.subject;
} }
} }
} }

32
ts/smartrx.functions.ts Normal file
View File

@ -0,0 +1,32 @@
import { Observable } from 'rxjs';
import type { Readable } from 'stream';
export function fromStreamWithBackpressure<T>(stream: Readable): Observable<T> {
return new Observable<T>((subscriber) => {
const pauseStream = () => stream.pause();
const resumeStream = () => process.nextTick(() => stream.resume());
// Handler for each piece of data
const onData = (data: T) => {
// Pause the stream to apply backpressure
pauseStream();
// Emit data and resume the stream if the subscriber is ready
subscriber.next(data);
resumeStream();
};
// Subscribe to stream events
stream.on('data', onData);
stream.on('error', (error) => subscriber.error(error));
stream.on('end', () => subscriber.complete());
stream.on('close', () => subscriber.complete());
// If the subscriber unsubscribes, clean up the stream listeners
return () => {
stream.removeListener('data', onData);
stream.removeListener('error', subscriber.error);
stream.removeListener('end', subscriber.complete);
stream.removeListener('close', subscriber.complete);
};
});
}

View File

@ -0,0 +1,31 @@
// this file is intended to keep the bundle size down
export { Observable, Subject, fromEvent, ReplaySubject, Subscription, from, of } from 'rxjs';
export type { Observer } from 'rxjs';
import {
buffer,
bufferCount,
bufferTime,
debounce,
debounceTime,
filter,
map,
startWith,
takeUntil,
throttleTime,
} from 'rxjs/operators';
export const ops = {
buffer,
bufferCount,
bufferTime,
debounce,
debounceTime,
filter,
map,
startWith,
takeUntil,
throttleTime,
};

View File

@ -1,7 +1,3 @@
import * as events from 'events'; import * as smartpromise from '@push.rocks/smartpromise';
import * as lik from '@pushrocks/lik';
import * as rxjs from 'rxjs';
import * as smartevent from '@pushrocks/smartevent';
import * as smartpromise from '@pushrocks/smartpromise';
export { events, lik, rxjs, smartevent, smartpromise }; export { smartpromise };

17
tsconfig.json Normal file
View File

@ -0,0 +1,17 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
"baseUrl": ".",
"paths": {}
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}