sharp 0.34.4 → 0.34.5-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ /*!
2
+ Copyright 2013 Lovell Fuller and others.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ const {
7
+ useGlobalLibvips,
8
+ globalLibvipsVersion,
9
+ log,
10
+ spawnRebuild,
11
+ } = require('../lib/libvips');
12
+
13
+ log('Attempting to build from source via node-gyp');
14
+ log('See https://sharp.pixelplumbing.com/install#building-from-source');
15
+
16
+ try {
17
+ const addonApi = require('node-addon-api');
18
+ log(`Found node-addon-api ${addonApi.version || ''}`);
19
+ } catch (_err) {
20
+ log('Please add node-addon-api to your dependencies');
21
+ process.exit(1);
22
+ }
23
+ try {
24
+ const gyp = require('node-gyp');
25
+ log(`Found node-gyp ${gyp().version}`);
26
+ } catch (_err) {
27
+ log('Please add node-gyp to your dependencies');
28
+ process.exit(1);
29
+ }
30
+
31
+ if (useGlobalLibvips(log)) {
32
+ log(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
33
+ }
34
+
35
+ const status = spawnRebuild();
36
+ if (status !== 0) {
37
+ process.exit(status);
38
+ }
package/install/check.js CHANGED
@@ -1,39 +1,12 @@
1
- // Copyright 2013 Lovell Fuller and others.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- 'use strict';
1
+ /*!
2
+ Copyright 2013 Lovell Fuller and others.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
5
 
6
6
  try {
7
- const { useGlobalLibvips, globalLibvipsVersion, log, spawnRebuild } = require('../lib/libvips');
8
-
9
- const buildFromSource = (msg) => {
10
- log(msg);
11
- log('Attempting to build from source via node-gyp');
12
- try {
13
- const addonApi = require('node-addon-api');
14
- log(`Found node-addon-api ${addonApi.version || ''}`);
15
- } catch (err) {
16
- log('Please add node-addon-api to your dependencies');
17
- return;
18
- }
19
- try {
20
- const gyp = require('node-gyp');
21
- log(`Found node-gyp ${gyp().version}`);
22
- } catch (err) {
23
- log('Please add node-gyp to your dependencies');
24
- return;
25
- }
26
- log('See https://sharp.pixelplumbing.com/install#building-from-source');
27
- const status = spawnRebuild();
28
- if (status !== 0) {
29
- process.exit(status);
30
- }
31
- };
32
-
33
- if (useGlobalLibvips(log)) {
34
- buildFromSource(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
35
- } else if (process.env.npm_config_build_from_source) {
36
- buildFromSource('Detected --build-from-source flag');
7
+ const { useGlobalLibvips } = require('../lib/libvips');
8
+ if (useGlobalLibvips() || process.env.npm_config_build_from_source) {
9
+ process.exit(1);
37
10
  }
38
11
  } catch (err) {
39
12
  const summary = err.message.split(/\n/).slice(0, 1);
package/lib/channel.js CHANGED
@@ -1,7 +1,7 @@
1
- // Copyright 2013 Lovell Fuller and others.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- 'use strict';
1
+ /*!
2
+ Copyright 2013 Lovell Fuller and others.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
5
 
6
6
  const is = require('./is');
7
7
 
@@ -18,7 +18,7 @@ const bool = {
18
18
  /**
19
19
  * Remove alpha channels, if any. This is a no-op if the image does not have an alpha channel.
20
20
  *
21
- * See also {@link /api-operation#flatten|flatten}.
21
+ * See also {@link /api-operation/#flatten flatten}.
22
22
  *
23
23
  * @example
24
24
  * sharp('rgba.png')
@@ -163,7 +163,7 @@ function bandbool (boolOp) {
163
163
  * @module Sharp
164
164
  * @private
165
165
  */
