function tryGetNodeDeprecate ( ) { try { const util = require ( 'util' ) as typeof import ( 'util' ) ; return util . deprecate ; } catch { } } function createDeprecateCore ( ) { const emitWarning = typeof process === "object" && typeof process . emitWarning === "function" ? function emitWarning ( warning , type = "Warning" , ctor = emitWarning ) { process . emitWarning ( warning , type , ctor ) ; } : typeof Error . captureStackTrace === "function" ? function emitWarning ( warning , type = "Warning" , ctor = emitWarning ) { if ( typeof warning === "string" ) { warning = new Error ( warning ) ; warning . name = type ; } Error . captureStackTrace ( warning , ctor ) ; console . warn ( warning ) ; } : function emitWarning ( warning , type = "Warning" ) { if ( typeof warning === "string" ) { console . warn ( `${ type }:` , warning ) ; } else { console . warn ( warning ) ; } } ; return < T extends Function > ( fn , msg ) : T => { let warned = false ; function deprecated ( this , ... args ) { if ( ! warned ) { warned = true ; emitWarning ( msg , 'DeprecationWarning' , fn ) ; } return new . target ? Reflect . construct ( fn , args , new . target ) : fn . apply ( this , args ) ; } Object . setPrototypeOf ( deprecated , fn ) ; if ( fn . prototype ) deprecated . prototype = fn . prototype ; return deprecated as Function as typeof fn ; } ; } const deprecateCore = tryGetNodeDeprecate ( ) || createDeprecateCore ( ) ; internal export function deprecate < T extends Function > ( fn , message ) { return deprecateCore ( fn , message ) ; } internal export function deprecateProperty < T , K extends keyof T > ( target , key , message ) { let descriptor = Object . getOwnPropertyDescriptor ( target , key ) ; if ( descriptor && descriptor . configurable ) { let changed = false ; if ( descriptor . get ) { descriptor . get = deprecate ( descriptor . get , message ) ; changed = true ; } if ( descriptor . set ) { descriptor . set = deprecate ( descriptor . set , message ) ; changed = true ; } if ( typeof descriptor . value === "function" ) { descriptor . value = deprecate ( descriptor . value , message ) ; changed = true ; } if ( changed ) { Object . defineProperty ( target , key , descriptor ) ; } } return target ; }