Registry / concurrency / spica
library0.0.810jsnpmunverified

A JavaScript/TypeScript library providing concurrency primitives (Coroutine, Channel, select, AtomicPromise, Cancellation), functional utilities (Maybe, Either, Sequence, Cache), and data structures (List, Queue, Stack, MultiMap). Current stable version is 0.0.810, with ongoing active development. It focuses on structured concurrency and monadic patterns, offering Supervisor-based error handling and cancellation. Differentiators include a unique channel-based coroutine system and a wide range of utility modules in a single package. Targeted at modern browsers (Chrome, Firefox, Edge Chromium) and Node.js environments.

npm install spica
INSTALL
IMPORT
SIG · SPICA
S
spica
concurrencyjavascriptv0.0.810
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.

Coroutine
import { Coroutine } from 'spica'
const Coroutine = require('spica').Coroutine
ESM-only, named export; no default export.
select
import { select } from 'spica'
import select from 'spica/select'
Available as a named export from 'spica'; not a subpath.
Maybe
import { Maybe } from 'spica'
const Maybe = require('spica/maybe')
ESM-only; use named import.

Demonstrates creating a Channel, sending a value, using select to receive from channel with a timeout, and executing within a Supervisor.

import { Channel, select, Coroutine, Supervisor } from 'spica'; // Create a channel of numbers const ch = new Channel<number>(); // Send a value ch.send(42); // Receive using select async function main() { const result = await select([ { channel: ch, handler: (v) => `Received: ${v}` }, { timeout: 100, handler: () => 'Timeout' }, ]); console.log(result); } // Run with supervisor for error handling const supervisor = new Supervisor(); supervisor.execute(() => main());
Debug
Known issues
gotchaCoroutine and Channel are not based on Promises; mixing with native async/await may cause unexpected behavior.
fix
Use provided primitives consistently; avoid combining with raw Promise constructs unless converted via AtomicPromise.
affects: >=0.0.0
breakingThe 'spica/cache' subpath module was removed in favor of importing from 'spica' directly.
fix
Change import { Cache } from 'spica/cache' to import { Cache } from 'spica'.
affects: >=0.0.800
deprecatedThe 'Observer' class is deprecated and will be replaced by 'Coaggregator' in future versions.
fix
Migrate usage from Observer to Coaggregator.
affects: >=0.0.800
gotchaOnly ESM imports are supported; using CommonJS require() will result in undefined values.
fix
Use ES module imports (import statements) or upgrade to a version that supports CJS (if available).
affects: >=0.0.800
breakingThe 'Sequence' class API changed: next() now returns { value: T, done: boolean } instead of a Promise.
fix
Update code to handle synchronous iteration results.
affects: >=0.0.600
Errors
Common errors & fixes
Error: Cannot find module 'spica/cache'
Import path changed from subpath to main module.
fix
Use import { Cache } from 'spica' instead of import { Cache } from 'spica/cache'.
TypeError: Coroutine is not a constructor
Using CommonJS require() instead of ESM import.
fix
Ensure you are using ES module import statements: import { Coroutine } from 'spica'.
TypeError: Cannot read properties of undefined (reading 'send')
Instantiated Channel before importing the library properly.
fix
Verify the import path and ensure the library is correctly installed and imported.
Upgrade
Version history
0.0.810latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
4
Amazon
1
Resources
packagespica
spica — npm install spica · libregistry