0.0.2 • Published 7 months ago
async2sync2 v0.0.2
async2sync2
Project Introduction
async2sync2
is a tool that converts asynchronous functions into synchronous functions. It achieves synchronous execution of asynchronous functions by extracting the function source code into a separate JavaScript file and running it.
Installation
npm install async2sync2
Usage
const { async2sync2 } = require('async2sync2');
const asyncFn = async (a, b) => {
return a + b;
};
const result = async2sync2(asyncFn)(1, 2);
console.log(result); // Output: 3
Configuration Options
tempDir
: Temporary file storage directoryclearTemp
: Whether to clear temporary files, default istrue
returnDetail
: Whether to return detailed information, default isfalse
cb
: Error callback function
Here is an example using all configuration options:
const asyncFn = async (a, b) => {
return a + b
}
const { res } = async2sync2(asyncFn, {
returnDetail: true,
})(1, 2)
expect(res).toStrictEqual(3)
Running Tests
npm test
License
MIT
0.0.2
7 months ago