Promise implementations that can resolve synchronously or lazily: TSDNPromise, LazyPromise and promise collections.
npm install @tsdotnet/promisesimport { TSDNPromise } from '@tsdotnet/promises';
const total = TSDNPromise
.all(TSDNPromise.resolve(1), TSDNPromise.resolve(2))
.thenSynchronous(([a, b]) => a + b); // a promise of 3thenSynchronous skips the extra tick when the value is ready. LazyPromise defers its work until something asks for the result.
ESM (import { TSDNPromise, LazyPromise } from '@tsdotnet/promises';) or CommonJS (const { TSDNPromise, LazyPromise } = require('@tsdotnet/promises');). No <script> (UMD) build: use it with a bundler or Node.js.