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

@@ -9,7 +9,7 @@ const sharp = require('../build/Release/sharp.node');
* Create Object containing input and input-related options.
* @private
*/
const _createInputDescriptor = function _createInputDescriptor (input, inputOptions, containerOptions) {
function _createInputDescriptor (input, inputOptions, containerOptions) {
const inputDescriptor = {};
if (is.string(input)) {
// filesystem
@@ -75,7 +75,7 @@ const _createInputDescriptor = function _createInputDescriptor (input, inputOpti
throw new Error('Invalid input options ' + inputOptions);
}
return inputDescriptor;
};
}
/**
* Handle incoming Buffer chunk on Writable Stream.
@@ -84,7 +84,7 @@ const _createInputDescriptor = function _createInputDescriptor (input, inputOpti
* @param {String} encoding - unused
* @param {Function} callback
*/
const _write = function _write (chunk, encoding, callback) {
function _write (chunk, encoding, callback) {
/* istanbul ignore else */
if (Array.isArray(this.options.input.buffer)) {
/* istanbul ignore else */
@@ -103,26 +103,26 @@ const _write = function _write (chunk, encoding, callback) {
} else {
callback(new Error('Unexpected data on Writable Stream'));
}
};
}
/**
* Flattens the array of chunks accumulated in input.buffer.
* @private
*/
const _flattenBufferIn = function _flattenBufferIn () {
function _flattenBufferIn () {
if (this._isStreamInput()) {
this.options.input.buffer = Buffer.concat(this.options.input.buffer);
}
};
}
/**
* Are we expecting Stream-based input?
* @private
* @returns {Boolean}
*/
const _isStreamInput = function _isStreamInput () {
function _isStreamInput () {
return Array.isArray(this.options.input.buffer);
};
}
/**
* Take a "snapshot" of the Sharp instance, returning a new instance.
@@ -139,7 +139,7 @@ const _isStreamInput = function _isStreamInput () {
*
* @returns {Sharp}
*/
const clone = function clone () {
function clone () {
const that = this;
// Clone existing options
const clone = this.constructor.call();
@@ -152,7 +152,7 @@ const clone = function clone () {
clone.emit('finish');
});
return clone;
};
}
/**
* Fast access to image metadata without decoding any compressed image data.
@@ -187,7 +187,7 @@ const clone = function clone () {
* @param {Function} [callback] - called with the arguments `(err, metadata)`
* @returns {Promise<Object>|Sharp}
*/
const metadata = function metadata (callback) {
function metadata (callback) {
const that = this;
if (is.fn(callback)) {
if (this._isStreamInput()) {
@@ -225,7 +225,7 @@ const metadata = function metadata (callback) {
});
}
}
};
}
/**
* Do not process input images where the number of pixels (width * height) exceeds this limit.
@@ -235,7 +235,7 @@ const metadata = function metadata (callback) {
* @returns {Sharp}
* @throws {Error} Invalid limit
*/
const limitInputPixels = function limitInputPixels (limit) {
function limitInputPixels (limit) {
// if we pass in false we represent the integer as 0 to disable
if (limit === false) {
limit = 0;
@@ -248,7 +248,7 @@ const limitInputPixels = function limitInputPixels (limit) {
throw new Error('Invalid pixel limit (0 to ' + this.constructor.maximum.pixels + ') ' + limit);
}
return this;
};
}
/**
* An advanced setting that switches the libvips access method to `VIPS_ACCESS_SEQUENTIAL`.
@@ -256,10 +256,10 @@ const limitInputPixels = function limitInputPixels (limit) {
* @param {Boolean} [sequentialRead=true]
* @returns {Sharp}
*/
const sequentialRead = function sequentialRead (sequentialRead) {
function sequentialRead (sequentialRead) {
this.options.sequentialRead = is.bool(sequentialRead) ? sequentialRead : true;
return this;
};
}
/**
* Decorate the Sharp prototype with input-related functions.