mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Rotate should throw Error, not String.
Minor JSLint and whitespace fixes.
This commit is contained in:
parent
b1b070ae5c
commit
84a059d7e3
18
index.js
18
index.js
@ -19,8 +19,8 @@ var Sharp = function(input) {
|
|||||||
interpolator: 'bilinear',
|
interpolator: 'bilinear',
|
||||||
progressive: false,
|
progressive: false,
|
||||||
sequentialRead: false,
|
sequentialRead: false,
|
||||||
quality: 80,
|
quality: 80,
|
||||||
compressionLevel: 6,
|
compressionLevel: 6,
|
||||||
output: '__jpeg'
|
output: '__jpeg'
|
||||||
};
|
};
|
||||||
if (typeof input === 'string') {
|
if (typeof input === 'string') {
|
||||||
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user