{"id":"147e15b268c36ab1","repo":"sindresorhus/is","slug":"expected-value-which-is-blob-received-value-of","errorCode":null,"errorMessage":"Expected value which is `Blob`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `Blob`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1504,"sourceCode":"\t\tthrow new TypeError(message ?? typeErrorMessage('bigint', value));\n\t}\n}\n\nexport function assertBigInt64Array(value: unknown, message?: string): asserts value is BigInt64Array {\n\tif (!isBigInt64Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('BigInt64Array', value));\n\t}\n}\n\nexport function assertBigUint64Array(value: unknown, message?: string): asserts value is BigUint64Array {\n\tif (!isBigUint64Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('BigUint64Array', value));\n\t}\n}\n\nexport function assertBlob(value: unknown, message?: string): asserts value is Blob {\n\tif (!isBlob(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Blob', value));\n\t}\n}\n\nexport function assertBoolean(value: unknown, message?: string): asserts value is boolean {\n\tif (!isBoolean(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('boolean', value));\n\t}\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function assertBoundFunction(value: unknown, message?: string): asserts value is Function {\n\tif (!isBoundFunction(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('bound Function', value));\n\t}\n}\n\n/**\nNote: [Prefer using `Uint8Array` instead of `Buffer`.](https://sindresorhus.com/blog/goodbye-nodejs-buffer)","sourceCodeStart":1486,"sourceCodeEnd":1522,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1486-L1522","documentation":"Thrown by `assertBlob()` when the value fails `isBlob` (object type check for 'Blob'). It guarantees callers can use Blob APIs (`.arrayBuffer()`, `.stream()`, `.size`) without runtime crashes.","triggerScenarios":"Calling `assert.blob(value)` with a Buffer, ArrayBuffer, Uint8Array, string, File-like plain object, or a stream instead of an actual Blob instance.","commonSituations":"Node.js < 18 (or older polyfill setups) where global `Blob` didn't exist and code passed Buffers instead; form-upload handlers receiving multipart data as Buffers; cross-library confusion between `File`/`Blob` polyfills (e.g., from `fetch-blob`) whose instances may not match the realm's Blob; JSDOM/test environments lacking Blob.","solutions":["Convert binary data to a Blob before asserting: `new Blob([buffer])`.","On Node, ensure Node ≥ 18 (or import Blob from 'node:buffer') so a real Blob class exists.","If using a Blob polyfill in tests, ensure the same Blob implementation is used by producer and consumer.","Check `is(value)` in the message to see what you actually received and fix the upstream producer."],"exampleFix":"// before\nassert.blob(fileBuffer);\n// after\nassert.blob(new Blob([fileBuffer]));","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof Blob)) {\n  value = new Blob([value]); // wrap explicitly if raw data\n}","typeGuard":"function isBlob(value: unknown): value is Blob {\n  return typeof Blob !== 'undefined' && value instanceof Blob;\n}","tryCatchPattern":"try {\n  assert.blob(value);\n} catch (error) {\n  if (error instanceof TypeError) {\n    // likely a Buffer, ArrayBuffer, or string — wrap in new Blob([...]) or reject\n  } else throw error;\n}","preventionTips":["In Node, Blob exists only in Node 18+ (node:buffer) — verify runtime support before relying on it","File extends Blob, so File passes; Buffer and ArrayBuffer do not — wrap them with new Blob([data])","Check fetch/form-data payloads at the boundary where they enter your code, not deep inside"],"tags":["type-assertion","blob","binary-data","node"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}