* Returns a ULID ([Universally Unique Lexicographically Sortable Identifier](https://github.com/ulid/spec)). * * @param options The optional options object. * @param options.refDate The timestamp to encode into the ULID. * The encoded timestamp is represented by the first 10 characters o
(
options: {
/**
* The date to use as reference point for the newly generated ULID encoded timestamp.
* The encoded timestamp is represented by the first 10 characters of the result.
*
* @default faker.defaultRefDate()
*/
refDate?: string | Date | number;
} = {}
)
| 808 | * @since 9.1.0 |
| 809 | */ |
| 810 | ulid( |
| 811 | options: { |
| 812 | /** |
| 813 | * The date to use as reference point for the newly generated ULID encoded timestamp. |
| 814 | * The encoded timestamp is represented by the first 10 characters of the result. |
| 815 | * |
| 816 | * @default faker.defaultRefDate() |
| 817 | */ |
| 818 | refDate?: string | Date | number; |
| 819 | } = {} |
| 820 | ): string { |
| 821 | const { refDate = this.faker.defaultRefDate() } = options; |
| 822 | const date = toDate(refDate); |
| 823 | |
| 824 | return dateToBase32(date) + this.fromCharacters(CROCKFORDS_BASE32, 16); |
| 825 | } |
| 826 | |
| 827 | /** |
| 828 | * Generates a [Nano ID](https://github.com/ai/nanoid). |
no test coverage detected