Skip to main content

Function: warnOnce()

warnOnce(key, message, options): void

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

process.emitWarning(message, options) the first time key is seen in this process, never again: the one warn-once registry behind the deprecated names and endpoints, the stats.ncaa.org scrapers and the CDN football-date warning. Namespace the key by caller ("name:" + fn) so two callers cannot share it.

Parameters​

key​

string

Registry key; the first call per process with this key warns, later ones return. Namespace it ("name:espn_nfl_pbp", "endpoint:recruiting_players").

message​

string

The warning text.

options​

process.emitWarning options: type (e.g. "DeprecationWarning") and a stable code callers can filter on (DEPRECATED_NAME_CODE, DEPRECATED_ENDPOINT_CODE).

code?​

string

type?​

string

Returns​

void

Nothing.

Example​

import { warnOnce, DEPRECATED_ENDPOINT_CODE } from './core/deprecation.js';

warnOnce(`endpoint:${short}`, `${short}() hits a dead route`, {
type: 'DeprecationWarning',
code: DEPRECATED_ENDPOINT_CODE,
});

Remarks​

The registry is a module-level Set, so it is per process and shared by every caller; resetWarnOnce clears it (for tests). Only DEPRECATED_NAME_CODE and DEPRECATED_ENDPOINT_CODE are re-exported from the package root.