Gathering detailed insights and metrics for observable-fns
Gathering detailed insights and metrics for observable-fns
Gathering detailed insights and metrics for observable-fns
Gathering detailed insights and metrics for observable-fns
🕵️♀️ Light-weight observable implementation and functional utilities in TypeScript
npm install observable-fns
Typescript
Module System
Node Version
NPM Version
TypeScript (97.71%)
JavaScript (2.29%)
Total Downloads
21,983,359
Last Day
34,102
Last Week
205,448
Last Month
837,390
Last Year
8,662,147
MIT License
46 Stars
68 Commits
1 Forks
2 Watchers
4 Branches
1 Contributors
Updated on Apr 24, 2025
Minified
Minified + Gzipped
Latest Version
0.6.1
Package Id
observable-fns@0.6.1
Unpacked Size
97.74 kB
Size
15.73 kB
File Count
88
NPM Version
6.14.11
Node Version
12.16.3
Cumulative downloads
Total Downloads
Last Day
21.1%
34,102
Compared to previous day
Last Week
7.8%
205,448
Compared to previous week
Last Month
5.7%
837,390
Compared to previous month
Last Year
59.9%
8,662,147
Compared to previous year
7
Light-weight Observable implementation and common toolbelt functions. Based on zen-observable
, re-implemented in TypeScript. Zero dependencies, tree-shakeable.
The aim is to provide a lean Observable implementation with a small footprint that's fit to be used in libraries as an alternative to the huge RxJS.
Find all the provided functions and constructors in the 👉 API Documentation
🧩 Composable functional streams
🚀 map(), filter() & friends support async handlers
🔩 Based on popular zen-observable
, re-implemented in TypeScript
🌳 Zero dependencies, tree-shakeable
npm install observable-fns
An observable is basically a stream of asynchronously emitted values that you can subscribe to. In a sense it is to the event emitter what the promise is to the callback.
The main difference to a promise is that a promise only resolves once, whereas observables can yield values repeatedly. They can also fail with an error, like a promise, and they come with a completion event to indicate that no more values will be send.
For a quick introduction on how to use observables, check out the zen-observable readme.
1import { Observable, multicast } from "observable-fns"
2
3function subscribeToServerSentEvents(url) {
4 // multicast() will make the observable "hot", so multiple
5 // subscribers will share the same event source
6 return multicast(new Observable(observer => {
7 const eventStream = new EventSource(url)
8
9 eventStream.addEventListener("message", message => observer.next(message))
10 eventStream.addEventListener("error", error => observer.error(error))
11
12 return () => eventStream.close()
13 }))
14}
15
16subscribeToServerSentEvents("http://localhost:3000/events")
17 .filter(event => !event.isStale)
18 .subscribe(event => console.log("Server sent event:", event))
You can import everything you need directly from the package:
1import { Observable, flatMap } from "observable-fns"
If you write front-end code and care about bundle size, you can either depend on tree-shaking or explicitly import just the parts that you need:
1import Observable from "observable-fns/observable" 2import flatMap from "observable-fns/flatMap"
Functions like filter()
, flatMap()
, map()
accept asynchronous handlers – this can be a big win compared to the usual methods on Observable.prototype
that only work with synchronous handlers.
Those functions will also make sure that the values are consistently emitted in the same order as the input observable emitted them.
1import { Observable, filter } from "observable-fns" 2 3const existingGitHubUsersObservable = Observable.from(["andywer", "bcdef", "charlie"]) 4 .pipe( 5 filter(async name => { 6 const response = await fetch(`https://github.com/${name}`) 7 return response.status === 200 8 }) 9 )
See docs/API.md for an overview of the full API.
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
6 existing vulnerabilities detected
Details
Reason
Found 0/14 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More