observables-with-streams
observables-with-streams copied to clipboard
[Experiment] Move package to Deno first
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.tsextensions added in imports - In
tests/theMocha.*calls have been replaced withDeno.test. - In
tests/the chai asserts have been replaced with simpleassertandassertEqualsfromstd/testing/asserts.ts. src/sources/from-timer.tshas been updated to clear the interval when the stream is closed to appease Deno's test sanitizers. (Fixes #13)- CI has been moved to GitHub Actions
- Formatting has been moved to
deno fmt - Utility scripts now use
makerather thannpm run - A
build.tsscript was added that generates adist/folder from the source code. It usesdntto generate the plain JS ESM code and type declaration files. Rollup is then used to generate thedist/dist/really-big-bundle.js. - Publishing instructions added to
CONTRIBUTING- Bump version in build.ts
make buildcd dist && npm publish- 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
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));