{"id":"88b96ca682546e0e","repo":"sindresorhus/is","slug":"expected-value-which-is-int8array-received-valu","errorCode":null,"errorMessage":"Expected value which is `Int8Array`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `Int8Array`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1689,"sourceCode":"\t\tthrow new TypeError(message ?? typeErrorMessage('in range', value));\n\t}\n}\n\nexport function assertInt16Array(value: unknown, message?: string): asserts value is Int16Array {\n\tif (!isInt16Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Int16Array', value));\n\t}\n}\n\nexport function assertInt32Array(value: unknown, message?: string): asserts value is Int32Array {\n\tif (!isInt32Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Int32Array', value));\n\t}\n}\n\nexport function assertInt8Array(value: unknown, message?: string): asserts value is Int8Array {\n\tif (!isInt8Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Int8Array', value));\n\t}\n}\n\nexport function assertInteger(value: unknown, message?: string): asserts value is number {\n\tif (!isInteger(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('integer', value));\n\t}\n}\n\nexport function assertIterable<T = unknown>(value: unknown, message?: string): asserts value is Iterable<T> {\n\tif (!isIterable(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Iterable', value));\n\t}\n}\n\nexport function assertMap<Key = unknown, Value = unknown>(value: unknown, message?: string): asserts value is Map<Key, Value> {\n\tif (!isMap(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Map', value));","sourceCodeStart":1671,"sourceCodeEnd":1707,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1671-L1707","documentation":"Thrown by `assertInt8Array()` (source/index.ts:1687) when `isInt8Array()` fails; that predicate requires the value's object type tag to be exactly 'Int8Array'. It exists so code consuming signed 8-bit binary data fails immediately with the received type named rather than misbehaving later.","triggerScenarios":"Calling `assertInt8Array(value)` with a Uint8Array, Node.js Buffer (which is a Uint8Array subclass, tag 'Uint8Array'), plain array, ArrayBuffer, or DataView — only a genuine Int8Array passes.","commonSituations":"Node.js Buffers are the classic trap: `fs.readFile` and network APIs return Buffer/Uint8Array, which fails the Int8Array check even though the bytes are compatible. Also plain arrays from JSON payloads.","solutions":["Convert without copying: `new Int8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength)` for a Buffer/Uint8Array view.","Construct from a plain array or ArrayBuffer: `new Int8Array(data)`.","If unsigned bytes are actually what you handle, assert `assertUint8Array()` or the generic `assertTypedArray()` instead."],"exampleFix":"// before\nconst buf = await fs.promises.readFile(path);\nassertInt8Array(buf); // throws — Buffer is a Uint8Array\n// after\nconst bytes = new Int8Array(buf.buffer, buf.byteOffset, buf.byteLength);\nassertInt8Array(bytes);","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof Int8Array)) {\n  throw new TypeError('Expected Int8Array, got ' + (value?.constructor?.name ?? typeof value));\n}","typeGuard":"const isInt8Array = (v: unknown): v is Int8Array => v instanceof Int8Array;","tryCatchPattern":null,"preventionTips":["Use is.int8Array(value) as a guard instead of relying on assert to throw","Note Node's Buffer is a Uint8Array, not an Int8Array — convert with new Int8Array(buf.buffer, buf.byteOffset, buf.length) if needed","Construct typed arrays explicitly at the boundary rather than passing raw ArrayBuffers"],"tags":["typed-array","buffer","node","type-assertion"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}