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

fix: apply stricter typing to the v* signatures #831

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type V1State = {
const _state: V1State = {};

function v1(options?: Version1Options, buf?: undefined, offset?: number): string;
function v1(options?: Version1Options, buf?: Uint8Array, offset?: number): Uint8Array;
function v1(options: Version1Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
function v1(options?: Version1Options, buf?: Uint8Array, offset?: number): UUIDTypes {
let bytes: Uint8Array;

Expand Down
12 changes: 0 additions & 12 deletions src/v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ import v35, { DNS, URL } from './v35.js';

export { DNS, URL } from './v35.js';

function v3(
value: string | Uint8Array,
namespace: UUIDTypes,
buf?: undefined,
offset?: number
): string;
function v3(
value: string | Uint8Array,
namespace: UUIDTypes,
buf?: Uint8Array,
offset?: number
): Uint8Array;
function v3(value: string | Uint8Array, namespace: UUIDTypes, buf?: Uint8Array, offset?: number) {
return v35(0x30, md5, value, namespace, buf, offset);
}
Expand Down
2 changes: 1 addition & 1 deletion src/v4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import rng from './rng.js';
import { unsafeStringify } from './stringify.js';

function v4(options?: Version4Options, buf?: undefined, offset?: number): string;
function v4(options?: Version4Options, buf?: Uint8Array, offset?: number): Uint8Array;
function v4(options: Version4Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
function v4(options?: Version4Options, buf?: Uint8Array, offset?: number): UUIDTypes {
if (native.randomUUID && !buf && !options) {
return native.randomUUID();
Expand Down
12 changes: 0 additions & 12 deletions src/v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ import v35, { DNS, URL } from './v35.js';

export { DNS, URL } from './v35.js';

function v5(
value: string | Uint8Array,
namespace: UUIDTypes,
buf?: undefined,
offset?: number
): string;
function v5(
value: string | Uint8Array,
namespace: UUIDTypes,
buf?: Uint8Array,
offset?: number
): Uint8Array;
function v5(value: string | Uint8Array, namespace: UUIDTypes, buf?: Uint8Array, offset?: number) {
return v35(0x50, sha1, value, namespace, buf, offset);
}
Expand Down
2 changes: 1 addition & 1 deletion src/v6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import v1 from './v1.js';
import v1ToV6 from './v1ToV6.js';

function v6(options?: Version6Options, buf?: undefined, offset?: number): string;
function v6(options?: Version6Options, buf?: Uint8Array, offset?: number): Uint8Array;
function v6(options: Version6Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
function v6(options?: Version6Options, buf?: Uint8Array, offset?: number): UUIDTypes {
options ??= {};
offset ??= 0;
Expand Down
2 changes: 1 addition & 1 deletion src/v7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type V7State = {
const _state: V7State = {};

function v7(options?: Version7Options, buf?: undefined, offset?: number): string;
function v7(options?: Version7Options, buf?: Uint8Array, offset?: number): Uint8Array;
function v7(options: Version7Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
function v7(options?: Version7Options, buf?: Uint8Array, offset?: number): UUIDTypes {
let bytes: Uint8Array;

Expand Down