thromise 1.4.0
Install from the command line:
Learn more about npm packages
$ npm install @qiwi/thromise@1.4.0
Install via package.json:
"@qiwi/thromise": "1.4.0"
About this version
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
yarn add thromise
import { loop } from 'thromise'
const a = v => new Promise(resolve => setTimeout(() => resolve(v), Math.random() * 1000))
const b = v => v
loop((a, b) => {
const [_a, _b] = t(a, b)
console.log(
'Looks synchronous:',
_a('foo'),
_b('quz'),
_a('bar'),
_a('baz'),
)
})
// or a bit shorter:
loop((a, b) => {
console.log(
'Looks synchronous:',
_a('foo'),
_b('quz'),
_a('bar'),
_a('baz'),
)
}, a, b)