Skip to main content
Deno 2 is finally here 🎉️
Learn more

Async Channels

Latest Version Test & Release codecov nodejs minimum version License: GPL v3

Channels are queue-like objects (First In First Out) that their enqueue (send) and dequeue (get) functions are asynchronous (async). By passing them between asynchronous functions we can synchronize operations between said functions.

Setup

NodeJS

Released under both npmjs & github packages:

npmjs.com:@eyalsh/async_channels github.com:@Eyal-Shalev/async_channels

Install:

npm
npm install @eyalsh/async_channels
yarn
yarn add @eyal-shalev/async_channels

import (ES Modules):

import { Channel } from "@eyalsh/async_channels";

require (CommonJS):

const { Channel } = require("@eyalsh/async_channels");

Deno

The library is available to import from deno.land/x/async_channels

import { Channel } from "https://deno.land/x/async_channels/mod.ts";

Browser - CDN / Download

You can import the library from any CDN that mirrors npmjs.com, such as skypack.dev or unpkg.com.

import { Channel } from "https://cdn.skypack.dev/@eyalsh/async_channels";

Or you can download compiled library from GitHub:

import { Channel } from "/path/to/async_channels.esm.js";

Note: an IIFE version also exist, if your application doesn’t support ES modules.

<script src="/path/to/async_channels.iife.js"></script>
<script>
  const {Channel} = async_channels;
</script>

Examples