166
- module.exports = function (Sharp) {
166
+ module.exports = (Sharp) => {
167
167
  Object.assign(Sharp.prototype, {
168
168
  // Public instance functions
169
169
  removeAlpha,
package/lib/colour.js CHANGED
@@ -1,7 +1,7 @@
1
- // Copyright 2013 Lovell Fuller and others.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- 'use strict';
1
+ /*!
2
+ Copyright 2013 Lovell Fuller and others.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
5
 
6
6
  const color = require('@img/colour');
7
7
  const is = require('./is');
@@ -69,7 +69,7 @@ function grayscale (grayscale) {
69
69
  *
70
70
  * The input image will be converted to the provided colourspace at the start of the pipeline.
71
71
  * All operations will use this colourspace before converting to the output colourspace,
72
- * as defined by {@link #tocolourspace|toColourspace}.
72
+ * as defined by {@link #tocolourspace toColourspace}.
73
73
  *
74
74
  * @since 0.29.0
75
75
  *
@@ -80,7 +80,7 @@ function grayscale (grayscale) {
80
80
  * .toColourspace('srgb')
81
81
  * .toFile('16bpc-pipeline-to-8bpc-output.png')
82
82
  *
83
- * @param {string} [colourspace] - pipeline colourspace e.g. `rgb16`, `scrgb`, `lab`, `grey16` [...](https://github.com/libvips/libvips/blob/41cff4e9d0838498487a00623462204eb10ee5b8/libvips/iofuncs/enumtypes.c#L774)
83
+ * @param {string} [colourspace] - pipeline colourspace e.g. `rgb16`, `scrgb`, `lab`, `grey16` [...](https://www.libvips.org/API/current/enum.Interpretation.html)
84
84
  * @returns {Sharp}
85
85
  * @throws {Error} Invalid parameters
86
86
  */
@@ -112,7 +112,7 @@ function pipelineColorspace (colorspace) {
112
112
  * .toColourspace('rgb16')
113
113
  * .toFile('16-bpp.png')
114
114
  *
115
- * @param {string} [colourspace] - output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://github.com/libvips/libvips/blob/3c0bfdf74ce1dc37a6429bed47fa76f16e2cd70a/libvips/iofuncs/enumtypes.c#L777-L794)
115
+ * @param {string} [colourspace] - output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/enum.Interpretation.html)
116
116
  * @returns {Sharp}
117
117
  * @throws {Error} Invalid parameters
118
118
  */
@@ -141,7 +141,10 @@ function toColorspace (colorspace) {
141
141
  * @throws {Error} Invalid value
142
142
  */
143
143
  function _getBackgroundColourOption (value) {
144
- if (is.object(value) || is.string(value)) {
144
+ if (
145
+ is.object(value) ||
146
+ (is.string(value) && value.length >= 3 && value.length <= 200)
147
+ ) {
145
148
  const colour = color(value);
146
149
  return [
147
150
  colour.red(),
@@ -172,7 +175,7 @@ function _setBackgroundColourOption (key, value) {
172
175
  * @module Sharp
173
176
  * @private
174
177
  */
175
- module.exports = function (Sharp) {
178
+ module.exports = (Sharp) => {
176
179
  Object.assign(Sharp.prototype, {
177
180
  // Public
178
181
  tint,
package/lib/composite.js CHANGED
@@ -1,7 +1,7 @@
1
- // Copyright 2013 Lovell Fuller and others.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- 'use strict';
1
+ /*!
2
+ Copyright 2013 Lovell Fuller and others.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
5
 
6
6
  const is = require('./is');
7
7
 
@@ -56,7 +56,7 @@ const blend = {
56
56
  * `hard-light`, `soft-light`, `difference`, `exclusion`.
57
57
  *
58
58
  * More information about blend modes can be found at
59
- * https://www.libvips.org/API/current/libvips-conversion.html#VipsBlendMode
59
+ * https://www.libvips.org/API/current/enum.BlendMode.html
60
60
  * and https://www.cairographics.org/operators/
61
61
  *
62
62
  * @since 0.22.0
@@ -123,8 +123,8 @@ const blend = {
123
123
  * @param {Number} [images[].raw.height]
124
124
  * @param {Number} [images[].raw.channels]
125
125
  * @param {boolean} [images[].animated=false] - Set to `true` to read all frames/pages of an animated image.
126
- * @param {string} [images[].failOn='warning'] - @see {@link /api-constructor#parameters|constructor parameters}
127
- * @param {number|boolean} [images[].limitInputPixels=268402689] - @see {@link /api-constructor#parameters|constructor parameters}
126
+ * @param {string} [images[].failOn='warning'] - @see {@link /api-constructor/ constructor parameters}
127
+ * @param {number|boolean} [images[].limitInputPixels=268402689] - @see {@link /api-constructor/ constructor parameters}
128
128
  * @returns {Sharp}
129
129
  * @throws {Error} Invalid parameters
130
130
  */
@@ -206,7 +206,7 @@ function composite (images) {
206
206
  * @module Sharp
207
207
  * @private
208
208
  */
209
- module.exports = function (Sharp) {
209
+ module.exports = (Sharp) => {
210
210
  Sharp.prototype.composite = composite;
211
211
  Sharp.blend = blend;
212
212
  };
@@ -1,7 +1,7 @@
1
- // Copyright 2013 Lovell Fuller and others.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- 'use strict';
1
+ /*!
2
+ Copyright 2013 Lovell Fuller and others.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
5
 
6
6
  const util = require('node:util');
7
7
  const stream = require('node:stream');
@@ -12,6 +12,10 @@ require('./sharp');
12
12
  // Use NODE_DEBUG=sharp to enable libvips warnings
13
13
  const debuglog = util.debuglog('sharp');
14
14
 
15
+ const queueListener = (queueLength) => {
16
+ Sharp.queue.emit('change', queueLength);
17
+ };
18
+
15
19
  /**
16
20
  * Constructor factory to create an instance of `sharp`, to which further methods are chained.
17
21
  *
@@ -205,6 +209,7 @@ const debuglog = util.debuglog('sharp');
205
209
  * @throws {Error} Invalid parameters
206
210
  */
207
211
  const Sharp = function (input, options) {
212
+ // biome-ignore lint/complexity/noArguments: constructor factory
208
213
  if (arguments.length === 1 && !is.defined(input)) {
209
214
  throw new Error('Invalid input');
210
215
  }
@@ -353,6 +358,7 @@ const Sharp = function (input, options) {
353
358
  gifProgressive: false,
354
359
  tiffQuality: 80,
355
360
  tiffCompression: 'jpeg',
361
+ tiffBigtiff: false,
356
362
  tiffPredictor: 'horizontal',
357
363
  tiffPyramid: false,
358
364
  tiffMiniswhite: false,
@@ -396,9 +402,7 @@ const Sharp = function (input, options) {
396
402
  debuglog(warning);
397
403
  },
398
404
  // Function to notify of queue length changes
399
- queueListener: function (queueLength) {
400
- Sharp.queue.emit('change', queueLength);
401
- }
405
+ queueListener
402
406
  };
403
407
  this.options.input = this._createInputDescriptor(input, options, { allowStream: true });
404
408
  return this;
package/lib/index.d.ts CHANGED
@@ -27,7 +27,7 @@
27
27
 
28
28
  /// <reference types="node" />
29
29
 
30
- import { Duplex } from 'stream';
30
+ import type { Duplex } from 'node:stream';
31
31
 
32
32
  //#region Constructor functions
33
33
 
@@ -860,6 +860,7 @@ declare namespace sharp {
860
860
  | JxlOptions
861
861
  | GifOptions
862
862
  | Jp2Options
863
+ | RawOptions
863
864
  | TiffOptions,
864
865
  ): Sharp;
865
866
 
@@ -1181,6 +1182,10 @@ declare namespace sharp {
1181
1182
  'IFD3'?: ExifDir;
1182
1183
  }
1183
1184
 
1185
+ type HeifCompression = 'av1' | 'hevc';
1186
+
1187
+ type Unit = 'inch' | 'cm';
1188
+
1184
1189
  interface WriteableMetadata {
1185
1190
  /** Number of pixels per inch (DPI) */
1186
1191
  density?: number | undefined;
@@ -1259,7 +1264,7 @@ declare namespace sharp {
1259
1264
  /** Buffer containing raw TIFFTAG_PHOTOSHOP data, if present */
1260
1265
  tifftagPhotoshop?: Buffer | undefined;
1261
1266
  /** The encoder used to compress an HEIF file, `av1` (AVIF) or `hevc` (HEIC) */
1262
- compression?: 'av1' | 'hevc';
1267
+ compression?: HeifCompression | undefined;
1263
1268
  /** Default background colour, if present, for PNG (bKGD) and GIF images */
1264
1269
  background?: { r: number; g: number; b: number } | { gray: number };
1265
1270
  /** Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide */
@@ -1267,7 +1272,7 @@ declare namespace sharp {
1267
1272
  /** Number of Sub Image File Directories in an OME-TIFF image */
1268
1273
  subifds?: number | undefined;
1269
1274
  /** The unit of resolution (density) */
1270
- resolutionUnit?: 'inch' | 'cm' | undefined;
1275
+ resolutionUnit?: Unit | undefined;
1271
1276
  /** String containing format for images loaded via *magick */
1272
1277
  formatMagick?: string | undefined;
1273
1278
  /** Array of keyword/text pairs representing PNG text blocks, if present. */
@@ -1423,7 +1428,7 @@ declare namespace sharp {
1423
1428
  /** quality, integer 1-100 (optional, default 50) */
1424
1429
  quality?: number | undefined;
1425
1430
  /** compression format: av1, hevc (optional, default 'av1') */
1426
- compression?: 'av1' | 'hevc' | undefined;
1431
+ compression?: HeifCompression | undefined;
1427
1432
  /** use lossless compression (optional, default false) */
1428
1433
  lossless?: boolean | undefined;
1429
1434
  /** Level of CPU effort to reduce file size, between 0 (fastest) and 9 (slowest) (optional, default 4) */
@@ -1460,6 +1465,8 @@ declare namespace sharp {
1460
1465
  quality?: number | undefined;
1461
1466
  /** Compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k (optional, default 'jpeg') */
1462
1467
  compression?: string | undefined;
1468
+ /** Use BigTIFF variant (has no effect when compression is none) (optional, default false) */
1469
+ bigtiff?: boolean | undefined;
1463
1470
  /** Compression predictor options: none, horizontal, float (optional, default 'horizontal') */
1464
1471
  predictor?: string | undefined;
1465
1472
  /** Write an image pyramid (optional, default false) */
@@ -1479,7 +1486,7 @@ declare namespace sharp {
1479
1486
  /** Write 1-bit images as miniswhite (optional, default false) */
1480
1487
  miniswhite?: boolean | undefined;
1481
1488
  /** Resolution unit options: inch, cm (optional, default 'inch') */
1482
- resolutionUnit?: 'inch' | 'cm' | undefined;
1489
+ resolutionUnit?: Unit | undefined;
1483
1490
  }
1484
1491
 
1485
1492
  interface PngOptions extends OutputOptions {
@@ -1604,7 +1611,7 @@ declare namespace sharp {
1604
1611
  }
1605
1612
 
1606
1613
  interface RawOptions {
1607
- depth?: 'char' | 'uchar' | 'short' | 'ushort' | 'int' | 'uint' | 'float' | 'complex' | 'double' | 'dpcomplex';
1614
+ depth?: keyof DepthEnum;
1608
1615
  }
1609
1616
 
1610
1617
  /** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
- // Copyright 2013 Lovell Fuller and others.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- 'use strict';
1
+ /*!
2
+ Copyright 2013 Lovell Fuller and others.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
5
 
6
6
  const Sharp = require('./constructor');
7
7
  require('./input')(Sharp);
package/lib/input.js CHANGED
@@ -1,7 +1,7 @@
1
- // Copyright 2013 Lovell Fuller and others.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- 'use strict';
1
+ /*!
2
+ Copyright 2013 Lovell Fuller and others.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
5
 
6
6
  const is = require('./is');
7
7
  const sharp = require('./sharp');
@@ -54,7 +54,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
54
54
  const inputDescriptor = {
55
55
  autoOrient: false,
56
56
  failOn: 'warning',
57
- limitInputPixels: Math.pow(0x3FFF, 2),
57
+ limitInputPixels: 0x3FFF ** 2,
58
58
  ignoreIcc: false,
59
59
  unlimited: false,
60
60
  sequentialRead: true
@@ -150,7 +150,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
150
150
  if (is.defined(inputOptions.limitInputPixels)) {
151
151
  if (is.bool(inputOptions.limitInputPixels)) {
152
152
  inputDescriptor.limitInputPixels = inputOptions.limitInputPixels
153
- ? Math.pow(0x3FFF, 2)
153
+ ? 0x3FFF ** 2
154
154
  : 0;
155
155
  } else if (is.integer(inputOptions.limitInputPixels) && is.inRange(inputOptions.limitInputPixels, 0, Number.MAX_SAFE_INTEGER)) {
156
156
  inputDescriptor.limitInputPixels = inputOptions.limitInputPixels;
@@ -513,7 +513,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
513
513
  }
514
514
  }
515
515
  } else if (is.defined(inputOptions)) {
516
- throw new Error('Invalid input options ' + inputOptions);
516
+ throw new Error(`Invalid input options ${inputOptions}`);
517
517
  }
518
518
  return inputDescriptor;
519
519
  }
@@ -525,10 +525,8 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
525
525
  * @param {string} encoding - unused
526
526
  * @param {Function} callback
527
527
  */
528
- function _write (chunk, encoding, callback) {
529
- /* istanbul ignore else */
528
+ function _write (chunk, _encoding, callback) {
530
529
  if (Array.isArray(this.options.input.buffer)) {
531
- /* istanbul ignore else */
532
530
  if (is.buffer(chunk)) {
533
531
  if (this.options.input.buffer.length === 0) {
534
532
  this.on('finish', () => {
@@ -572,7 +570,7 @@ function _isStreamInput () {
572
570
  * such as resize or rotate.
573
571
  *
574
572
  * Dimensions in the response will respect the `page` and `pages` properties of the
575
- * {@link /api-constructor#parameters|constructor parameters}.
573
+ * {@link /api-constructor/ constructor parameters}.
576
574
  *
577
575
  * A `Promise` is returned when `callback` is not provided.
578
576
  *
@@ -580,9 +578,9 @@ function _isStreamInput () {
580
578
  * - `size`: Total size of image in bytes, for Stream and Buffer input only
581
579
  * - `width`: Number of pixels wide (EXIF orientation is not taken into consideration, see example below)
582
580
  * - `height`: Number of pixels high (EXIF orientation is not taken into consideration, see example below)
583
- * - `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/VipsImage.html#VipsInterpretation)
581
+ * - `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/enum.Interpretation.html)
584
582
  * - `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK
585
- * - `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...](https://www.libvips.org/API/current/VipsImage.html#VipsBandFormat)
583
+ * - `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...](https://www.libvips.org/API/current/enum.BandFormat.html)
586
584
  * - `density`: Number of pixels per inch (DPI), if present
587
585
  * - `chromaSubsampling`: String containing JPEG chroma subsampling, `4:2:0` or `4:4:4` for RGB, `4:2:0:4` or `4:4:4:4` for CMYK
588
586
  * - `isProgressive`: Boolean indicating whether the image is interlaced using a progressive scan
@@ -794,7 +792,7 @@ function stats (callback) {
794
792
  * @module Sharp
795
793
  * @private
796
794
  */
797
- module.exports = function (Sharp) {
795
+ module.exports = (Sharp) => {
798
796
  Object.assign(Sharp.prototype, {
799
797
  // Private
800
798
  _inputOptionsFromObject,
package/lib/is.js CHANGED
@@ -1,61 +1,49 @@
1
- // Copyright 2013 Lovell Fuller and others.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- 'use strict';
1
+ /*!
2
+ Copyright 2013 Lovell Fuller and others.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
5
 
6
6
  /**
7
7
  * Is this value defined and not null?
8
8
  * @private
9
9
  */
10
- const defined = function (val) {
11
- return typeof val !== 'undefined' && val !== null;
12
- };
10
+ const defined = (val) => typeof val !== 'undefined' && val !== null;
13
11
 
14
12
  /**
15
13
  * Is this value an object?
16
14
  * @private
17
15
  */
18
- const object = function (val) {
19
- return typeof val === 'object';
20
- };
16
+ const object = (val) => typeof val === 'object';
21
17
 
22
18
  /**
23
19
  * Is this value a plain object?
24
20
  * @private
25
21
  */
26
- const plainObject = function (val) {
27
- return Object.prototype.toString.call(val) === '[object Object]';
28
- };
22
+ const plainObject = (val) => Object.prototype.toString.call(val) === '[object Object]';
29
23
 
30
24
  /**
31
25
  * Is this value a function?
32
26
  * @private
33
27
  */
34
- const fn = function (val) {
35
- return typeof val === 'function';
36
- };
28
+ const fn = (val) => typeof val === 'function';
37
29
 
38
30
  /**
39
31
  * Is this value a boolean?
40
32
  * @private
41
33
  */
42
- const bool = function (val) {
43
- return typeof val === 'boolean';
44
- };
34
+ const bool = (val) => typeof val === 'boolean';
45
35
 
46
36
  /**
47
37
  * Is this value a Buffer object?
48
38
  * @private
49
39
  */
50
- const buffer = function (val) {
51
- return val instanceof Buffer;
52
- };
40
+ const buffer = (val) => val instanceof Buffer;
53
41
 
54
42
  /**
55
43
  * Is this value a typed array object?. E.g. Uint8Array or Uint8ClampedArray?
56
44
  * @private
57
45
  */
58
- const typedArray = function (val) {
46
+ const typedArray = (val) => {
59
47
  if (defined(val)) {
60
48
  switch (val.constructor) {
61
49
  case Uint8Array:
@@ -78,49 +66,37 @@ const typedArray = function (val) {
78
66
  * Is this value an ArrayBuffer object?
79
67
  * @private
80
68
  */
81
- const arrayBuffer = function (val) {
82
- return val instanceof ArrayBuffer;
83
- };
69
+ const arrayBuffer = (val) => val instanceof ArrayBuffer;
84
70
 
85
71
  /**
86
72
  * Is this value a non-empty string?
87
73
  * @private
88
74
  */
89
- const string = function (val) {
90
- return typeof val === 'string' && val.length > 0;
91
- };
75
+ const string = (val) => typeof val === 'string' && val.length > 0;
92
76
 
93
77
  /**
94
78
  * Is this value a real number?
95
79
  * @private
96
80
  */
97
- const number = function (val) {
98
- return typeof val === 'number' && !Number.isNaN(val);
99
- };
81
+ const number = (val) => typeof val === 'number' && !Number.isNaN(val);
100
82
 
101
83
  /**
102
84
  * Is this value an integer?
103
85
  * @private
104
86
  */
105
- const integer = function (val) {
106
- return Number.isInteger(val);
107
- };
87
+ const integer = (val) => Number.isInteger(val);
108
88
 
109
89
  /**
110
90
  * Is this value within an inclusive given range?
111
91
  * @private
112
92
  */
113
- const inRange = function (val, min, max) {
114
- return val >= min && val <= max;
115
- };
93
+ const inRange = (val, min, max) => val >= min && val <= max;
116
94
 
117
95
  /**
118
96
  * Is this value within the elements of an array?
119
97
  * @private
120
98
  */
121
- const inArray = function (val, list) {
122
- return list.includes(val);
123
- };
99
+ const inArray = (val, list) => list.includes(val);
124
100
 
125
101
  /**
126
102
  * Create an Error with a message relating to an invalid parameter.
@@ -131,11 +107,9 @@ const inArray = function (val, list) {
131
107
  * @returns {Error} Containing the formatted message.
132
108
  * @private
133
109
  */
134
- const invalidParameterError = function (name, expected, actual) {
135
- return new Error(
110
+ const invalidParameterError = (name, expected, actual) => new Error(
136
111
  `Expected ${expected} for ${name} but received ${actual} of type ${typeof actual}`
137
112
  );
138
- };
139
113
 
140
114
  /**
141
115
  * Ensures an Error from C++ contains a JS stack.
@@ -145,7 +119,7 @@ const invalidParameterError = function (name, expected, actual) {
145
119
  * @returns {Error} Error with message and stack.
146
120
  * @private
147
121
  */
148
- const nativeError = function (native, context) {
122
+ const nativeError = (native, context) => {
149
123
  context.message = native.message;
150
124
  return context;
151
125
  };