
Security News
The Next Open Source Security Race: Triage at Machine Speed
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.
Observable (reactive streams) pattern implemented using es2015 async generators.
Using yarn:
yarn add obgen
or using npm:
npm i --save obgen
Observables are lazy streams of data that emit items asynchronously. They may be infinite or include an optional terminal event to signal the end of the stream. You can map, filter, etc.:
import Observable from "obgen";
import {
asyncDefer,
buffer,
empty,
from,
just,
promise,
wrap,
} from "obgen/factoryFunctions";
const arr = [...Array(num).keys()].map((_, i) => i);
const observable = from(arr)
.map((i) => i * 2)
.filter((i) => i % 2 == 0)
.take(10);
Observables are lazily evaluated. Items are not collected until you subscribe to them:
observable.subscribe(console.log);
// outputs:
// 0
// 2
// 4
// 6
// 8
// 10
// 12
// 14
// 16
// 18
If you prefer, you can instead iterate it with for-await as you normally would:
for await (const element of observable.iterable()) {
console.log(element);
}
Or collect the items into an array:
const array = await observable.toArray();
Observables can be created in multiple ways. For example, you can manually wrap an async generator function (which is not particularly useful by itself):
const observable = wrap(async function* () {
yield "a";
yield "b";
yield "c";
});
You can also use buffer() to accumulate items until subscription time:
const observable = buffer((stream) => {
stream.emit(1);
stream.emit(2);
stream.emit(3);
stream.emit(4);
stream.end();
});
Or asynchronously emit items:
const observable = buffer((stream) => {
// delay emission for a few milliseconds so that it happens after we subscribe
times(5, (i) => setTimeout(() => stream.emit(i), i * 100));
setTimeout(() => stream.end(), 600);
});
expect(await observable.toArray()).toEqual([0, 1, 2, 3, 4]);
MIT
FAQs
Javascript Observables implemented with async generators
The npm package obgen receives a total of 18 weekly downloads. As such, obgen popularity was classified as not popular.
We found that obgen demonstrated a not healthy version release cadence and project activity because the last version was released 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
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.

Research
/Security News
Malicious dYdX client packages were published to npm and PyPI after a maintainer compromise, enabling wallet credential theft and remote code execution.

Security News
gem.coop is testing registry-level dependency cooldowns to limit exposure during the brief window when malicious gems are most likely to spread.