aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPiotr Kuczynski <[email protected]>2022-04-03 14:44:55 +0200
committerGitHub <[email protected]>2022-04-03 14:44:55 +0200
commitb40121e9102b9e8bde1d99689bd2fd3f61f8b767 (patch)
tree41dcbdfd928c4969d7e7228127fc503440bccb9c /src
parent77115d4d13d3ed6b4ead76d3d28e9c989b80c4d6 (diff)
downloadfaker-b40121e9102b9e8bde1d99689bd2fd3f61f8b767.tar.xz
faker-b40121e9102b9e8bde1d99689bd2fd3f61f8b767.zip
refactor: rename hexaDecimal to hexadecimal (#764)
Diffstat (limited to 'src')
-rw-r--r--src/datatype.ts25
-rw-r--r--src/finance.ts2
-rw-r--r--src/random.ts11
3 files changed, 32 insertions, 6 deletions
diff --git a/src/datatype.ts b/src/datatype.ts
index 79b0b61c..50bcb17f 100644
--- a/src/datatype.ts
+++ b/src/datatype.ts
@@ -1,4 +1,5 @@
import type { Faker } from '.';
+import { deprecated } from './internal/deprecated';
/**
* Module to generate various primitive values and data types.
@@ -185,11 +186,35 @@ export class Datatype {
*
* @param length Length of the generated number. Defaults to `1`.
*
+ * @see faker.datatype.hexadecimal()
+ *
* @example
* faker.datatype.hexaDecimal() // '0xb'
* faker.datatype.hexaDecimal(10) // '0xaE13F044fb'
+ *
+ * @deprecated
*/
hexaDecimal(length = 1): string {
+ deprecated({
+ deprecated: 'faker.datatype.hexaDecimal()',
+ proposed: 'faker.datatype.hexadecimal()',
+ since: 'v6.1.2',
+ until: 'v7.0.0',
+ });
+
+ return this.hexadecimal(length);
+ }
+
+ /**
+ * Returns a [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) number.
+ *
+ * @param length Length of the generated number. Defaults to `1`.
+ *
+ * @example
+ * faker.datatype.hexadecimal() // '0xb'
+ * faker.datatype.hexadecimal(10) // '0xaE13F044fb'
+ */
+ hexadecimal(length = 1): string {
let wholeString = '';
for (let i = 0; i < length; i++) {
diff --git a/src/finance.ts b/src/finance.ts
index ea71391d..5581ad4e 100644
--- a/src/finance.ts
+++ b/src/finance.ts
@@ -298,7 +298,7 @@ export class Finance {
* faker.finance.ethereumAddress() // '0xf03dfeecbafc5147241cc4c4ca20b3c9dfd04c4a'
*/
ethereumAddress(): string {
- const address = this.faker.datatype.hexaDecimal(40).toLowerCase();
+ const address = this.faker.datatype.hexadecimal(40).toLowerCase();
return address;
}
diff --git a/src/random.ts b/src/random.ts
index 20d54f5b..a653472f 100644
--- a/src/random.ts
+++ b/src/random.ts
@@ -545,21 +545,22 @@ export class Random {
*
* @param count Length of the generated number. Defaults to `1`.
*
- * @see faker.datatype.hexaDecimal()
+ * @see faker.datatype.hexadecimal()
*
* @example
- * faker.datatype.hexaDecimal() // '0xb'
- * faker.datatype.hexaDecimal(10) // '0xaE13F044fb'
+ * faker.random.hexaDecimal() // '0xb'
+ * faker.random.hexaDecimal(10) // '0xaE13F044fb'
*
* @deprecated
*/
hexaDecimal(count?: number): string {
deprecated({
deprecated: 'faker.random.hexaDecimal()',
- proposed: 'faker.datatype.hexaDecimal()',
+ proposed: 'faker.datatype.hexadecimal()',
// since: 'v5.0.0', (?)
until: 'v7.0.0',
});
- return this.faker.datatype.hexaDecimal(count);
+
+ return this.faker.datatype.hexadecimal(count);
}
}