Registry / workflow / futoin-asyncsteps

futoin-asyncsteps

JSON →
library2.5.6jsnpmunverified

FutoIn AsyncSteps mimics traditional threads of execution in a single-threaded event loop, supporting cancellation, exit handlers, thread-local storage, and synchronization primitives like mutexes and throttles. Current stable version is 2.5.6, released under a stable maturity (status 3). It builds on the FTN12: FutoIn Async API v1.13 specification. Key differentiators include explicit step-based control flow (add, parallel, error handling) rather than Promises or async/await, though it integrates with Promises via as.await(). It is designed for both Node.js (>=8) and browser environments, providing ES5 CJS modules under es5/ and pre-built webpack dists under dist/. Synchronization primitives like Mutex are available for coordinated concurrent execution.

npm install futoin-asyncsteps
INSTALL
IMPORT
SIG · FUTOIN-ASYNCSTEPS
F
futoin-asyncsteps
workflowjavascriptv2.5.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

$as
import $as from 'futoin-asyncsteps'
const $as = require('futoin-asyncsteps').default
Default export is a factory function returning AsyncSteps instance. In CommonJS, use require('futoin-asyncsteps') directly.
AsyncSteps
import { AsyncSteps } from 'futoin-asyncsteps'
import AsyncSteps from 'futoin-asyncsteps'
AsyncSteps is a named export, not default. In CommonJS: const { AsyncSteps } = require('futoin-asyncsteps').
Mutex
import { Mutex } from 'futoin-asyncsteps'
const Mutex = require('futoin-asyncsteps').Mutex
Mutex is a named export. In browser, it may require WeakMap polyfill.
$as (browser)
<script src='dist/futoin-asyncsteps.min.js'></script>... $as(...)
import $as from 'futoin-asyncsteps' in non-module script
In browser, $as is a global; no import needed. Use script tag loading the dist.

Shows basic step execution chain with add() and success().

const $as = require('futoin-asyncsteps'); const root = $as(); root.add((as) => { console.log('Step 1'); as.success('done'); }).add((as, result) => { console.log('Step 2 received:', result); as.success(); }); root.execute();
Debug
Known issues
gotchaCalling as.success() more than once or after as.error() in a step causes undefined behavior.
fix
Ensure exactly one call to as.success() or as.error() per step (or none for implicit success).
affects: >=2.0
gotchaSynchronization primitives (Mutex, Throttle) require WeakMap polyfill in older browsers.
fix
Include dist/polyfill-asyncsteps.js before using Sync primitives in legacy browsers.
affects: >=2.0
gotchaThe as.state object is shared among all steps in the same AsyncSteps instance; mutations persist across steps.
fix
Use as.state for cross-step data, but be aware of unintended sharing when passing AsyncSteps instances or creating nested scopes.
affects: >=2.0
gotchaUsing as.await() with a rejected Promise will trigger error handling in the AsyncSteps flow, not throw an unhandled rejection.
fix
Ensure error handling steps are added after as.await() to catch rejections.
affects: >=2.0
gotchaParallel step results are not automatically merged; you must store results in as.state manually inside each parallel branch.
fix
Assign to as.state inside each parallel add() callback to collect outputs.
affects: >=2.0
Errors
Common errors & fixes
TypeError: $as is not a function
Imported default incorrectly (e.g., import { $as } instead of import $as).
fix
Use `import $as from 'futoin-asyncsteps'` or `const $as = require('futoin-asyncsteps')`.
Cannot find module 'futoin-asyncsteps'
Package not installed or wrong path in require/import.
fix
Run `npm install futoin-asyncsteps` and ensure import path is correct.
as.success is not a function
Calling as.success outside of a step callback (e.g., in the root scope or after step ends).
fix
Only call as.success() inside a step function passed to add(), parallel().add(), etc.
Upgrade
Version history
2.5.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
futoin-asyncsteps — npm install futoin-asyncsteps · libregistry