+10
-6
@@ -149,8 +149,12 @@ /*! | ||
| const colour = color(value); | ||
| return [ | ||
| colour.red(), | ||
| colour.green(), | ||
| colour.blue(), | ||
| Math.round(colour.alpha() * 255) | ||
| ]; | ||
| const red = colour.red(); | ||
| const green = colour.green(); | ||
| const blue = colour.blue(); | ||
| const alpha = Math.round(colour.alpha() * 255); | ||
| for (const [channel, component] of [['red', red], ['green', green], ['blue', blue], ['alpha', alpha]]) { | ||
| if (!is.number(component)) { | ||
| throw is.invalidParameterError(`background.${channel}`, 'number', component); | ||
| } | ||
| } | ||
| return [red, green, blue, alpha]; | ||
| } else { | ||
@@ -157,0 +161,0 @@ throw is.invalidParameterError('background', 'object or string', value); |
+10
-6
@@ -149,8 +149,12 @@ /*! | ||
| const colour = color(value); | ||
| return [ | ||
| colour.red(), | ||
| colour.green(), | ||
| colour.blue(), | ||
| Math.round(colour.alpha() * 255) | ||
| ]; | ||
| const red = colour.red(); | ||
| const green = colour.green(); | ||
| const blue = colour.blue(); | ||
| const alpha = Math.round(colour.alpha() * 255); | ||
| for (const [channel, component] of [['red', red], ['green', green], ['blue', blue], ['alpha', alpha]]) { | ||
| if (!is.number(component)) { | ||
| throw is.invalidParameterError(`background.${channel}`, 'number', component); | ||
| } | ||
| } | ||
| return [red, green, blue, alpha]; | ||
| } else { | ||
@@ -157,0 +161,0 @@ throw is.invalidParameterError('background', 'object or string', value); |
+8
-8
@@ -184,4 +184,4 @@ /*! | ||
| is.object(inputOptions.raw) && | ||
| is.integer(inputOptions.raw.width) && inputOptions.raw.width > 0 && | ||
| is.integer(inputOptions.raw.height) && inputOptions.raw.height > 0 && | ||
| is.integer(inputOptions.raw.width) && is.inRange(inputOptions.raw.width, 1, 100000000) && | ||
| is.integer(inputOptions.raw.height) && is.inRange(inputOptions.raw.height, 1, 100000000) && | ||
| is.integer(inputOptions.raw.channels) && is.inRange(inputOptions.raw.channels, 1, 4) | ||
@@ -333,4 +333,4 @@ ) { | ||
| is.object(inputOptions.create) && | ||
| is.integer(inputOptions.create.width) && inputOptions.create.width > 0 && | ||
| is.integer(inputOptions.create.height) && inputOptions.create.height > 0 && | ||
| is.integer(inputOptions.create.width) && is.inRange(inputOptions.create.width, 1, 100000000) && | ||
| is.integer(inputOptions.create.height) && is.inRange(inputOptions.create.height, 1, 100000000) && | ||
| is.integer(inputOptions.create.channels) | ||
@@ -415,13 +415,13 @@ ) { | ||
| if (is.defined(inputOptions.text.width)) { | ||
| if (is.integer(inputOptions.text.width) && inputOptions.text.width > 0) { | ||
| if (is.integer(inputOptions.text.width) && is.inRange(inputOptions.text.width, 1, 1000000)) { | ||
| inputDescriptor.textWidth = inputOptions.text.width; | ||
| } else { | ||
| throw is.invalidParameterError('text.width', 'positive integer', inputOptions.text.width); | ||
| throw is.invalidParameterError('text.width', 'integer between 1 and 1000000', inputOptions.text.width); | ||
| } | ||
| } | ||
| if (is.defined(inputOptions.text.height)) { | ||
| if (is.integer(inputOptions.text.height) && inputOptions.text.height > 0) { | ||
| if (is.integer(inputOptions.text.height) && is.inRange(inputOptions.text.height, 1, 1000000)) { | ||
| inputDescriptor.textHeight = inputOptions.text.height; | ||
| } else { | ||
| throw is.invalidParameterError('text.height', 'positive integer', inputOptions.text.height); | ||
| throw is.invalidParameterError('text.height', 'integer between 1 and 1000000', inputOptions.text.height); | ||
| } | ||
@@ -428,0 +428,0 @@ } |
+8
-8
@@ -184,4 +184,4 @@ /*! | ||
| is.object(inputOptions.raw) && | ||
| is.integer(inputOptions.raw.width) && inputOptions.raw.width > 0 && | ||
| is.integer(inputOptions.raw.height) && inputOptions.raw.height > 0 && | ||
| is.integer(inputOptions.raw.width) && is.inRange(inputOptions.raw.width, 1, 100000000) && | ||
| is.integer(inputOptions.raw.height) && is.inRange(inputOptions.raw.height, 1, 100000000) && | ||
| is.integer(inputOptions.raw.channels) && is.inRange(inputOptions.raw.channels, 1, 4) | ||
@@ -333,4 +333,4 @@ ) { | ||
| is.object(inputOptions.create) && | ||
| is.integer(inputOptions.create.width) && inputOptions.create.width > 0 && | ||
| is.integer(inputOptions.create.height) && inputOptions.create.height > 0 && | ||
| is.integer(inputOptions.create.width) && is.inRange(inputOptions.create.width, 1, 100000000) && | ||
| is.integer(inputOptions.create.height) && is.inRange(inputOptions.create.height, 1, 100000000) && | ||
| is.integer(inputOptions.create.channels) | ||
@@ -415,13 +415,13 @@ ) { | ||
| if (is.defined(inputOptions.text.width)) { | ||
| if (is.integer(inputOptions.text.width) && inputOptions.text.width > 0) { | ||
| if (is.integer(inputOptions.text.width) && is.inRange(inputOptions.text.width, 1, 1000000)) { | ||
| inputDescriptor.textWidth = inputOptions.text.width; | ||
| } else { | ||
| throw is.invalidParameterError('text.width', 'positive integer', inputOptions.text.width); | ||
| throw is.invalidParameterError('text.width', 'integer between 1 and 1000000', inputOptions.text.width); | ||
| } | ||
| } | ||
| if (is.defined(inputOptions.text.height)) { | ||
| if (is.integer(inputOptions.text.height) && inputOptions.text.height > 0) { | ||
| if (is.integer(inputOptions.text.height) && is.inRange(inputOptions.text.height, 1, 1000000)) { | ||
| inputDescriptor.textHeight = inputOptions.text.height; | ||
| } else { | ||
| throw is.invalidParameterError('text.height', 'positive integer', inputOptions.text.height); | ||
| throw is.invalidParameterError('text.height', 'integer between 1 and 1000000', inputOptions.text.height); | ||
| } | ||
@@ -428,0 +428,0 @@ } |
+1
-1
@@ -81,3 +81,3 @@ /*! | ||
| */ | ||
| const number = (val) => typeof val === 'number' && !Number.isNaN(val); | ||
| const number = (val) => typeof val === 'number' && Number.isFinite(val); | ||
@@ -84,0 +84,0 @@ /** |
+1
-1
@@ -81,3 +81,3 @@ /*! | ||
| */ | ||
| const number = (val) => typeof val === 'number' && !Number.isNaN(val); | ||
| const number = (val) => typeof val === 'number' && Number.isFinite(val); | ||
@@ -84,0 +84,0 @@ /** |
+19
-12
@@ -181,3 +181,9 @@ /*! | ||
| function affine (matrix, options) { | ||
| const flatMatrix = Array.isArray(matrix) ? [].concat(...matrix) : []; | ||
| const isValidShape = Array.isArray(matrix) && ( | ||
| // 1x4 array of numbers | ||
| (matrix.length === 4 && matrix.every(is.number)) || | ||
| // 2x2 array of arrays of numbers | ||
| (matrix.length === 2 && matrix.every((row) => Array.isArray(row) && row.length === 2)) | ||
| ); | ||
| const flatMatrix = isValidShape ? matrix.flat() : []; | ||
| if (flatMatrix.length === 4 && flatMatrix.every(is.number)) { | ||
@@ -650,4 +656,4 @@ this.options.affineMatrix = flatMatrix; | ||
| * @param {Object} options | ||
| * @param {number} options.width - Integral width of the search window, in pixels. | ||
| * @param {number} options.height - Integral height of the search window, in pixels. | ||
| * @param {number} options.width - Integral width of the search window, in pixels, between 1 and 65536. | ||
| * @param {number} options.height - Integral height of the search window, in pixels, between 1 and 65536. | ||
| * @param {number} [options.maxSlope=3] - Integral level of brightening, between 0 and 100, where 0 disables contrast limiting. | ||
@@ -659,11 +665,11 @@ * @returns {Sharp} | ||
| if (is.plainObject(options)) { | ||
| if (is.integer(options.width) && options.width > 0) { | ||
| if (is.integer(options.width) && is.inRange(options.width, 1, 65536)) { | ||
| this.options.claheWidth = options.width; | ||
| } else { | ||
| throw is.invalidParameterError('width', 'integer greater than zero', options.width); | ||
| throw is.invalidParameterError('width', 'integer between 1 and 65536', options.width); | ||
| } | ||
| if (is.integer(options.height) && options.height > 0) { | ||
| if (is.integer(options.height) && is.inRange(options.height, 1, 65536)) { | ||
| this.options.claheHeight = options.height; | ||
| } else { | ||
| throw is.invalidParameterError('height', 'integer greater than zero', options.height); | ||
| throw is.invalidParameterError('height', 'integer between 1 and 65536', options.height); | ||
| } | ||
@@ -866,9 +872,10 @@ if (is.defined(options.maxSlope)) { | ||
| } | ||
| if (inputMatrix.length !== 3 && inputMatrix.length !== 4) { | ||
| throw is.invalidParameterError('inputMatrix', '3x3 or 4x4 array', inputMatrix.length); | ||
| const dimensions = inputMatrix.length; | ||
| if (dimensions !== 3 && dimensions !== 4) { | ||
| throw is.invalidParameterError('inputMatrix', '3x3 or 4x4 array', dimensions); | ||
| } | ||
| if (!inputMatrix.every((row) => Array.isArray(row) && row.length === dimensions)) { | ||
| throw is.invalidParameterError('inputMatrix', `array of ${dimensions} arrays of length ${dimensions}`, inputMatrix); | ||
| } | ||
| const recombMatrix = inputMatrix.flat(); | ||
| if (recombMatrix.length !== 9 && recombMatrix.length !== 16) { | ||
| throw is.invalidParameterError('inputMatrix', 'cardinality of 9 or 16', recombMatrix.length); | ||
| } | ||
| if (!recombMatrix.every(is.number)) { | ||
@@ -875,0 +882,0 @@ throw is.invalidParameterError('inputMatrix', 'array of numbers', recombMatrix); |
+19
-12
@@ -181,3 +181,9 @@ /*! | ||
| function affine (matrix, options) { | ||
| const flatMatrix = Array.isArray(matrix) ? [].concat(...matrix) : []; | ||
| const isValidShape = Array.isArray(matrix) && ( | ||
| // 1x4 array of numbers | ||
| (matrix.length === 4 && matrix.every(is.number)) || | ||
| // 2x2 array of arrays of numbers | ||
| (matrix.length === 2 && matrix.every((row) => Array.isArray(row) && row.length === 2)) | ||
| ); | ||
| const flatMatrix = isValidShape ? matrix.flat() : []; | ||
| if (flatMatrix.length === 4 && flatMatrix.every(is.number)) { | ||
@@ -650,4 +656,4 @@ this.options.affineMatrix = flatMatrix; | ||
| * @param {Object} options | ||
| * @param {number} options.width - Integral width of the search window, in pixels. | ||
| * @param {number} options.height - Integral height of the search window, in pixels. | ||
| * @param {number} options.width - Integral width of the search window, in pixels, between 1 and 65536. | ||
| * @param {number} options.height - Integral height of the search window, in pixels, between 1 and 65536. | ||
| * @param {number} [options.maxSlope=3] - Integral level of brightening, between 0 and 100, where 0 disables contrast limiting. | ||
@@ -659,11 +665,11 @@ * @returns {Sharp} | ||
| if (is.plainObject(options)) { | ||
| if (is.integer(options.width) && options.width > 0) { | ||
| if (is.integer(options.width) && is.inRange(options.width, 1, 65536)) { | ||
| this.options.claheWidth = options.width; | ||
| } else { | ||
| throw is.invalidParameterError('width', 'integer greater than zero', options.width); | ||
| throw is.invalidParameterError('width', 'integer between 1 and 65536', options.width); | ||
| } | ||
| if (is.integer(options.height) && options.height > 0) { | ||
| if (is.integer(options.height) && is.inRange(options.height, 1, 65536)) { | ||
| this.options.claheHeight = options.height; | ||
| } else { | ||
| throw is.invalidParameterError('height', 'integer greater than zero', options.height); | ||
| throw is.invalidParameterError('height', 'integer between 1 and 65536', options.height); | ||
| } | ||
@@ -866,9 +872,10 @@ if (is.defined(options.maxSlope)) { | ||
| } | ||
| if (inputMatrix.length !== 3 && inputMatrix.length !== 4) { | ||
| throw is.invalidParameterError('inputMatrix', '3x3 or 4x4 array', inputMatrix.length); | ||
| const dimensions = inputMatrix.length; | ||
| if (dimensions !== 3 && dimensions !== 4) { | ||
| throw is.invalidParameterError('inputMatrix', '3x3 or 4x4 array', dimensions); | ||
| } | ||
| if (!inputMatrix.every((row) => Array.isArray(row) && row.length === dimensions)) { | ||
| throw is.invalidParameterError('inputMatrix', `array of ${dimensions} arrays of length ${dimensions}`, inputMatrix); | ||
| } | ||
| const recombMatrix = inputMatrix.flat(); | ||
| if (recombMatrix.length !== 9 && recombMatrix.length !== 16) { | ||
| throw is.invalidParameterError('inputMatrix', 'cardinality of 9 or 16', recombMatrix.length); | ||
| } | ||
| if (!recombMatrix.every(is.number)) { | ||
@@ -875,0 +882,0 @@ throw is.invalidParameterError('inputMatrix', 'array of numbers', recombMatrix); |
+30
-26
@@ -389,6 +389,6 @@ /*! | ||
| * @param {(number|Object)} extend - single pixel count to add to all edges or an Object with per-edge counts | ||
| * @param {number} [extend.top=0] | ||
| * @param {number} [extend.left=0] | ||
| * @param {number} [extend.bottom=0] | ||
| * @param {number} [extend.right=0] | ||
| * @param {number} [extend.top=0] - number of pixels to add to the top edge, valid values are integers in the range 0-10000 | ||
| * @param {number} [extend.left=0] - number of pixels to add to the left edge, valid values are integers in the range 0-10000 | ||
| * @param {number} [extend.bottom=0] - number of pixels to add to the bottom edge, valid values are integers in the range 0-10000 | ||
| * @param {number} [extend.right=0] - number of pixels to add to the right edge, valid values are integers in the range 0-10000 | ||
| * @param {String} [extend.extendWith='background'] - populate new pixels using this method, one of: background, copy, repeat, mirror. | ||
@@ -400,34 +400,38 @@ * @param {String|Object} [extend.background={r: 0, g: 0, b: 0, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black without transparency. | ||
| function extend (extend) { | ||
| if (is.integer(extend) && extend > 0) { | ||
| this.options.extendTop = extend; | ||
| this.options.extendBottom = extend; | ||
| this.options.extendLeft = extend; | ||
| this.options.extendRight = extend; | ||
| if (is.integer(extend)) { | ||
| if (is.inRange(extend, 1, 10000)) { | ||
| this.options.extendTop = extend; | ||
| this.options.extendBottom = extend; | ||
| this.options.extendLeft = extend; | ||
| this.options.extendRight = extend; | ||
| } else { | ||
| throw is.invalidParameterError('extend', 'integer between 1 and 10000', extend); | ||
| } | ||
| } else if (is.object(extend)) { | ||
| if (is.defined(extend.top)) { | ||
| if (is.integer(extend.top) && extend.top >= 0) { | ||
| if (is.integer(extend.top) && is.inRange(extend.top, 0, 10000)) { | ||
| this.options.extendTop = extend.top; | ||
| } else { | ||
| throw is.invalidParameterError('top', 'positive integer', extend.top); | ||
| throw is.invalidParameterError('top', 'integer between 0 and 10000', extend.top); | ||
| } | ||
| } | ||
| if (is.defined(extend.bottom)) { | ||
| if (is.integer(extend.bottom) && extend.bottom >= 0) { | ||
| if (is.integer(extend.bottom) && is.inRange(extend.bottom, 0, 10000)) { | ||
| this.options.extendBottom = extend.bottom; | ||
| } else { | ||
| throw is.invalidParameterError('bottom', 'positive integer', extend.bottom); | ||
| throw is.invalidParameterError('bottom', 'integer between 0 and 10000', extend.bottom); | ||
| } | ||
| } | ||
| if (is.defined(extend.left)) { | ||
| if (is.integer(extend.left) && extend.left >= 0) { | ||
| if (is.integer(extend.left) && is.inRange(extend.left, 0, 10000)) { | ||
| this.options.extendLeft = extend.left; | ||
| } else { | ||
| throw is.invalidParameterError('left', 'positive integer', extend.left); | ||
| throw is.invalidParameterError('left', 'integer between 0 and 10000', extend.left); | ||
| } | ||
| } | ||
| if (is.defined(extend.right)) { | ||
| if (is.integer(extend.right) && extend.right >= 0) { | ||
| if (is.integer(extend.right) && is.inRange(extend.right, 0, 10000)) { | ||
| this.options.extendRight = extend.right; | ||
| } else { | ||
| throw is.invalidParameterError('right', 'positive integer', extend.right); | ||
| throw is.invalidParameterError('right', 'integer between 0 and 10000', extend.right); | ||
| } | ||
@@ -472,6 +476,6 @@ } | ||
| * @param {Object} options - describes the region to extract using integral pixel values | ||
| * @param {number} options.left - zero-indexed offset from left edge | ||
| * @param {number} options.top - zero-indexed offset from top edge | ||
| * @param {number} options.width - width of region to extract | ||
| * @param {number} options.height - height of region to extract | ||
| * @param {number} options.left - zero-indexed offset from left edge, an integer between 0 and 100000000 | ||
| * @param {number} options.top - zero-indexed offset from top edge, an integer between 0 and 100000000 | ||
| * @param {number} options.width - width of region to extract, an integer between 0 and 100000000 | ||
| * @param {number} options.height - height of region to extract, an integer between 0 and 100000000 | ||
| * @returns {Sharp} | ||
@@ -487,6 +491,6 @@ * @throws {Error} Invalid parameters | ||
| const value = options[name]; | ||
| if (is.integer(value) && value >= 0) { | ||
| if (is.integer(value) && is.inRange(value, 0, 100000000)) { | ||
| this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value; | ||
| } else { | ||
| throw is.invalidParameterError(name, 'integer', value); | ||
| throw is.invalidParameterError(name, 'integer between 0 and 100000000', value); | ||
| } | ||
@@ -561,3 +565,3 @@ }, this); | ||
| * @param {boolean} [options.lineArt=false] - Does the input more closely resemble line art (e.g. vector) rather than being photographic? | ||
| * @param {number} [options.margin=0] - Leave a margin around trimmed content, value is in pixels. | ||
| * @param {number} [options.margin=0] - Leave a margin around trimmed content, integral number of pixels between 0 and 10000000. | ||
| * @returns {Sharp} | ||
@@ -584,6 +588,6 @@ * @throws {Error} Invalid parameters | ||
| if (is.defined(options.margin)) { | ||
| if (is.integer(options.margin) && options.margin >= 0) { | ||
| if (is.integer(options.margin) && is.inRange(options.margin, 0, 10000000)) { | ||
| this.options.trimMargin = options.margin; | ||
| } else { | ||
| throw is.invalidParameterError('margin', 'positive integer', options.margin); | ||
| throw is.invalidParameterError('margin', 'integer between 0 and 10000000', options.margin); | ||
| } | ||
@@ -590,0 +594,0 @@ } |
+30
-26
@@ -389,6 +389,6 @@ /*! | ||
| * @param {(number|Object)} extend - single pixel count to add to all edges or an Object with per-edge counts | ||
| * @param {number} [extend.top=0] | ||
| * @param {number} [extend.left=0] | ||
| * @param {number} [extend.bottom=0] | ||
| * @param {number} [extend.right=0] | ||
| * @param {number} [extend.top=0] - number of pixels to add to the top edge, valid values are integers in the range 0-10000 | ||
| * @param {number} [extend.left=0] - number of pixels to add to the left edge, valid values are integers in the range 0-10000 | ||
| * @param {number} [extend.bottom=0] - number of pixels to add to the bottom edge, valid values are integers in the range 0-10000 | ||
| * @param {number} [extend.right=0] - number of pixels to add to the right edge, valid values are integers in the range 0-10000 | ||
| * @param {String} [extend.extendWith='background'] - populate new pixels using this method, one of: background, copy, repeat, mirror. | ||
@@ -400,34 +400,38 @@ * @param {String|Object} [extend.background={r: 0, g: 0, b: 0, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black without transparency. | ||
| function extend (extend) { | ||
| if (is.integer(extend) && extend > 0) { | ||
| this.options.extendTop = extend; | ||
| this.options.extendBottom = extend; | ||
| this.options.extendLeft = extend; | ||
| this.options.extendRight = extend; | ||
| if (is.integer(extend)) { | ||
| if (is.inRange(extend, 1, 10000)) { | ||
| this.options.extendTop = extend; | ||
| this.options.extendBottom = extend; | ||
| this.options.extendLeft = extend; | ||
| this.options.extendRight = extend; | ||
| } else { | ||
| throw is.invalidParameterError('extend', 'integer between 1 and 10000', extend); | ||
| } | ||
| } else if (is.object(extend)) { | ||
| if (is.defined(extend.top)) { | ||
| if (is.integer(extend.top) && extend.top >= 0) { | ||
| if (is.integer(extend.top) && is.inRange(extend.top, 0, 10000)) { | ||
| this.options.extendTop = extend.top; | ||
| } else { | ||
| throw is.invalidParameterError('top', 'positive integer', extend.top); | ||
| throw is.invalidParameterError('top', 'integer between 0 and 10000', extend.top); | ||
| } | ||
| } | ||
| if (is.defined(extend.bottom)) { | ||
| if (is.integer(extend.bottom) && extend.bottom >= 0) { | ||
| if (is.integer(extend.bottom) && is.inRange(extend.bottom, 0, 10000)) { | ||
| this.options.extendBottom = extend.bottom; | ||
| } else { | ||
| throw is.invalidParameterError('bottom', 'positive integer', extend.bottom); | ||
| throw is.invalidParameterError('bottom', 'integer between 0 and 10000', extend.bottom); | ||
| } | ||
| } | ||
| if (is.defined(extend.left)) { | ||
| if (is.integer(extend.left) && extend.left >= 0) { | ||
| if (is.integer(extend.left) && is.inRange(extend.left, 0, 10000)) { | ||
| this.options.extendLeft = extend.left; | ||
| } else { | ||
| throw is.invalidParameterError('left', 'positive integer', extend.left); | ||
| throw is.invalidParameterError('left', 'integer between 0 and 10000', extend.left); | ||
| } | ||
| } | ||
| if (is.defined(extend.right)) { | ||
| if (is.integer(extend.right) && extend.right >= 0) { | ||
| if (is.integer(extend.right) && is.inRange(extend.right, 0, 10000)) { | ||
| this.options.extendRight = extend.right; | ||
| } else { | ||
| throw is.invalidParameterError('right', 'positive integer', extend.right); | ||
| throw is.invalidParameterError('right', 'integer between 0 and 10000', extend.right); | ||
| } | ||
@@ -472,6 +476,6 @@ } | ||
| * @param {Object} options - describes the region to extract using integral pixel values | ||
| * @param {number} options.left - zero-indexed offset from left edge | ||
| * @param {number} options.top - zero-indexed offset from top edge | ||
| * @param {number} options.width - width of region to extract | ||
| * @param {number} options.height - height of region to extract | ||
| * @param {number} options.left - zero-indexed offset from left edge, an integer between 0 and 100000000 | ||
| * @param {number} options.top - zero-indexed offset from top edge, an integer between 0 and 100000000 | ||
| * @param {number} options.width - width of region to extract, an integer between 0 and 100000000 | ||
| * @param {number} options.height - height of region to extract, an integer between 0 and 100000000 | ||
| * @returns {Sharp} | ||
@@ -487,6 +491,6 @@ * @throws {Error} Invalid parameters | ||
| const value = options[name]; | ||
| if (is.integer(value) && value >= 0) { | ||
| if (is.integer(value) && is.inRange(value, 0, 100000000)) { | ||
| this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value; | ||
| } else { | ||
| throw is.invalidParameterError(name, 'integer', value); | ||
| throw is.invalidParameterError(name, 'integer between 0 and 100000000', value); | ||
| } | ||
@@ -561,3 +565,3 @@ }, this); | ||
| * @param {boolean} [options.lineArt=false] - Does the input more closely resemble line art (e.g. vector) rather than being photographic? | ||
| * @param {number} [options.margin=0] - Leave a margin around trimmed content, value is in pixels. | ||
| * @param {number} [options.margin=0] - Leave a margin around trimmed content, integral number of pixels between 0 and 10000000. | ||
| * @returns {Sharp} | ||
@@ -584,6 +588,6 @@ * @throws {Error} Invalid parameters | ||
| if (is.defined(options.margin)) { | ||
| if (is.integer(options.margin) && options.margin >= 0) { | ||
| if (is.integer(options.margin) && is.inRange(options.margin, 0, 10000000)) { | ||
| this.options.trimMargin = options.margin; | ||
| } else { | ||
| throw is.invalidParameterError('margin', 'positive integer', options.margin); | ||
| throw is.invalidParameterError('margin', 'integer between 0 and 10000000', options.margin); | ||
| } | ||
@@ -590,0 +594,0 @@ } |
+6
-0
@@ -92,2 +92,8 @@ /*! | ||
| } | ||
| if (sharp && process.versions.electron && runtimePlatform.startsWith("linux")) { | ||
| process.emitWarning( | ||
| "Binaries provided by Electron for use on Linux may be incompatible with sharp - see https://sharp.pixelplumbing.com/install#electron-and-linux", | ||
| { code: "SharpElectronLinux" } | ||
| ); | ||
| } | ||
| } catch (err) { | ||
@@ -94,0 +100,0 @@ errors.push(err); |
+6
-0
@@ -92,2 +92,8 @@ /*! | ||
| } | ||
| if (sharp && process.versions.electron && runtimePlatform.startsWith("linux")) { | ||
| process.emitWarning( | ||
| "Binaries provided by Electron for use on Linux may be incompatible with sharp - see https://sharp.pixelplumbing.com/install#electron-and-linux", | ||
| { code: "SharpElectronLinux" } | ||
| ); | ||
| } | ||
| } catch (err) { | ||
@@ -94,0 +100,0 @@ errors.push(err); |
+7
-1
@@ -117,2 +117,8 @@ /*! | ||
| } else if (is.object(options)) { | ||
| for (const property of ['memory', 'files', 'items']) { | ||
| const value = options[property]; | ||
| if (is.defined(value) && !(is.integer(value) && value >= 0)) { | ||
| throw is.invalidParameterError(property, 'a positive integer', value); | ||
| } | ||
| } | ||
| return sharp.cache(options.memory, options.files, options.items); | ||
@@ -159,3 +165,3 @@ } else { | ||
| /* node:coverage ignore next 7 */ | ||
| if (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) { | ||
| if (!process.env.MALLOC_ARENA_MAX && detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) { | ||
| // Reduce default concurrency to 1 when using glibc memory allocator | ||
@@ -162,0 +168,0 @@ sharp.concurrency(1); |
+7
-1
@@ -117,2 +117,8 @@ /*! | ||
| } else if (is.object(options)) { | ||
| for (const property of ['memory', 'files', 'items']) { | ||
| const value = options[property]; | ||
| if (is.defined(value) && !(is.integer(value) && value >= 0)) { | ||
| throw is.invalidParameterError(property, 'a positive integer', value); | ||
| } | ||
| } | ||
| return sharp.cache(options.memory, options.files, options.items); | ||
@@ -159,3 +165,3 @@ } else { | ||
| /* node:coverage ignore next 7 */ | ||
| if (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) { | ||
| if (!process.env.MALLOC_ARENA_MAX && detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) { | ||
| // Reduce default concurrency to 1 when using glibc memory allocator | ||
@@ -162,0 +168,0 @@ sharp.concurrency(1); |
+33
-33
| { | ||
| "name": "sharp", | ||
| "description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images", | ||
| "version": "0.35.2", | ||
| "version": "0.35.3-rc.1", | ||
| "author": "Lovell Fuller <npm@lovell.info>", | ||
@@ -163,40 +163,40 @@ "homepage": "https://sharp.pixelplumbing.com", | ||
| "detect-libc": "^2.1.2", | ||
| "semver": "^7.8.4" | ||
| "semver": "^7.8.5" | ||
| }, | ||
| "optionalDependencies": { | ||
| "@img/sharp-darwin-arm64": "0.35.2", | ||
| "@img/sharp-darwin-x64": "0.35.2", | ||
| "@img/sharp-freebsd-wasm32": "0.35.2", | ||
| "@img/sharp-libvips-darwin-arm64": "1.3.1", | ||
| "@img/sharp-libvips-darwin-x64": "1.3.1", | ||
| "@img/sharp-libvips-linux-arm": "1.3.1", | ||
| "@img/sharp-libvips-linux-arm64": "1.3.1", | ||
| "@img/sharp-libvips-linux-ppc64": "1.3.1", | ||
| "@img/sharp-libvips-linux-riscv64": "1.3.1", | ||
| "@img/sharp-libvips-linux-s390x": "1.3.1", | ||
| "@img/sharp-libvips-linux-x64": "1.3.1", | ||
| "@img/sharp-libvips-linuxmusl-arm64": "1.3.1", | ||
| "@img/sharp-libvips-linuxmusl-x64": "1.3.1", | ||
| "@img/sharp-linux-arm": "0.35.2", | ||
| "@img/sharp-linux-arm64": "0.35.2", | ||
| "@img/sharp-linux-ppc64": "0.35.2", | ||
| "@img/sharp-linux-riscv64": "0.35.2", | ||
| "@img/sharp-linux-s390x": "0.35.2", | ||
| "@img/sharp-linux-x64": "0.35.2", | ||
| "@img/sharp-linuxmusl-arm64": "0.35.2", | ||
| "@img/sharp-linuxmusl-x64": "0.35.2", | ||
| "@img/sharp-webcontainers-wasm32": "0.35.2", | ||
| "@img/sharp-win32-arm64": "0.35.2", | ||
| "@img/sharp-win32-ia32": "0.35.2", | ||
| "@img/sharp-win32-x64": "0.35.2" | ||
| "@img/sharp-darwin-arm64": "0.35.3-rc.1", | ||
| "@img/sharp-darwin-x64": "0.35.3-rc.1", | ||
| "@img/sharp-freebsd-wasm32": "0.35.3-rc.1", | ||
| "@img/sharp-libvips-darwin-arm64": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-darwin-x64": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-linux-arm": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-linux-arm64": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-linux-ppc64": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-linux-riscv64": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-linux-s390x": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-linux-x64": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-linuxmusl-arm64": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-linuxmusl-x64": "1.3.2-rc.0", | ||
| "@img/sharp-linux-arm": "0.35.3-rc.1", | ||
| "@img/sharp-linux-arm64": "0.35.3-rc.1", | ||
| "@img/sharp-linux-ppc64": "0.35.3-rc.1", | ||
| "@img/sharp-linux-riscv64": "0.35.3-rc.1", | ||
| "@img/sharp-linux-s390x": "0.35.3-rc.1", | ||
| "@img/sharp-linux-x64": "0.35.3-rc.1", | ||
| "@img/sharp-linuxmusl-arm64": "0.35.3-rc.1", | ||
| "@img/sharp-linuxmusl-x64": "0.35.3-rc.1", | ||
| "@img/sharp-webcontainers-wasm32": "0.35.3-rc.1", | ||
| "@img/sharp-win32-arm64": "0.35.3-rc.1", | ||
| "@img/sharp-win32-ia32": "0.35.3-rc.1", | ||
| "@img/sharp-win32-x64": "0.35.3-rc.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@biomejs/biome": "^2.5.0", | ||
| "@biomejs/biome": "^2.5.1", | ||
| "@cpplint/cli": "^0.1.0", | ||
| "@emnapi/runtime": "^1.11.1", | ||
| "@img/sharp-libvips-dev": "1.3.1", | ||
| "@img/sharp-libvips-dev-wasm32": "1.3.1", | ||
| "@img/sharp-libvips-win32-arm64": "1.3.1", | ||
| "@img/sharp-libvips-win32-ia32": "1.3.1", | ||
| "@img/sharp-libvips-win32-x64": "1.3.1", | ||
| "@img/sharp-libvips-dev": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-dev-wasm32": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-win32-arm64": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-win32-ia32": "1.3.2-rc.0", | ||
| "@img/sharp-libvips-win32-x64": "1.3.2-rc.0", | ||
| "@types/node": "*", | ||
@@ -203,0 +203,0 @@ "emnapi": "^1.11.1", |
+2
-0
@@ -52,2 +52,3 @@ /*! | ||
| bool typedArrayOut; | ||
| bool hasAlphaOut; | ||
| std::vector<Composite *> composite; | ||
@@ -253,2 +254,3 @@ std::vector<sharp::InputDescriptor *> joinChannelIn; | ||
| typedArrayOut(false), | ||
| hasAlphaOut(false), | ||
| topOffsetPre(-1), | ||
@@ -255,0 +257,0 @@ topOffsetPost(-1), |
+3
-3
@@ -26,11 +26,11 @@ /*! | ||
| if (info[size_t(0)].IsNumber()) { | ||
| vips_cache_set_max_mem(info[size_t(0)].As<Napi::Number>().Int32Value() * 1048576); | ||
| vips_cache_set_max_mem(static_cast<size_t>(info[size_t(0)].As<Napi::Number>().Uint32Value()) * 1048576); | ||
| } | ||
| // Set file limit | ||
| if (info[size_t(1)].IsNumber()) { | ||
| vips_cache_set_max_files(info[size_t(1)].As<Napi::Number>().Int32Value()); | ||
| vips_cache_set_max_files(info[size_t(1)].As<Napi::Number>().Uint32Value()); | ||
| } | ||
| // Set items limit | ||
| if (info[size_t(2)].IsNumber()) { | ||
| vips_cache_set_max(info[size_t(2)].As<Napi::Number>().Int32Value()); | ||
| vips_cache_set_max(info[size_t(2)].As<Napi::Number>().Uint32Value()); | ||
| } | ||
@@ -37,0 +37,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
957723
0.77%13786
0.41%17
13.33%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated