Rotate should throw Error, not String.

Minor JSLint and whitespace fixes.
This commit is contained in:
Lovell Fuller 2014-06-13 18:57:54 +01:00
parent b1b070ae5c
commit 84a059d7e3

View File

@ -68,7 +68,7 @@ Sharp.prototype.rotate = function(angle) {
} else if (!Number.isNaN(angle) && [0, 90, 180, 270].indexOf(angle) !== -1) { } else if (!Number.isNaN(angle) && [0, 90, 180, 270].indexOf(angle) !== -1) {
this.options.angle = angle; this.options.angle = angle;
} else { } else {
throw 'Unsupport angle (0, 90, 180, 270) ' + angle; throw new Error('Unsupported angle (0, 90, 180, 270) ' + angle);
} }
return this; return this;
}; };
@ -167,19 +167,19 @@ Sharp.prototype.resize = function(width, height) {
*/ */
Sharp.prototype.toFile = function(output, callback) { Sharp.prototype.toFile = function(output, callback) {
if (!output || output.length === 0) { if (!output || output.length === 0) {
var err = new Error('Invalid output'); var errOutputInvalid = new Error('Invalid output');
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(err); callback(errOutputInvalid);
} else { } else {
return Promise.reject(err); return Promise.reject(errOutputInvalid);
} }
} else { } else {
if (this.options.fileIn === output) { if (this.options.fileIn === output) {
var err = new Error('Cannot use same file for input and output'); var errOutputIsInput = new Error('Cannot use same file for input and output');
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(err); callback(errOutputIsInput);
} else { } else {
return Promise.reject(err); return Promise.reject(errOutputIsInput);
} }
} else { } else {
return this._sharp(output, callback); return this._sharp(output, callback);