Build prototype with Object.assign to allow minification (#1475)

This commit is contained in:
Julian Aubourg 2018-11-26 19:40:06 +01:00 committed by Lovell Fuller
parent d26ccf6294
commit 383b933e26
6 changed files with 7 additions and 19 deletions

View File

@ -117,14 +117,12 @@ function bandbool (boolOp) {
* @private * @private
*/ */
module.exports = function (Sharp) { module.exports = function (Sharp) {
Object.assign(Sharp.prototype, {
// Public instance functions // Public instance functions
[
removeAlpha, removeAlpha,
extractChannel, extractChannel,
joinChannel, joinChannel,
bandbool bandbool
].forEach(function (f) {
Sharp.prototype[f.name] = f;
}); });
// Class attributes // Class attributes
Sharp.bool = bool; Sharp.bool = bool;

View File

@ -123,7 +123,7 @@ function _setColourOption (key, val) {
* @private * @private
*/ */
module.exports = function (Sharp) { module.exports = function (Sharp) {
[ Object.assign(Sharp.prototype, {
// Public // Public
tint, tint,
greyscale, greyscale,
@ -132,8 +132,6 @@ module.exports = function (Sharp) {
toColorspace, toColorspace,
// Private // Private
_setColourOption _setColourOption
].forEach(function (f) {
Sharp.prototype[f.name] = f;
}); });
// Class attributes // Class attributes
Sharp.colourspace = colourspace; Sharp.colourspace = colourspace;

View File

@ -362,7 +362,7 @@ function sequentialRead (sequentialRead) {
* @private * @private
*/ */
module.exports = function (Sharp) { module.exports = function (Sharp) {
[ Object.assign(Sharp.prototype, {
// Private // Private
_createInputDescriptor, _createInputDescriptor,
_write, _write,
@ -374,7 +374,5 @@ module.exports = function (Sharp) {
stats, stats,
limitInputPixels, limitInputPixels,
sequentialRead sequentialRead
].forEach(function (f) {
Sharp.prototype[f.name] = f;
}); });
}; };

View File

@ -383,7 +383,7 @@ function linear (a, b) {
* @private * @private
*/ */
module.exports = function (Sharp) { module.exports = function (Sharp) {
[ Object.assign(Sharp.prototype, {
rotate, rotate,
flip, flip,
flop, flop,
@ -399,7 +399,5 @@ module.exports = function (Sharp) {
threshold, threshold,
boolean, boolean,
linear linear
].forEach(function (f) {
Sharp.prototype[f.name] = f;
}); });
}; };

View File

@ -641,7 +641,7 @@ function _pipeline (callback) {
* @private * @private
*/ */
module.exports = function (Sharp) { module.exports = function (Sharp) {
[ Object.assign(Sharp.prototype, {
// Public // Public
toFile, toFile,
toBuffer, toBuffer,
@ -658,7 +658,5 @@ module.exports = function (Sharp) {
_setBooleanOption, _setBooleanOption,
_read, _read,
_pipeline _pipeline
].forEach(function (f) {
Sharp.prototype[f.name] = f;
}); });
}; };

View File

@ -469,13 +469,11 @@ function withoutEnlargement (withoutEnlargement) {
* @private * @private
*/ */
module.exports = function (Sharp) { module.exports = function (Sharp) {
[ Object.assign(Sharp.prototype, {
resize, resize,
extend, extend,
extract, extract,
trim trim
].forEach(function (f) {
Sharp.prototype[f.name] = f;
}); });
// Class attributes // Class attributes
Sharp.gravity = gravity; Sharp.gravity = gravity;