Created
July 15, 2024 19:43
-
-
Save devsheva/4258784c77651fe1b7080449b0052350 to your computer and use it in GitHub Desktop.
(Deno.test): Improve Factory Object for async ops
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function promisifyFactoryObj<TFactory>( | |
obj: TFactory, | |
status = 200, | |
): Promise<Response> { | |
return Promise.resolve( | |
new Response(JSON.stringify(obj), { status }), | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of use case could be when needing to mock an API response.
It can work with a single obj, or an array.