Skip to main content

Function: withDeprecatedAliases()

withDeprecatedAliases(mod, aliases?): Record<string, WrapperFn>

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

A copy of mod plus a deprecated alias for every old snake -> new snake entry of aliases, under both the snake_case and camelCase forms (the generated tables in src/generated/aliases.ts). Throws when a target is missing, so a stale table fails loudly instead of dropping a name.

Parameters​

mod​

Record<string, WrapperFn>

The module (name → wrapper) to extend; it is not mutated.

aliases?​

Record<string, string> = {}

old snake_case name -> new snake_case name table; default {}. Each entry also yields a camelCase pair (old_name → oldName, new_name → newName).

Returns​

Record<string, WrapperFn>

A shallow copy of mod with one DeprecatedAlias per old name (snake and camel). An existing key of mod with the same name as an alias is overwritten.

Throws​

Error "deprecated alias <old>: no wrapper named <new>" when mod[new] is not a function (checked for the snake and the camel form).

Example​

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

const nfl = withDeprecatedAliases(generated, { espn_nfl_athlete_bio: 'espn_nfl_player_bio' });
await nfl.espnNflAthleteBio({ athleteId: 3139477 }); // DeprecationWarning once, then espnNflPlayerBio