Skip to content

Commit cb3626d

Browse files
committed
Do not allow tose size=0 on Node.js
1 parent 095b73d commit cb3626d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ export function customRandom(alphabet, defaultSize, getRandom) {
5151
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
5252

5353
return (size = defaultSize) => {
54+
if (size === 0) {
55+
throw new Error('ID size is 0')
56+
}
57+
5458
let id = ''
5559
while (true) {
5660
let bytes = getRandom(step)

0 commit comments

Comments
 (0)