![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@dirkluijk/promise-stream
Advanced tools
A stream-like promise that emits multiple values over time
A simple building block that behaves like a regular Promise<T>
, but can emit multiple values over time.
Like regular promises, a PromiseStream<T>
is not cancellable, is hot, shared, and will replay the last value.
Furthermore, no built-in operator support (like map or flatMap) is currently provided.
The limitations are intended. For extensive reactive apps I would recommend to use RxJS instead.
npm install @dirkluijk/promise-stream
PromiseStream<T>
This works the same as a regular Promise
, but you have three callbacks: next
, complete
and error
.
import { PromiseStream } from '@dirkluijk/promise-stream';
const myStream = new PromiseStream<string>((next, complete, error) => {
next('foo');
next('bar');
next('baz');
complete();
})
next
always expects a valuecomplete
never expects a valueerror
accepts an optional error valuePromiseStream<T>
You can use callbacks:
myStream
.iterate(value => {
// executed when value is emitted
})
.then(() => {
// executed when completed
})
.catch((error) => {
// executed when failed
})
Since a PromiseStream
invokes the .then()
callback upon completion, it is compatible with async/await:
try {
await myStream.iterate(value => {
// executed when value is emitted
});
} catch (error) {
// executed when failed
}
// executed when completed
Additionally, you can also use the async iterator:
try {
for await (const value of myStream.asyncIterator()) {
// executed when value is emitted
};
} catch (error) {
// executed when failed
}
// executed when completed
FAQs
A stream-like Promise for JavaScript
We found that @dirkluijk/promise-stream demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.