Skip to main content

Function: deprecatedAlias()

deprecatedAlias(target, name, replacement): DeprecatedAlias

Defined in: src/core/deprecation.ts:105

Wrap target under its pre-v4 name: same behaviour, plus ONE DeprecationWarning per name per process naming replacement.

Parameters​

target​

WrapperFn

The v4 wrapper to forward to.

name​

string

The pre-v4 name the caller uses; becomes fn.name and the warn-once key "name:<name>".

replacement​

string

The v4 name the warning tells the caller to use instead.

Returns​

DeprecatedAlias

A DeprecatedAlias: (params?) => target(params) with deprecatedAliasOf and replacement attached.

Example​

import { deprecatedAlias } from './core/deprecation.js';

const espnNflAthleteBio = deprecatedAlias(espnNflPlayerBio, 'espnNflAthleteBio', 'espnNflPlayerBio');
await espnNflAthleteBio({ athleteId: 3139477 }); // warns once (code SDV_DEPRECATED_NAME), then forwards

Remarks​

The warning is emitted through warnOnce with type: "DeprecationWarning" and code: DEPRECATED_NAME_CODE, on the first call only; the forward itself is unchanged.