Skip to main content

Intro

flowp aims to provide promise based utilities with modern and simple interface.

  • 📦 Pure TypeScript and ready to run in Node.js, browsers and web workers

  • 🏙 Embrace promises and async/await syntax, no more callback hells

  • 🧱 Robust quality with tests focusing on coverage as well as race conditions

  • 🔰 Friendly documentation and examples

Why flowp?

Yet numerous libraries provide similar functionalities, like semaphores (to limit concurrency):

But many of them have more or less limitations such as CJS only or lack of some capabilities. This doesn't mean these are not good libraries, but there are no single library that meets the author's need, so he's writing himself.

Besides, flowp adds some extra primitives to make these components easy to use and debug.

Getting Started

Prerequisites

This package targets ES2020 (ES11) and requires Node.js v16+ (Compability table) or modern browser (Compability table) to run.

  • If you're using an transpiler, e.g. babel / esbuild / swc then everything's good 🚀
  • If you don't have one, you may need to upgrade your Node.js version or think if you really need to write an IE compatible site 😕

Installation

Use your favorite package manager to install this package:

npm install --save flowp

Start using flowp

Checkout async components you like or continue reading tutorial.

Extended promises

Provides functionalities that JavaScript's Promise don't yet have:

  • Future A promise that can be filled in results anywhere other than its definition
  • Progress A promise but with progress report

Promise helpers

Asynchronos control flows

These classes utilize JavaScript's Promise to

  • Semaphore Controls concurrent access to a common resource
  • Mutex Specialized Semaphore(1)
  • Channel Powerful asynchronos message queue
  • ChannelHub Broadcast messages to its every reader Channel

Experimental blackmagick

These features are not well tested in production environment, use with caution

  • delegate deletgate property access and function calls of a promise, powered by Proxy