forked from faker-js/faker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deprecated.ts
47 lines (40 loc) · 975 Bytes
/
deprecated.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* eslint-disable jsdoc/require-param */
/**
* A deprecation should never be done in a patch.
*/
type DeprecationSemVer = `${number}.${number}`;
/** @internal */
export interface DeprecatedOptions {
/**
* The name of the function, following the syntax `faker.[module].[function]()`.
*/
deprecated: string;
/**
* An alternative solution.
*/
proposed?: string;
/**
* The semver since when this is deprecated.
*/
since?: DeprecationSemVer;
/**
* The semver when this will be removed.
*/
until?: DeprecationSemVer;
}
/**
* @internal
*/
export function deprecated(opts: DeprecatedOptions): void {
let message = `[@faker-js/faker]: ${opts.deprecated} is deprecated`;
if (opts.since) {
message += ` since v${opts.since}`;
}
if (opts.until) {
message += ` and will be removed in v${opts.until}`;
}
if (opts.proposed) {
message += `. Please use ${opts.proposed} instead`;
}
console.warn(`${message}.`);
}