@webreflection/lie
An optionally sync promise that directly passes along its value, particularly useful for any API that handles both synchronous and asynchronous use cases through explicit .then(...)
invocation.
import lie from '@webreflection/lie';
lie(123)
.then(value => {
console.log('sync #1', value);
return value * 2;
})
.then(async value => {
console.log('sync #2', value);
return value * 2;
})
.then(value => {
console.log('async #1', value);
})
;
console.log('sync #1 and #2 already logged');
Note: a lie(Promise.resolve(123))
, a lie(lie(123))
, or even a lie({ then: able })
would simply pass through as result the provided value, as opposite of creating "lies of lies".