concurrency-primitives
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Concurrency Primitives

Simple, functional concurrency primitives

Usage

type Action = {
  action: 'greet'
  name: string
} | {
  action: 'farewell'
  when: string
}

async function run(action: Action) {
  switch (action.action) {
    case 'greet':
      console.log(`Hi, ${action.name}!`)
      break
    case 'farewell':
      console.log(`See you ${when}!`)
      break
  }
}

const { enqueue, queue } = Queue(run)

enqueue({ action: 'greet', name: 'Bobby' })
enqueue({ action: 'farewell', when: 'in 1992' })

Readme

Keywords

none

Package Sidebar

Install

npm i concurrency-primitives

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

32.1 kB

Total Files

21

Last publish

Collaborators

  • moveread