2.0.0 • Published 2 months ago

async-utility v2.0.0

Weekly downloads
214
License
ISC
Repository
github
Last release
2 months ago

async-utility

npm package npm downloads GitHub test GitHub issues GitHub license

Utility to convert async function to sync function, execute async function synchronously & resolve promise synchronously.

Install via NPM

npm install async-utility

Usage

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);
2.0.0

2 months ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

2 years ago

1.4.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.4

3 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago