From 06cf6df954f0ab745bccb9455e7da14104acf1ae Mon Sep 17 00:00:00 2001 From: Steven Guerrero Date: Mon, 16 Nov 2020 18:20:46 -0500 Subject: feat(std/node): Add util.deprecate (#8407) --- std/node/_util.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'std/node/_util.ts') diff --git a/std/node/_util.ts b/std/node/_util.ts index 9cf996670..b21743541 100644 --- a/std/node/_util.ts +++ b/std/node/_util.ts @@ -123,6 +123,22 @@ export function getSystemErrorName(code: number): string | undefined { return errorMap.get(code)?.[0]; } +/** + * https://nodejs.org/api/util.html#util_util_deprecate_fn_msg_code + * @param _code This implementation of deprecate won't apply the deprecation code + */ +export function deprecate, B>( + this: unknown, + callback: (...args: A) => B, + msg: string, + _code?: string, +) { + return function (this: unknown, ...args: A) { + console.warn(msg); + return callback.apply(this, args); + }; +} + import { _TextDecoder, _TextEncoder } from "./_utils.ts"; /** The global TextDecoder */ -- cgit v1.2.3