-
Notifications
You must be signed in to change notification settings - Fork 0
How to Install
Install the streamlets
package (via NPM or yarn):
npm i streamlets
On modern browsers or Deno, you can directly import it from Skypack:
<!-- browser -->
<script type="module">
import { pipe, interval, tap, observe } from 'https://cdn.skypack.dev/streamlets'
// ...
</script>
// deno
import { pipe, interval, tap, observe } from 'https://cdn.skypack.dev/streamlets'
// ...
👉 IMPORTANT
For use in production, always use a pinned URL. You can generate one by opening this link.
Some utilities depend on AbortController
. It is already implemented in most modern browsers, in Deno and in Node 15.0.0 upwards. For older environments, you can use this polyfill. If your Node version is under 14.5.0, you also would need a polyfill for EventTarget
:
npm i event-target-polyfill yet-another-abortcontroller-polyfill
import 'event-target-polyfill'
import 'yet-another-abortcontroller-polyfill'
// ...
Additionally, fetch()
utility relies on the native fetch()
, which is absent from Node. You can use isomorphic-fetch
to bridge that gap:
npm i isomorphic-fetch
import 'isomorphic-fetch'
// ...
You can also get the bundle from a CDN like UNPKG, though this method is only recommended for browsers not supporting JavaScript Modules (which are pretty rare):
<script src="https://unpkg.com/streamlets/dist/bundles/streamlet.es5.min.js"></script>
<script>
const {
interval, pipe, tap, startWith, observe,
} = streamlet
// ...
</script>
In such an environment, you will also need all of these polyfills.