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

1.5.2 • Public • Published

thromise

CI Test Coverage

The Ugly.

const a = fn('foo')
  .then(r => b(r, 'bar')
    .then(/* ... */))

The Bad.

const a = await fn('foo')
const b = await fn(a, 'bar')

The good.

const a = fn('foo')
const b = fn(a, 'bar')

This is just our in-joke in the context of the Java vs JavaScript holywar

Install

yarn add thromise

Usage

import { loop } from 'thromise'

const a = v => new Promise(resolve => setTimeout(() => resolve(v), Math.random() * 1000))
const b = v => v

await loop(t => {
  const [_a, _b] = t(a, b)

  console.log(
    'Looks synchronous:',
    _a('foo'),
    _b('quz'),
    _a('bar'),
    _a('baz'),
  )
  
  return 'result'
})

// or even a bit shorter:

loop((a, b) => {
  console.log(
    'Looks synchronous:',
    a('foo'),
    b('quz'),
    a('bar'),
    a('baz'),
  )
}, a, b)

License

MIT

Package Sidebar

Install

npm i thromise

Weekly Downloads

0

Version

1.5.2

License

MIT

Unpacked Size

5.36 kB

Total Files

6

Last publish

Collaborators

  • qiwibot