Skip to content

Commit

Permalink
chore: rewrite func sig using deprecation workflow
Browse files Browse the repository at this point in the history
This should no longer be a breaking change.
  • Loading branch information
ejcheng committed Aug 8, 2022
1 parent f7d47f1 commit 7894387
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/modules/datatype/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Faker } from '../..';
import { FakerError } from '../../errors/faker-error';
import { deprecated } from '../../internal/deprecated';

/**
* Module to generate various primitive values and data types.
Expand Down Expand Up @@ -197,7 +198,19 @@ export class Datatype {
* faker.datatype.hexadecimal({ prefix: '0x' }) // '0xE'
* faker.datatype.hexadecimal({ length: 10, prefix: '0x' }) // '0xz12a974fb1'
*/
hexadecimal(options?: { length?: number; prefix?: string }): string {
hexadecimal(options?: { length?: number; prefix?: string } | number): string {
if (typeof options === 'number') {
deprecated({
deprecated: 'faker.datatype.hexadecimal(length)',
proposed: 'faker.datatype.hexadecimal({ length })',
since: '7.4',
until: '8.0',
});
options = {
length: options,
};
}

const length = options?.length ?? 1;
const prefix = options?.prefix ?? '';

Expand Down

0 comments on commit 7894387

Please sign in to comment.