rightimage
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -29,3 +29,3 @@ const isAnimatedGIF = require("is-animated/lib/types/gif").isAnimated; | ||
let args; | ||
if (typeof value === "string") { | ||
if (typeof value === "string" && processOption.canConvert(name)) { | ||
args = processOption(name, value); | ||
@@ -32,0 +32,0 @@ } else if (typeof value === "undefined") { |
const optionConverters = { | ||
resize: value => { | ||
const match = value.match(/\d+(x|,)\d+/) | ||
const match = value.match(/\d+(x|,)\d+/); | ||
if (match === null) { | ||
throw new Error(`invalid argument for resize ${value}`); | ||
// eslint-disable-next-line | ||
throw undefined; | ||
} | ||
@@ -17,7 +18,13 @@ | ||
if (!converter) { | ||
throw new Error(`unsupported argument for ${name}`); | ||
try { | ||
return converter(value); | ||
} catch (e) { | ||
throw new Error( | ||
`invalid argument for operation resize=${JSON.stringify(value)}` | ||
); | ||
} | ||
}; | ||
return converter(value); | ||
module.exports.canConvert = function canConvert(name) { | ||
return !!optionConverters[name]; | ||
}; |
{ | ||
"name": "rightimage", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "Stream images with dynamic re-orientation", | ||
@@ -39,2 +39,3 @@ "main": "lib/index.js", | ||
"eslint-plugin-node": "^10.0.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"eslint-plugin-promise": "^4.2.1", | ||
@@ -41,0 +42,0 @@ "eslint-plugin-standard": "^4.0.1", |
19633
372
19