Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experiment] Move package to Deno first #12

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

lucacasonato
Copy link

@lucacasonato lucacasonato commented Dec 29, 2021

As a prelude: I realize this is a very invasive change. If you are not
interested, feel free to just close the PR. I mostly did this to get a feel for
what our current state of Node->Deno and Deno->NPM tooling is like (I ran out of
own packages to convert 🙃).


What?

This PR moves the observables-with-streams package to be written for "Deno
first". This means that the TypeScript used is "Deno flavored", i.e. with
.ts extensions.

The tests were moved over to Deno.test and
https://deno.land/std/testing/asserts.ts. They now run in Deno rather than in
a browser. The streams implementation in Deno is just as (or more) correct than
Chrome, so the tests are still passing :-).
Proof.

How?

  • All code in src/ has had its .ts extensions added in imports
  • In tests/ the Mocha.* calls have been replaced with Deno.test.
  • In tests/ the chai asserts have been replaced with simple assert and
    assertEquals from std/testing/asserts.ts.
  • src/sources/from-timer.ts has been updated to clear the interval when the
    stream is closed to appease Deno's test sanitizers. (Fixes fromTimer does not stop interval when observable is cancelled #13)
  • CI has been moved to GitHub Actions
  • Formatting has been moved to deno fmt
  • Utility scripts now use make rather than npm run
  • A build.ts script was added that generates a dist/ folder from the source
    code. It uses dnt to generate the plain JS
    ESM code and type declaration files. Rollup is then used to generate the
    dist/dist/really-big-bundle.js.
  • Publishing instructions added to CONTRIBUTING
    1. Bump version in build.ts
    2. make build
    3. cd dist && npm publish
    4. Tag the release in Git (e.g. git tag v1.0.0)
  • Removed a bunch of config files that are now not needed anymore

What's next?

After merging this PR (if you want to), you should register
https://deno.land/x/observables-with-streams and create a new release. This will
make it easier for Deno users to use the package.

Docs on Netlify can be disabled after this change too, as docs can now be viewed
on doc.deno.land. Example: https://doc.deno.land/https://raw.githubusercontent.com/surma/observables-with-streams/28c55be6d855780c677fd1f4ba975f4d3144891d/src/index.ts

@danopia
Copy link

danopia commented Apr 3, 2023

Just noting that I have a port of this at https://deno.land/x/stream_observables. My fork differs a bit in a couple other ways too e.g. I replaced fromIterable with Deno's readableStreamFromIterable to gain async support.

Anyway, I just want to note how useful observables-with-streams has been for building reactive programs in Deno :) I've used it numerous times over the past year.

For example I just put together a filesystem watch debounce with only a couple lines of code:

    ows.fromIterable(Deno.watchFs(folder))
      .pipeThrough(ows.filter(x => x.kind == 'modify'))
      .pipeThrough(ows.debounce(250))
      .pipeTo(ows.subscribe(reloadFromFs));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fromTimer does not stop interval when observable is cancelled
2 participants