UNPKG

@chai-stuff/not-length-of

Version:

Check that an object does not have a length or size property with the expected value.

71 lines (58 loc) 2.27 kB
/*! * @chai-stuff/not-length-of v0.3.2 * * Check that an object does not have a length or size property with the expected value. * * Copyright (c) 2019-present, ScottRudiger (https://github.com/ScottRudiger) * * This source code is licensed under the MIT license found in the root of this package. */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } } function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } var getNotLengthOf = function getNotLengthOf() { var alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'notLengthOf'; return function (_ref, _ref2) { var assert = _ref.assert; var addMethod = _ref2.addMethod, inspect = _ref2.inspect; return addMethod(assert, alias, function (actual, expected, message) { var _actual = inspect(actual); try { assert.throws(function () { return assert.lengthOf(actual, expected); }); } catch (err) { if (actual[Symbol.iterator] && !Array.isArray(actual) && typeof actual !== 'string') _actual = `${actual.constructor.name} ${inspect(_toConsumableArray(actual)).replace(/^\[/, '{').replace(/\]$/, '}')}`; if (typeof actual === 'function') _actual = actual.toString(); err.message = message || `expected ${_actual} not to have a length of ${inspect(expected)}`; throw err; } }); }; }; var notLengthOf = getNotLengthOf(); var getNotLengthOfAlias = function getNotLengthOfAlias(alias) { return getNotLengthOf(alias); }; Object.defineProperty(notLengthOf, 'name', { value: 'notLengthOf', configurable: true }); exports.getNotLengthOfAlias = getNotLengthOfAlias; exports.notLengthOf = notLengthOf; //# sourceMappingURL=index.js.map