{"version":3,"file":"length.cjs","sources":["../../../src/matchers/length.js"],"sourcesContent":["import { getMatcherResult } from './utils.js';\n\n/**\n * Check if the received object has the expected length\n * @param {*} received \n * @param {*} expected \n * @returns {boolean}\n */\nexport function toHaveLength(received, expected) {\n  let actualLength;\n  \n  if (Array.isArray(received)) {\n    actualLength = received.length;\n  } else if (typeof received === 'string') {\n    actualLength = received.length;\n  } else if (received instanceof String) {\n    actualLength = received.length;\n  } else if (received instanceof Set) {\n    actualLength = received.size;\n  } else if (received instanceof Map) {\n    actualLength = received.size;\n  } else if (received && typeof received === 'object' && 'length' in received) {\n    if (ArrayBuffer.isView(received) || \n        (typeof received.length === 'number' && received.length >= 0)) {\n      actualLength = received.length;\n    } else {\n      return getMatcherResult(false, 'toHaveLength', received, expected);\n    }\n  } else {\n    return getMatcherResult(false, 'toHaveLength', received, expected);\n  }\n  \n  return getMatcherResult(actualLength === expected, 'toHaveLength', received, expected);\n}\n"],"names":["getMatcherResult"],"mappings":";;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE;AACjD,EAAE,IAAI,YAAY;AAClB;AACA,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAC/B,IAAI,YAAY,GAAG,QAAQ,CAAC,MAAM;AAClC,EAAE,CAAC,MAAM,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;AAC3C,IAAI,YAAY,GAAG,QAAQ,CAAC,MAAM;AAClC,EAAE,CAAC,MAAM,IAAI,QAAQ,YAAY,MAAM,EAAE;AACzC,IAAI,YAAY,GAAG,QAAQ,CAAC,MAAM;AAClC,EAAE,CAAC,MAAM,IAAI,QAAQ,YAAY,GAAG,EAAE;AACtC,IAAI,YAAY,GAAG,QAAQ,CAAC,IAAI;AAChC,EAAE,CAAC,MAAM,IAAI,QAAQ,YAAY,GAAG,EAAE;AACtC,IAAI,YAAY,GAAG,QAAQ,CAAC,IAAI;A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