evg_observable 2.15.4 → 2.15.7
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 +91 -0
- package/package.json +7 -3
- package/src/outLib/Collector.js +1 -1
- package/src/outLib/Observable.js +1 -1
- package/src/outLib/OrderedObservable.js +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ EVG Observable - is a light library for simple use.
|
|
|
8
8
|
|
|
9
9
|
## Navigation
|
|
10
10
|
|
|
11
|
+
- [EVG Observable vs RxJS](#evg-observable-vs-rxjs)
|
|
11
12
|
- [What is EVG Observable?](#what-is-evg-observable)
|
|
12
13
|
- [Installation](#installation)
|
|
13
14
|
- [Node.js](#nodejs)
|
|
@@ -29,6 +30,96 @@ EVG Observable - is a light library for simple use.
|
|
|
29
30
|
- [Collector](#collector-1)
|
|
30
31
|
- [License](#license)
|
|
31
32
|
|
|
33
|
+
## EVG Observable vs RxJS
|
|
34
|
+
|
|
35
|
+
| Metric | EVG Observable | RxJS |
|
|
36
|
+
|--------|----------------|------|
|
|
37
|
+
| **Bundle size** | **6.4 kB** | 88 kB |
|
|
38
|
+
| **Size advantage** | **13.75x smaller** | - |
|
|
39
|
+
| **Operations** | ~40 | 100+ |
|
|
40
|
+
| **Performance** | **2-6x faster** | baseline |
|
|
41
|
+
|
|
42
|
+
### Performance Comparison (Bundle vs Bundle)
|
|
43
|
+
|
|
44
|
+
| Test | EVG Observable | RxJS | Advantage |
|
|
45
|
+
|------|----------------|------|-----------|
|
|
46
|
+
| Emit 100 values | 1,548K ops/sec | 240K ops/sec | **6.4x faster** |
|
|
47
|
+
| Filter + transform | 353K ops/sec | 164K ops/sec | **2.1x faster** |
|
|
48
|
+
| 10 subscribers | 9,078K ops/sec | 2,900K ops/sec | **3.1x faster** |
|
|
49
|
+
| 100 subscribers | 1,245K ops/sec | 336K ops/sec | **3.7x faster** |
|
|
50
|
+
| 1000 subscribers | 122K ops/sec | 33K ops/sec | **3.7x faster** |
|
|
51
|
+
| Large payload | 865K ops/sec | 199K ops/sec | **4.3x faster** |
|
|
52
|
+
|
|
53
|
+
### EVG Observable Advantages
|
|
54
|
+
|
|
55
|
+
- **Dual filtering system** - Inbound (`addFilter`) + Outbound (`pipe`) filters
|
|
56
|
+
- **OR-logic in pipes** - `switch().case()` for branching logic
|
|
57
|
+
- **OR-logic in inbound filters** - `addFilter().switch().case()`
|
|
58
|
+
- **Observable-to-Observable subscription** - Direct subscription without adapters
|
|
59
|
+
- **OrderedObservable** - Subscribers with emission order control (not in RxJS)
|
|
60
|
+
- **Batch emission** - `stream()` method for array processing
|
|
61
|
+
- **Collector** - Convenient subscription management
|
|
62
|
+
- **Clean code organization** - Simple, readable module structure
|
|
63
|
+
|
|
64
|
+
### When to use RxJS instead
|
|
65
|
+
|
|
66
|
+
RxJS is better when you need specialized operators like `debounceTime`, `throttleTime`, `switchMap`, `mergeMap`, `combineLatest`, `withLatestFrom`, or schedulers for async control.
|
|
67
|
+
|
|
68
|
+
**For 80% of reactive programming tasks, EVG Observable provides sufficient functionality with significant performance and size benefits.**
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## EVG Observable vs Lightweight Competitors
|
|
73
|
+
|
|
74
|
+
Comparison with lightweight libraries in the same weight category (observable-fns):
|
|
75
|
+
|
|
76
|
+
| Metric | EVG Observable | observable-fns |
|
|
77
|
+
|--------|----------------|----------------|
|
|
78
|
+
| **Weekly downloads** | Growing | 67K |
|
|
79
|
+
| **Bundle size (minified)** | 6.3 kB | 10.8 kB |
|
|
80
|
+
| **Implementation** | Original architecture | zen-observable re-implementation |
|
|
81
|
+
| **Dependencies** | 0 | 0 |
|
|
82
|
+
| **Architecture** | True hot observables | Cold observables (zen-observable API) |
|
|
83
|
+
|
|
84
|
+
### Performance Comparison: Emissions
|
|
85
|
+
|
|
86
|
+
Basic emission performance across different subscriber counts:
|
|
87
|
+
|
|
88
|
+
| Scenario | EVG Observable | observable-fns | Advantage |
|
|
89
|
+
|----------|----------------|----------------|-----------|
|
|
90
|
+
| 1 emit × 1 subscriber | 57.2M ops/sec | 37.0M | **1.5x faster** |
|
|
91
|
+
| 1 emit × 10 subscribers | 17.1M ops/sec | 6.4M | **2.7x faster** |
|
|
92
|
+
| 1 emit × 100 subscribers | 2.1M ops/sec | 736K | **2.9x faster** |
|
|
93
|
+
| 1 emit × 1000 subscribers | 207K ops/sec | 73K | **2.8x faster** |
|
|
94
|
+
| 1 emit × 10000 subscribers | 18.7K ops/sec | 7.1K | **2.6x faster** |
|
|
95
|
+
| 100 emit × 1 subscriber | 1.2M ops/sec | 560K | **2.1x faster** |
|
|
96
|
+
| 100 emit × 100 subscribers | 21.6K ops/sec | 7.6K | **2.8x faster** |
|
|
97
|
+
| 1000 emit × 1000 subscribers | 215 ops/sec | 77 | **2.8x faster** |
|
|
98
|
+
| Large payload (complex objects) | 815K ops/sec | 557K | **1.5x faster** |
|
|
99
|
+
| Observable creation | 54.5M ops/sec | 17.9M | **3.0x faster** |
|
|
100
|
+
|
|
101
|
+
**Key Insights:**
|
|
102
|
+
- EVG Observable is consistently **1.5x-3.0x faster** across all emission scenarios
|
|
103
|
+
- Performance advantage remains stable from 1 to 10,000 subscribers
|
|
104
|
+
- Both libraries scale well for basic emission patterns
|
|
105
|
+
- EVG Observable's true hot observable architecture provides better performance for multi-subscriber scenarios
|
|
106
|
+
|
|
107
|
+
**When to choose EVG Observable:**
|
|
108
|
+
- Real-time data broadcasting (WebSocket, server events)
|
|
109
|
+
- Multiple active subscribers (2+)
|
|
110
|
+
- Performance-critical applications
|
|
111
|
+
- Hot observable patterns (subjects, event emitters)
|
|
112
|
+
|
|
113
|
+
**When to consider observable-fns:**
|
|
114
|
+
- Single subscriber scenarios
|
|
115
|
+
- Cold observable patterns (HTTP requests, async operations)
|
|
116
|
+
- Prefer functional programming style
|
|
117
|
+
- Need async filter/map handlers
|
|
118
|
+
|
|
119
|
+
*Full benchmark results including filter chains and transformations available in [benchmarks/benchmark-readme.md](./benchmarks/benchmark-readme.md)*
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
32
123
|
## What is EVG Observable?
|
|
33
124
|
|
|
34
125
|
EVG Observable is a robust, lightweight library designed for handling asynchronous events. What sets it apart is its
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "evg_observable",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.7",
|
|
4
4
|
"description": "Alternative fast and light library version - observable.",
|
|
5
5
|
"main": "src/outLib/index.js",
|
|
6
6
|
"types": "src/outLib/index.d.ts",
|
|
@@ -11,8 +11,11 @@
|
|
|
11
11
|
"test": "nyc ./node_modules/.bin/_mocha 'test/**/*.test.ts'",
|
|
12
12
|
"remove": "rm -rf ./src/Libraries; rm -rf ./test; rm .mocharc.json; rm .nyrc.json; rm register.js; rm tsconfig.json",
|
|
13
13
|
"build": "tsc --declaration; npm run remove",
|
|
14
|
-
"benchmark": "ts-node benchmark.ts",
|
|
15
|
-
"benchmark:comparison": "ts-node benchmark-comparison.ts"
|
|
14
|
+
"benchmark": "ts-node benchmarks/benchmark.ts",
|
|
15
|
+
"benchmark:comparison": "ts-node benchmarks/benchmark-comparison.ts",
|
|
16
|
+
"benchmark:competitors": "ts-node benchmarks/benchmark-competitors.ts",
|
|
17
|
+
"benchmark:browser": "ts-node benchmarks/benchmark-browser-bundle.ts",
|
|
18
|
+
"benchmark:bundles": "ts-node benchmarks/benchmark-bundles.ts"
|
|
16
19
|
},
|
|
17
20
|
"repository": {
|
|
18
21
|
"type": "git",
|
|
@@ -33,6 +36,7 @@
|
|
|
33
36
|
"microtime": "^3.1.1",
|
|
34
37
|
"mocha": "^11.7.5",
|
|
35
38
|
"nyc": "^17.1.0",
|
|
39
|
+
"observable-fns": "^0.6.1",
|
|
36
40
|
"rxjs": "^7.8.2",
|
|
37
41
|
"ts-node": "^10.9.1",
|
|
38
42
|
"typescript": "^5.4.5"
|
package/src/outLib/Collector.js
CHANGED
|
@@ -13,7 +13,7 @@ class Collector {
|
|
|
13
13
|
if (this.killed)
|
|
14
14
|
return;
|
|
15
15
|
subscriptionLike?.unsubscribe();
|
|
16
|
-
(0, FunctionLibs_1.
|
|
16
|
+
(0, FunctionLibs_1.deleteFromArray)(this.arr, subscriptionLike);
|
|
17
17
|
}
|
|
18
18
|
unsubscribeAll() {
|
|
19
19
|
if (this.killed)
|
package/src/outLib/Observable.js
CHANGED
|
@@ -41,7 +41,7 @@ class OrderedObservable extends Observable_1.Observable {
|
|
|
41
41
|
this.trash.push(listener);
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
this.subs && !(0, FunctionLibs_1.
|
|
44
|
+
this.subs && !(0, FunctionLibs_1.deleteFromArray)(this.subs, listener);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
exports.OrderedObservable = OrderedObservable;
|