Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
KATT committed Oct 7, 2023
1 parent 1eb737c commit 09ff667
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/async/serializeAsync.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TsonCircularReferenceError } from "../errors.js";
import { assert } from "../internals/assert.js";
import { GetNonce, getNonceDefault } from "../internals/getNonce.js";
import { GetNonce, getDefaultNonce } from "../internals/getNonce.js";
import { mapOrReturn } from "../internals/mapOrReturn.js";
import {
TsonAllTypes,
Expand Down Expand Up @@ -192,7 +192,7 @@ type TsonAsyncSerializer = <T>(
export function createAsyncTsonSerialize(
opts: TsonAsyncOptions,
): TsonAsyncSerializer {
const getNonce: GetNonce = (opts.nonce ?? getNonceDefault) as GetNonce;
const getNonce: GetNonce = (opts.nonce ?? getDefaultNonce) as GetNonce;
return (value) => {
const nonce = getNonce();
const [walk, iterator] = walkerFactory(nonce, opts.types);
Expand Down
4 changes: 2 additions & 2 deletions src/internals/getNonce.crypto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ test("with crypto", async () => {
global.crypto = {
randomUUID: () => "test",
} as any;
const { getNonceDefault } = await import("./getNonce.js");
const { getDefaultNonce } = await import("./getNonce.js");

expect(getNonceDefault()).toBe("test");
expect(getDefaultNonce()).toBe("test");

global.crypto = before;
});
4 changes: 2 additions & 2 deletions src/internals/getNonce.nocrypto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ test("without crypto", async () => {

global.crypto = undefined as any;

const { getNonceDefault } = await import("./getNonce.js");
const { getDefaultNonce } = await import("./getNonce.js");

expect(getNonceDefault().length).toBeGreaterThan(20);
expect(getDefaultNonce().length).toBeGreaterThan(20);

global.crypto = before;
});
2 changes: 1 addition & 1 deletion src/internals/getNonce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const randomString = () => Math.random().toString(36).slice(2);

export type GetNonce = () => TsonNonce;

export const getNonceDefault: GetNonce =
export const getDefaultNonce: GetNonce =
typeof crypto === "object" && typeof crypto.randomUUID === "function"
? () => crypto.randomUUID() as TsonNonce
: () =>
Expand Down
4 changes: 2 additions & 2 deletions src/sync/serialize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TsonCircularReferenceError } from "../errors.js";
import { GetNonce, getNonceDefault } from "../internals/getNonce.js";
import { GetNonce, getDefaultNonce } from "../internals/getNonce.js";
import { mapOrReturn } from "../internals/mapOrReturn.js";
import {
TsonAllTypes,
Expand Down Expand Up @@ -40,7 +40,7 @@ function getHandlers(opts: TsonOptions) {

const getNonce: GetNonce = opts.nonce
? (opts.nonce as GetNonce)
: getNonceDefault;
: getDefaultNonce;

return [getNonce, nonPrimitives, byPrimitive] as const;
}
Expand Down

0 comments on commit 09ff667

Please sign in to comment.