Skip to content

Commit c51b75a

Browse files
Syntax errors have been fixed.
1 parent ac9eb66 commit c51b75a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { obj } from 'through2'
22
import sharp from 'sharp'
33
import Vinyl from 'vinyl'
44

5-
const ALLOWED_EXTENTIONS = [
5+
const ALLOWED_EXTENSIONS = [
66
'.gif',
77
'.png',
88
'.jpg', '.jpeg',
@@ -11,7 +11,7 @@ const ALLOWED_EXTENTIONS = [
1111
'.tiff',
1212
'.heif',
1313
]
14-
const optionsByDefualt = {
14+
const optionsByDefault = {
1515
quality: 90,
1616
lossless: false,
1717
chromaSubsampling: '4:2:0'
@@ -23,7 +23,7 @@ export default function sharpOptimizeImages(options) {
2323
if (file.isNull()) {
2424
return callback(null, file)
2525
}
26-
if (ALLOWED_EXTENTIONS.includes(file.extname) == false) {
26+
if (ALLOWED_EXTENSIONS.includes(file.extname) == false) {
2727
console.error(`${file.basename} not supported, just copy.`)
2828

2929
return callback(null, file)
@@ -36,9 +36,9 @@ export default function sharpOptimizeImages(options) {
3636
let optionObjects = Object.entries(options)
3737

3838
for (let [optionObjectFormat, optionObjectProps] of optionObjects) {
39-
let splitedObjectName = optionObjectFormat.split('_to_')
40-
let convertFromOfGeneralExtname = splitedObjectName[0]
41-
let convertToExtname = splitedObjectName[1]
39+
let splittedObjectName = optionObjectFormat.split('_to_')
40+
let convertFromOfGeneralExtname = splittedObjectName[0]
41+
let convertToExtname = splittedObjectName[1]
4242

4343
if (extnamesIsCorrect(convertFromOfGeneralExtname, convertToExtname) == false) {
4444
throw new Error('Invalid name of an object! Make sure you have spelled the extension names correctly.')
@@ -69,26 +69,26 @@ async function convert(file, newFileFormat, options) {
6969

7070
switch (newFileFormat) {
7171
case 'gif':
72-
sharpInstance = sharpInstance.gif(Object.assign(optionsByDefualt, options))
72+
sharpInstance = sharpInstance.gif(Object.assign(optionsByDefault, options))
7373
break
7474
case 'png':
75-
sharpInstance = sharpInstance.png(Object.assign(optionsByDefualt, options))
75+
sharpInstance = sharpInstance.png(Object.assign(optionsByDefault, options))
7676
break
7777
case 'jpg':
7878
case 'jpeg':
79-
sharpInstance = sharpInstance.jpeg(Object.assign(optionsByDefualt, options))
79+
sharpInstance = sharpInstance.jpeg(Object.assign(optionsByDefault, options))
8080
break
8181
case 'webp':
82-
sharpInstance = sharpInstance.webp(Object.assign(optionsByDefualt, options))
82+
sharpInstance = sharpInstance.webp(Object.assign(optionsByDefault, options))
8383
break
8484
case 'tiff':
85-
sharpInstance = sharpInstance.tiff(Object.assign(optionsByDefualt, options))
85+
sharpInstance = sharpInstance.tiff(Object.assign(optionsByDefault, options))
8686
break
8787
case 'avif':
88-
sharpInstance = sharpInstance.avif(Object.assign(optionsByDefualt, options))
88+
sharpInstance = sharpInstance.avif(Object.assign(optionsByDefault, options))
8989
break
9090
case 'heif':
91-
sharpInstance = sharpInstance.heif(Object.assign(optionsByDefualt, options))
91+
sharpInstance = sharpInstance.heif(Object.assign(optionsByDefault, options))
9292
break
9393
default:
9494
return false
@@ -113,7 +113,7 @@ function toVinyl(buffer, newFileFormat, file) {
113113

114114
function extnamesIsCorrect(...extnames) {
115115
for (let extname of extnames) {
116-
if (extname && ALLOWED_EXTENTIONS.includes(`.${extname}`) == false) {
116+
if (extname && ALLOWED_EXTENSIONS.includes(`.${extname}`) == false) {
117117
return false
118118
} else {
119119
return true

0 commit comments

Comments
 (0)