diff --git a/lib/channel.js b/lib/channel.js index f7626fab..bb32eb3b 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -117,14 +117,12 @@ function bandbool (boolOp) { * @private */ module.exports = function (Sharp) { - // Public instance functions - [ + Object.assign(Sharp.prototype, { + // Public instance functions removeAlpha, extractChannel, joinChannel, bandbool - ].forEach(function (f) { - Sharp.prototype[f.name] = f; }); // Class attributes Sharp.bool = bool; diff --git a/lib/colour.js b/lib/colour.js index fe9015b6..cd0f29da 100644 --- a/lib/colour.js +++ b/lib/colour.js @@ -123,7 +123,7 @@ function _setColourOption (key, val) { * @private */ module.exports = function (Sharp) { - [ + Object.assign(Sharp.prototype, { // Public tint, greyscale, @@ -132,8 +132,6 @@ module.exports = function (Sharp) { toColorspace, // Private _setColourOption - ].forEach(function (f) { - Sharp.prototype[f.name] = f; }); // Class attributes Sharp.colourspace = colourspace; diff --git a/lib/input.js b/lib/input.js index fcfbba73..f3760d73 100644 --- a/lib/input.js +++ b/lib/input.js @@ -362,7 +362,7 @@ function sequentialRead (sequentialRead) { * @private */ module.exports = function (Sharp) { - [ + Object.assign(Sharp.prototype, { // Private _createInputDescriptor, _write, @@ -374,7 +374,5 @@ module.exports = function (Sharp) { stats, limitInputPixels, sequentialRead - ].forEach(function (f) { - Sharp.prototype[f.name] = f; }); }; diff --git a/lib/operation.js b/lib/operation.js index 351126c1..80cd3480 100644 --- a/lib/operation.js +++ b/lib/operation.js @@ -383,7 +383,7 @@ function linear (a, b) { * @private */ module.exports = function (Sharp) { - [ + Object.assign(Sharp.prototype, { rotate, flip, flop, @@ -399,7 +399,5 @@ module.exports = function (Sharp) { threshold, boolean, linear - ].forEach(function (f) { - Sharp.prototype[f.name] = f; }); }; diff --git a/lib/output.js b/lib/output.js index 4cd6fbc6..9556c90a 100644 --- a/lib/output.js +++ b/lib/output.js @@ -641,7 +641,7 @@ function _pipeline (callback) { * @private */ module.exports = function (Sharp) { - [ + Object.assign(Sharp.prototype, { // Public toFile, toBuffer, @@ -658,7 +658,5 @@ module.exports = function (Sharp) { _setBooleanOption, _read, _pipeline - ].forEach(function (f) { - Sharp.prototype[f.name] = f; }); }; diff --git a/lib/resize.js b/lib/resize.js index 45f87064..bf464524 100644 --- a/lib/resize.js +++ b/lib/resize.js @@ -469,13 +469,11 @@ function withoutEnlargement (withoutEnlargement) { * @private */ module.exports = function (Sharp) { - [ + Object.assign(Sharp.prototype, { resize, extend, extract, trim - ].forEach(function (f) { - Sharp.prototype[f.name] = f; }); // Class attributes Sharp.gravity = gravity;