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
*/
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;

View File

@ -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;

View File

@ -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;
});
};

View File

@ -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;
});
};

View File

@ -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;
});
};

View File

@ -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;