(doc)
| 5 | new Intl.ListFormat("en-US", { type: "disjunction" }).format(list); |
| 6 | |
| 7 | function getDocErrorMessage(doc) { |
| 8 | const type = doc === null ? "null" : typeof doc; |
| 9 | if (type !== "string" && type !== "object") { |
| 10 | return `Unexpected doc '${type}', \nExpected it to be 'string' or 'object'.`; |
| 11 | } |
| 12 | |
| 13 | /* c8 ignore next 3 */ |
| 14 | if (getDocType(doc)) { |
| 15 | throw new Error("doc is valid."); |
| 16 | } |
| 17 | |
| 18 | // eslint-disable-next-line prettier-internal-rules/no-unnecessary-ast-path-call |
| 19 | const objectType = Object.prototype.toString.call(doc); |
| 20 | if (objectType !== "[object Object]") { |
| 21 | return `Unexpected doc '${objectType}'.`; |
| 22 | } |
| 23 | |
| 24 | const EXPECTED_TYPE_VALUES = disjunctionListFormat( |
| 25 | [...VALID_OBJECT_DOC_TYPES].map((type) => `'${type}'`), |
| 26 | ); |
| 27 | |
| 28 | return `Unexpected doc.type '${doc.type}'.\nExpected it to be ${EXPECTED_TYPE_VALUES}.`; |
| 29 | } |
| 30 | |
| 31 | class InvalidDocError extends Error { |
| 32 | name = "InvalidDocError"; |
no test coverage detected
searching dependent graphs…