diff options
author | Steven Guerrero <stephenguerrero43@gmail.com> | 2020-11-16 18:20:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-16 18:20:46 -0500 |
commit | 06cf6df954f0ab745bccb9455e7da14104acf1ae (patch) | |
tree | a790459dcd61ea7cc7ec3bc79aafdd05df19679f /std/node/_util.ts | |
parent | 636af2850c90f6bf7005a270d95b68bc9718de75 (diff) |
feat(std/node): Add util.deprecate (#8407)
Diffstat (limited to 'std/node/_util.ts')
-rw-r--r-- | std/node/_util.ts | 16 |
1 files changed, 16 insertions, 0 deletions
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<A extends Array<unknown>, 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 */ |