MCPcopy
hub / github.com/faker-js/faker / ulid

Method ulid

src/modules/string/index.ts:810–825  ·  view source on GitHub ↗

* 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;
    } = {}
  )

Source from the content-addressed store, hash-verified

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).

Callers 1

string.spec.tsFile · 0.80

Calls 4

fromCharactersMethod · 0.95
toDateFunction · 0.90
dateToBase32Function · 0.90
defaultRefDateMethod · 0.80

Tested by

no test coverage detected