Utility to convert async function to sync function, execute async function synchronously & resolve promise synchronously.
npm install async-utility
import { toSync, executeSync, resolveSync } from 'async-utility';
let result: number;
const asyncFn = (a: number, b: number): Promise<number> => new Promise(resolve => resolve(a + b));
// Convert async function to sync function
const syncFn = toSync(asyncFn);
result = syncFn(1, 2);
// Execute async function synchronously
result = executeSync(() => asyncFn(1, 2));
// Resolve promise synchronously
const promise = asyncFn(1, 2);
result = resolveSync(promise);