Skip to content

co

A small JavaScript helper for running generator functions as async control flow.

Stars
11.8k
Forks
780
Licence
MIT
Language
JavaScript
Last update
5.9 years ago
Type
Library

No commits in over a year — check for forks or alternatives before adopting.

What it is

co is a JavaScript library that lets you write asynchronous code in a sequential style by running generator functions and resolving the values they yield, such as thunks and promises. The description says it supports thunks, promises, and similar patterns. It is aimed at Node.js developers who want to flatten callback-heavy or promise-chained code.

  • Wrapping a generator function with co so it runs to completion and returns a promise
  • Yielding promises or thunks inside a generator to write sequential-looking async logic
  • Maintaining an existing codebase that depends on generator-based flow control

Great for

  • Node.js developers maintaining code that already uses generator functions
  • Developers reading or migrating older async code written around co-style generators
  • Developers who want a minimal helper rather than a full framework

Not ideal for

  • Projects using modern async/await, since native syntax covers the same need (general reasoning, not stated in the README)
  • Anyone who needs documentation or a README that explains usage, since the provided README text is empty
Step-by-step guide: how to use coInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js

    Clone the repository

    git clone https://github.com/tj/co
  2. 2

    Run it

    • Install or clone the package from the repository
    • Write a generator function that yields promises or thunks
    • Pass the generator to co and handle the returned promise
  3. 3

    Get the most out of it

    • Read the repository source and tests for the supported yieldable types
    • Compare against native async/await before adopting co in new code

Downloads

Strengths

  • Simple, focused purpose: one job of running generator-based async flow
  • Widely starred on GitHub, indicating broad past adoption
  • Released under the permissive MIT license

Trade-offs

  • The last push was in December 2020 and no releases are listed, so maintenance status is unclear
  • The README provided here is empty, so usage details could not be verified
  • Generator-based flow control has been largely superseded by native async/await in modern JavaScript

How it compares

ProjectStarsTypeLevelUpdatedBest for
co (this)11.8kLibraryintermediate5.9 years agoNode.js developers maintaining code that already uses generator functions
bluebird20.5kLibrarybeginner2.0 years agoMaintainers of legacy codebases that already depend on Bluebird
async28.1kLibraryintermediate5 days agoJavaScript developers who need to run many asynchronous operations over a collection of items

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.