/async_channels

Inspired by Go & Clojure Channels, async_channels provides channels as an asynchronous communication method between asynchronous functions.

Primary LanguageTypeScriptGNU General Public License v3.0GPL-3.0

Async Channels

Latest Version Test 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:

  • Latest Release
  • All Releases
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