{"id":46427,"library":"spica","title":"Spica","description":"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.","status":"active","version":"0.0.810","language":"javascript","source_language":"en","source_url":"https://github.com/falsandtru/spica","tags":["javascript","supervisor","observer","coroutine","channel","select","cancellation","sequence","maybe"],"install":[{"cmd":"npm install spica","lang":"bash","label":"npm"},{"cmd":"yarn add spica","lang":"bash","label":"yarn"},{"cmd":"pnpm add spica","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only, named export; no default export.","wrong":"const Coroutine = require('spica').Coroutine","symbol":"Coroutine","correct":"import { Coroutine } from 'spica'"},{"note":"Available as a named export from 'spica'; not a subpath.","wrong":"import select from 'spica/select'","symbol":"select","correct":"import { select } from 'spica'"},{"note":"ESM-only; use named import.","wrong":"const Maybe = require('spica/maybe')","symbol":"Maybe","correct":"import { Maybe } from 'spica'"}],"quickstart":{"code":"import { Channel, select, Coroutine, Supervisor } from 'spica';\n\n// Create a channel of numbers\nconst ch = new Channel<number>();\n\n// Send a value\nch.send(42);\n\n// Receive using select\nasync function main() {\n  const result = await select([\n    { channel: ch, handler: (v) => `Received: ${v}` },\n    { timeout: 100, handler: () => 'Timeout' },\n  ]);\n  console.log(result);\n}\n\n// Run with supervisor for error handling\nconst supervisor = new Supervisor();\nsupervisor.execute(() => main());","lang":"typescript","description":"Demonstrates creating a Channel, sending a value, using select to receive from channel with a timeout, and executing within a Supervisor."},"warnings":[{"fix":"Use provided primitives consistently; avoid combining with raw Promise constructs unless converted via AtomicPromise.","message":"Coroutine and Channel are not based on Promises; mixing with native async/await may cause unexpected behavior.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Change import { Cache } from 'spica/cache' to import { Cache } from 'spica'.","message":"The 'spica/cache' subpath module was removed in favor of importing from 'spica' directly.","severity":"breaking","affected_versions":">=0.0.800"},{"fix":"Migrate usage from Observer to Coaggregator.","message":"The 'Observer' class is deprecated and will be replaced by 'Coaggregator' in future versions.","severity":"deprecated","affected_versions":">=0.0.800"},{"fix":"Use ES module imports (import statements) or upgrade to a version that supports CJS (if available).","message":"Only ESM imports are supported; using CommonJS require() will result in undefined values.","severity":"gotcha","affected_versions":">=0.0.800"},{"fix":"Update code to handle synchronous iteration results.","message":"The 'Sequence' class API changed: next() now returns { value: T, done: boolean } instead of a Promise.","severity":"breaking","affected_versions":">=0.0.600"}],"env_vars":null,"search_vec":"'0.0.810':30 'activ':33 'atomicpromis':11 'base':46,57 'browser':74 'cach':18 'cancel':12,50,88 'channel':9,56,86 'channel-bas':55 'chrome':75 'chromium':78 'concurr':6,39 'coroutin':8,58,85 'current':26 'data':20 'develop':34 'differenti':51 'edg':77 'either':16 'environ':81 'error':47 'firefox':76 'focus':36 'function':13 'handl':48 'includ':52 'javascript':82 'javascript/typescript':3 'librari':4 'list':22 'mayb':15,90 'modern':73 'modul':66 'monad':41 'multimap':25 'node.js':80 'observ':84 'offer':43 'ongo':32 'packag':70 'pattern':42 'primit':7 'provid':5 'queue':23 'rang':63 'select':10,87 'sequenc':17,89 'singl':69 'spica':1 'stabl':27 'stack':24 'structur':21,38 'supervisor':45,83 'supervisor-bas':44 'system':59 'target':71 'uniqu':54 'util':14,65 'version':28 'wide':62","created_at":"2026-06-07T12:59:52.016055+00:00","updated_at":"2026-06-07T12:59:52.016055+00:00","problems":[{"fix":"Use import { Cache } from 'spica' instead of import { Cache } from 'spica/cache'.","cause":"Import path changed from subpath to main module.","error":"Error: Cannot find module 'spica/cache'"},{"fix":"Ensure you are using ES module import statements: import { Coroutine } from 'spica'.","cause":"Using CommonJS require() instead of ESM import.","error":"TypeError: Coroutine is not a constructor"},{"fix":"Verify the import path and ensure the library is correctly installed and imported.","cause":"Instantiated Channel before importing the library properly.","error":"TypeError: Cannot read properties of undefined (reading 'send')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/falsandtru/spica","github":"https://github.com/falsandtru/spica","docs":null,"changelog":null,"pypi":null,"npm":"spica","openapi_spec":null,"status_page":null,"smithery":null,"categories":["concurrency"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}