From 02c65fad45898b79ef9614319061d19d24cfb9ce Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Thu, 1 Feb 2024 08:51:10 +0530 Subject: fix(node): `util.callbackify` (#22200) Fixes https://github.com/denoland/deno/issues/22180 Matches the Node.js implementation more closely. Removed types, they do not help just make it harder to debug with stack traces. --- cli/tests/unit_node/util_test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'cli/tests/unit_node/util_test.ts') diff --git a/cli/tests/unit_node/util_test.ts b/cli/tests/unit_node/util_test.ts index 2e2bb0021..a88128ee9 100644 --- a/cli/tests/unit_node/util_test.ts +++ b/cli/tests/unit_node/util_test.ts @@ -292,3 +292,26 @@ Deno.test({ fn(); }, }); + +Deno.test({ + name: "[util] callbackify() works", + fn() { + const fn = util.callbackify(() => Promise.resolve("foo")); + fn((err, value) => { + assert(err === null); + assert(value === "foo"); + }); + }, +}); + +Deno.test({ + name: "[util] callbackify(undefined) throws", + fn() { + assertThrows( + // @ts-expect-error: testing runtime error + () => util.callbackify(undefined), + TypeError, + 'The "original" argument must be of type function', + ); + }, +}); -- cgit v1.2.3