Skip to content

Commit

Permalink
deprecation(uuid): deprecate v1.generate() signature with buf and…
Browse files Browse the repository at this point in the history
… `offset` parameters (#4880)
  • Loading branch information
iuioiua authored May 29, 2024
1 parent fc3d376 commit 5ffeab7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions uuid/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,39 @@ export interface GenerateOptions {
rng?: () => number[];
}

/**
* Generates a
* {@link https://www.rfc-editor.org/rfc/rfc9562.html#section-5.1 | UUIDv1}.
*
* @param options Can use RFC time sequence values as overwrites.
* @param buf Can allow the UUID to be written in byte-form starting at the offset.
* @param offset Index to start writing on the UUID bytes in buffer.
*
* @returns Returns a UUIDv1 string or an array of 16 bytes.
*
* @example Usage
* ```ts
* import { generate, validate } from "@std/uuid/v1";
* import { assert } from "@std/assert/assert";
*
* const options = {
* node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
* clockseq: 0x1234,
* msecs: new Date("2011-11-01").getTime(),
* nsecs: 5678,
* };
*
* const uuid = generate(options) as string;
* assert(validate(uuid));
* ```
*
* @deprecated This will be removed in 1.0.0. Use the other overload instead.
*/
export function generate(
options?: GenerateOptions,
buf?: number[],
offset?: number,
): string | number[];
/**
* Generates a
* {@link https://www.rfc-editor.org/rfc/rfc9562.html#section-5.1 | UUIDv1}.
Expand All @@ -104,6 +137,7 @@ export interface GenerateOptions {
* assert(validate(uuid));
* ```
*/
export function generate(options?: GenerateOptions): string;
export function generate(
options: GenerateOptions = {},
buf?: number[],
Expand Down

0 comments on commit 5ffeab7

Please sign in to comment.