Skip to content

Commit

Permalink
fix: apply stricter typing to the v* signatures (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbtraister authored Nov 4, 2024
1 parent 913e958 commit c2d3fed
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 28 deletions.
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

0 comments on commit c2d3fed

Please # to comment.