Gathering detailed insights and metrics for @andywer/observable-fns
Gathering detailed insights and metrics for @andywer/observable-fns
Gathering detailed insights and metrics for @andywer/observable-fns
Gathering detailed insights and metrics for @andywer/observable-fns
🕵️♀️ Light-weight observable implementation and functional utilities in TypeScript
npm install @andywer/observable-fns
Typescript
Module System
Node Version
NPM Version
74.8
Supply Chain
95.3
Quality
75.2
Maintenance
100
Vulnerability
100
License
TypeScript (97.71%)
JavaScript (2.29%)
Total Downloads
1,727
Last Day
1
Last Week
8
Last Month
18
Last Year
242
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.3.1
Package Id
@andywer/observable-fns@0.3.1
Unpacked Size
79.27 kB
Size
17.04 kB
File Count
63
NPM Version
6.9.0
Node Version
10.16.3
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
33.3%
8
Compared to previous week
Last Month
-70%
18
Compared to previous month
Last Year
-21.9%
242
Compared to previous year
7
Light-weight observable implementation (< 7kB minified) and utils. Based on zen-observable
, re-implemented in TypeScript including .pipe()
and .tap()
. Zero dependencies, tree-shakeable.
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 different values repeatedly. They can also fail and yield an error, like a promise, and they come with a completion event to indicate that the last value has been sent.
For a quick introduction on how to use observables, check out the zen-observable readme.
1import { Observable, multicast } from "@andywer/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 .subscribe(event => console.log("Server sent event:", event))
Keep the observable implementation itself lean, ship the utility functions loosely coupled, so they can be imported as needed.
The aim is to provide a lean, friendly observable implementation with a small footprint that's fit to be used in libraries.
npm install @andywer/observable-fns
You can import whatever you need directly from the package:
1import { Observable, flatMap } from "@andywer/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 "@andywer/observable-fns/observable" 2import flatMap from "@andywer/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 "@andywer/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