Improve error messages for invalid resize parameters

Dependency version bumps and doc refresh
This commit is contained in:
Lovell Fuller
2017-01-05 22:16:59 +00:00
parent 4858ebe051
commit 70a3d4fb5e
15 changed files with 182 additions and 76 deletions

View File

@@ -80,6 +80,21 @@ const inArray = function (val, list) {
return list.indexOf(val) !== -1;
};
/**
* Create an Error with a message relating to an invalid parameter.
*
* @param {String} name - parameter name.
* @param {String} expected - description of the type/value/range expected.
* @param {*} actual - the value received.
* @returns {Error} Containing the formatted message.
* @private
*/
const invalidParameterError = function (name, expected, actual) {
return new Error(
`Expected ${expected} for ${name} but received ${actual} of type ${typeof actual}`
);
};
module.exports = {
defined: defined,
object: object,
@@ -90,5 +105,6 @@ module.exports = {
number: number,
integer: integer,
inRange: inRange,
inArray: inArray
inArray: inArray,
invalidParameterError: invalidParameterError
};