Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: array.join for concat
  • Loading branch information
cmcnicholas committed Sep 13, 2025
commit 054b847994d942f2823aba7577fbcae63e952dcd
8 changes: 8 additions & 0 deletions source/ulid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ export function encodeRandom(len: number, prng: PRNG): string {
let str = "";
for (; len > 0; len--) {
str = randomChar(prng) + str;
const str = new Array(len);
for (let currentLen = len; currentLen > 0; currentLen--) {
str[len - currentLen] = randomChar(prng);
}
return str;
return str.join("");
}

/**
Expand Down Expand Up @@ -125,12 +129,16 @@ export function encodeTime(now: number, len: number = TIME_LEN): string {
}
let mod: number,
str: string = "";
let mod: number;
const str = new Array(len);
for (let currentLen = len; currentLen > 0; currentLen--) {
mod = now % ENCODING_LEN;
str = ENCODING.charAt(mod) + str;
str[len - currentLen] = ENCODING[mod];
now = (now - mod) / ENCODING_LEN;
}
return str;
return str.join("");
}

function inWebWorker(): boolean {
Expand Down