Skip to content

Commit 48432a2

Browse files
committed
Fix argument validation
1 parent caa8b21 commit 48432a2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@ const zipToBuffer = (zip) => zip.generateAsync({ compression: 'DEFLATE', type: '
2121

2222
const createBuffer = (zeroBufferSize, bufferLevel, zipLevel) => {
2323
let rootZipFile = new JSZip()
24+
25+
if (typeof zeroBufferSize !== 'number') {
26+
throw new Error('Buffer multiplier should be a number')
27+
}
28+
2429
rootZipFile.file('zero.txt', prepareZeroBuffer(zeroBufferSize, bufferLevel))
2530

2631
return zipToBuffer(rootZipFile)
2732
.then((rootBuffer) => {
28-
if (typeof zeroBufferSize === 'number') {
33+
if (typeof bufferLevel !== 'number') {
2934
throw new Error('Buffer multiplier should be a number')
3035
}
3136

32-
if (typeof level === 'number') {
37+
if (typeof zipLevel !== 'number') {
3338
throw new Error('Level should be a number')
3439
}
3540

0 commit comments

Comments
 (0)