Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecation(uuid): deprecate v1.generate() signature with buf and offset parameters #4880

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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