UNPKG

earljs

Version:

Ergonomic, modern and type-safe assertion library

26 lines (25 loc) 821 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ArrayOfLengthMatcher = void 0; const format_1 = require("../format"); const isEqual_1 = require("../isEqual"); const Base_1 = require("./Base"); class ArrayOfLengthMatcher extends Base_1.Matcher { constructor(expectedLength) { super(); this.expectedLength = expectedLength; } check(actualItems) { if (!Array.isArray(actualItems)) { return false; } return (0, isEqual_1.isEqual)(actualItems.length, this.expectedLength); } toString() { return `[ArrayOfLength: ${(0, format_1.formatCompact)(this.expectedLength)}]`; } static make(length) { return new ArrayOfLengthMatcher(length); } } exports.ArrayOfLengthMatcher = ArrayOfLengthMatcher;