Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.64 KB

README.md

File metadata and controls

55 lines (40 loc) · 1.64 KB

This module is a Deno-friendly port of observables-with-streams.

Published to jsr.io as @cloudydeno/stream-observables. Read more about using packages.

Published to /x/ as stream_observables. Import from https://deno.land/x/[email protected]/.

Subset of original README below:

Observables with Streams

A library for observables built with WHATWG streams. This library is inspired by ReactiveX’s operators and implements a subset of them using streams.

The goal of this library is to implement observables making as much use of the platform as possible and being highly tree-shakeable.

Example

import * as ows from "jsr:@cloudydeno/stream-observables@^1.4.0";

console.log('Tap Enter to add energy!');
ows.merge(
  ows.fromTimer(1000)
    .pipeThrough(ows.map(() => -1)),
  ows.fromIterable(Deno.stdin.readable)
    .pipeThrough(ows.map(() => 1)),
)
  .pipeThrough(
    ows.scan((v0, v1) => Math.max(v0 + v1, 0), 0)
  )
  .pipeThrough(
    ows.distinct()
  )
  .pipeTo(
    ows.subscribe(
      v => console.log('Energy:', v)
    )
  );

Documentation

The (somewhat lacking) documentation for the original library is hosted at https://observables-with-streams.surma.technology

Caveats

For a good primer about streams, read this blog post by Jake Archibald (he is aware the title hasn’t aged well).


License Apache 2.0