Update dev deps, deconstify all the functions, API doc refresh

This commit is contained in:
Lovell Fuller
2017-03-31 21:42:20 +01:00
parent 4001c4a48a
commit 27fb864ac4
15 changed files with 128 additions and 125 deletions

View File

@@ -29,7 +29,7 @@ const is = require('./is');
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
const rotate = function rotate (angle) {
function rotate (angle) {
if (!is.defined(angle)) {
this.options.angle = -1;
} else if (is.integer(angle) && is.inArray(angle, [0, 90, 180, 270])) {
@@ -38,7 +38,7 @@ const rotate = function rotate (angle) {
throw new Error('Unsupported angle (0, 90, 180, 270) ' + angle);
}
return this;
};
}
/**
* Extract a region of the image.
@@ -70,7 +70,7 @@ const rotate = function rotate (angle) {
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
const extract = function extract (options) {
function extract (options) {
const suffix = this.options.width === -1 && this.options.height === -1 ? 'Pre' : 'Post';
['left', 'top', 'width', 'height'].forEach(function (name) {
const value = options[name];
@@ -85,7 +85,7 @@ const extract = function extract (options) {
this.options.rotateBeforePreExtract = true;
}
return this;
};
}
/**
* Flip the image about the vertical Y axis. This always occurs after rotation, if any.
@@ -93,10 +93,10 @@ const extract = function extract (options) {
* @param {Boolean} [flip=true]
* @returns {Sharp}
*/
const flip = function flip (flip) {
function flip (flip) {
this.options.flip = is.bool(flip) ? flip : true;
return this;
};
}
/**
* Flop the image about the horizontal X axis. This always occurs after rotation, if any.
@@ -104,10 +104,10 @@ const flip = function flip (flip) {
* @param {Boolean} [flop=true]
* @returns {Sharp}
*/
const flop = function flop (flop) {
function flop (flop) {
this.options.flop = is.bool(flop) ? flop : true;
return this;
};
}
/**
* Sharpen the image.
@@ -121,7 +121,7 @@ const flop = function flop (flop) {
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
const sharpen = function sharpen (sigma, flat, jagged) {
function sharpen (sigma, flat, jagged) {
if (!is.defined(sigma)) {
// No arguments: default to mild sharpen
this.options.sharpenSigma = -1;
@@ -151,7 +151,7 @@ const sharpen = function sharpen (sigma, flat, jagged) {
throw new Error('Invalid sharpen sigma (0.01 - 10000) ' + sigma);
}
return this;
};
}
/**
* Blur the image.
@@ -161,7 +161,7 @@ const sharpen = function sharpen (sigma, flat, jagged) {
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
const blur = function blur (sigma) {
function blur (sigma) {
if (!is.defined(sigma)) {
// No arguments: default to mild blur
this.options.blurSigma = -1;
@@ -175,7 +175,7 @@ const blur = function blur (sigma) {
throw new Error('Invalid blur sigma (0.3 - 1000.0) ' + sigma);
}
return this;
};
}
/**
* Extends/pads the edges of the image with the colour provided to the `background` method.
@@ -198,7 +198,7 @@ const blur = function blur (sigma) {
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
const extend = function extend (extend) {
function extend (extend) {
if (is.integer(extend) && extend > 0) {
this.options.extendTop = extend;
this.options.extendBottom = extend;
@@ -219,17 +219,17 @@ const extend = function extend (extend) {
throw new Error('Invalid edge extension ' + extend);
}
return this;
};
}
/**
* Merge alpha transparency channel, if any, with `background`.
* @param {Boolean} [flatten=true]
* @returns {Sharp}
*/
const flatten = function flatten (flatten) {
function flatten (flatten) {
this.options.flatten = is.bool(flatten) ? flatten : true;
return this;
};
}
/**
* Trim "boring" pixels from all edges that contain values within a percentage similarity of the top-left pixel.
@@ -237,7 +237,7 @@ const flatten = function flatten (flatten) {
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
const trim = function trim (tolerance) {
function trim (tolerance) {
if (!is.defined(tolerance)) {
this.options.trimTolerance = 10;
} else if (is.integer(tolerance) && is.inRange(tolerance, 1, 99)) {
@@ -246,7 +246,7 @@ const trim = function trim (tolerance) {
throw new Error('Invalid trim tolerance (1 to 99) ' + tolerance);
}
return this;
};
}
/**
* Apply a gamma correction by reducing the encoding (darken) pre-resize at a factor of `1/gamma`
@@ -258,7 +258,7 @@ const trim = function trim (tolerance) {
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
const gamma = function gamma (gamma) {
function gamma (gamma) {
if (!is.defined(gamma)) {
// Default gamma correction of 2.2 (sRGB)
this.options.gamma = 2.2;
@@ -268,36 +268,36 @@ const gamma = function gamma (gamma) {
throw new Error('Invalid gamma correction (1.0 to 3.0) ' + gamma);
}
return this;
};
}
/**
* Produce the "negative" of the image.
* @param {Boolean} [negate=true]
* @returns {Sharp}
*/
const negate = function negate (negate) {
function negate (negate) {
this.options.negate = is.bool(negate) ? negate : true;
return this;
};
}
/**
* Enhance output image contrast by stretching its luminance to cover the full dynamic range.
* @param {Boolean} [normalise=true]
* @returns {Sharp}
*/
const normalise = function normalise (normalise) {
function normalise (normalise) {
this.options.normalise = is.bool(normalise) ? normalise : true;
return this;
};
}
/**
* Alternative spelling of normalise.
* @param {Boolean} [normalize=true]
* @returns {Sharp}
*/
const normalize = function normalize (normalize) {
function normalize (normalize) {
return this.normalise(normalize);
};
}
/**
* Convolve the image with the specified kernel.
@@ -324,7 +324,7 @@ const normalize = function normalize (normalize) {
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
const convolve = function convolve (kernel) {
function convolve (kernel) {
if (!is.object(kernel) || !Array.isArray(kernel.kernel) ||
!is.integer(kernel.width) || !is.integer(kernel.height) ||
!is.inRange(kernel.width, 3, 1001) || !is.inRange(kernel.height, 3, 1001) ||
@@ -348,7 +348,7 @@ const convolve = function convolve (kernel) {
}
this.options.convKernel = kernel;
return this;
};
}
/**
* Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
@@ -359,7 +359,7 @@ const convolve = function convolve (kernel) {
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
const threshold = function threshold (threshold, options) {
function threshold (threshold, options) {
if (!is.defined(threshold)) {
this.options.threshold = 128;
} else if (is.bool(threshold)) {
@@ -375,7 +375,7 @@ const threshold = function threshold (threshold, options) {
this.options.thresholdGrayscale = false;
}
return this;
};
}
/**
* Perform a bitwise boolean operation with operand image.
@@ -393,7 +393,7 @@ const threshold = function threshold (threshold, options) {
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
const boolean = function boolean (operand, operator, options) {
function boolean (operand, operator, options) {
this.options.boolean = this._createInputDescriptor(operand, options);
if (is.string(operator) && is.inArray(operator, ['and', 'or', 'eor'])) {
this.options.booleanOp = operator;
@@ -401,7 +401,7 @@ const boolean = function boolean (operand, operator, options) {
throw new Error('Invalid boolean operator ' + operator);
}
return this;
};
}
/**
* Decorate the Sharp prototype with operation-related functions.