UNPKG

@ai-sdk/provider-utils

Version:
10 lines (9 loc) 318 B
/** * Type-guard for Node.js `Buffer` instances. * * Uses optional chaining on `globalThis.Buffer` so it returns `false` in * runtimes where `Buffer` is not available (e.g. CloudFlare Workers). */ export function isBuffer(value: unknown): value is Buffer { return globalThis.Buffer?.isBuffer(value) ?? false; }